Remove not used getDisplayLine() function and convert tabs to spaces
This commit is contained in:
parent
0f4e2016c7
commit
8d8ac9ead6
1 changed files with 33 additions and 42 deletions
|
|
@ -414,7 +414,6 @@ var EditSession = function(text, mode) {
|
||||||
var lines = this.doc.getAllLines();
|
var lines = this.doc.getAllLines();
|
||||||
var longestLine = 0;
|
var longestLine = 0;
|
||||||
var longestScreenLine = 0;
|
var longestScreenLine = 0;
|
||||||
var tabSize = this.getTabSize();
|
|
||||||
|
|
||||||
for ( var i = 0; i < lines.length; i++) {
|
for ( var i = 0; i < lines.length; i++) {
|
||||||
var line = lines[i],
|
var line = lines[i],
|
||||||
|
|
@ -440,14 +439,6 @@ var EditSession = function(text, mode) {
|
||||||
return this.doc.getLine(row);
|
return this.doc.getLine(row);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a line as it is displayed on screen. Tabs are replaced by spaces.
|
|
||||||
*/
|
|
||||||
this.getDisplayLine = function(row) {
|
|
||||||
var tab = new Array(this.getTabSize()+1).join(" ");
|
|
||||||
return this.doc.getLine(row).replace(/\t/g, tab);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.getLines = function(firstRow, lastRow) {
|
this.getLines = function(firstRow, lastRow) {
|
||||||
return this.doc.getLines(firstRow, lastRow);
|
return this.doc.getLines(firstRow, lastRow);
|
||||||
};
|
};
|
||||||
|
|
@ -947,20 +938,20 @@ var EditSession = function(text, mode) {
|
||||||
var tabSize;
|
var tabSize;
|
||||||
|
|
||||||
for (var i = 0; i < str.length; i++) {
|
for (var i = 0; i < str.length; i++) {
|
||||||
var c = str.charCodeAt(i);
|
var c = str.charCodeAt(i);
|
||||||
// Tab
|
// Tab
|
||||||
if (c == 9) {
|
if (c == 9) {
|
||||||
tabSize = this.getScreenTabSize(arr.length);
|
tabSize = this.getScreenTabSize(arr.length);
|
||||||
arr.push(TAB);
|
arr.push(TAB);
|
||||||
for (var n = 1; n < tabSize; n++) {
|
for (var n = 1; n < tabSize; n++) {
|
||||||
arr.push(TAB_SPACE);
|
arr.push(TAB_SPACE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Space
|
// Space
|
||||||
else if(c == 32) {
|
else if(c == 32) {
|
||||||
arr.push(SPACE);
|
arr.push(SPACE);
|
||||||
}
|
}
|
||||||
// CJK characters
|
// CJK characters
|
||||||
else if (
|
else if (
|
||||||
c >= 0x3040 && c <= 0x309F || // Hiragana
|
c >= 0x3040 && c <= 0x309F || // Hiragana
|
||||||
c >= 0x30A0 && c <= 0x30FF || // Katakana
|
c >= 0x30A0 && c <= 0x30FF || // Katakana
|
||||||
|
|
@ -987,13 +978,13 @@ var EditSession = function(text, mode) {
|
||||||
var screenColumn = 0;
|
var screenColumn = 0;
|
||||||
var tabSize = this.getTabSize();
|
var tabSize = this.getTabSize();
|
||||||
|
|
||||||
for (var i=0; i<str.length; i++) {
|
for (var i=0; i<str.length; i++) {
|
||||||
var c = str.charCodeAt(i);
|
var c = str.charCodeAt(i);
|
||||||
// tab
|
// tab
|
||||||
if (c == 9) {
|
if (c == 9) {
|
||||||
screenColumn += this.getScreenTabSize(screenColumn);
|
screenColumn += this.getScreenTabSize(screenColumn);
|
||||||
}
|
}
|
||||||
// CJK characters
|
// CJK characters
|
||||||
else if (
|
else if (
|
||||||
c >= 0x3040 && c <= 0x309F || // Hiragana
|
c >= 0x3040 && c <= 0x309F || // Hiragana
|
||||||
c >= 0x30A0 && c <= 0x30FF || // Katakana
|
c >= 0x30A0 && c <= 0x30FF || // Katakana
|
||||||
|
|
@ -1001,13 +992,13 @@ var EditSession = function(text, mode) {
|
||||||
c >= 0xF900 && c <= 0xFAFF ||
|
c >= 0xF900 && c <= 0xFAFF ||
|
||||||
c >= 0x3400 && c <= 0x4DBF
|
c >= 0x3400 && c <= 0x4DBF
|
||||||
) {
|
) {
|
||||||
screenColumn += 2;
|
screenColumn += 2;
|
||||||
} else {
|
} else {
|
||||||
screenColumn += 1;
|
screenColumn += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return screenColumn;
|
return screenColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getRowHeight = function(config, row) {
|
this.getRowHeight = function(config, row) {
|
||||||
|
|
@ -1125,15 +1116,15 @@ var EditSession = function(text, mode) {
|
||||||
} else {
|
} else {
|
||||||
var wrapData = this.$wrapData;
|
var wrapData = this.$wrapData;
|
||||||
|
|
||||||
var docRow = 0;
|
var docRow = 0;
|
||||||
while (docRow < linesCount && row >= wrapData[docRow].length + 1) {
|
while (docRow < linesCount && row >= wrapData[docRow].length + 1) {
|
||||||
row -= wrapData[docRow].length + 1;
|
row -= wrapData[docRow].length + 1;
|
||||||
docRow ++;
|
docRow ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (docRow >= linesCount) {
|
if (docRow >= linesCount) {
|
||||||
docRow = linesCount-1
|
docRow = linesCount-1
|
||||||
row = wrapData[docRow].length;
|
row = wrapData[docRow].length;
|
||||||
}
|
}
|
||||||
docColumn = wrapData[docRow][row - 1] || 0;
|
docColumn = wrapData[docRow][row - 1] || 0;
|
||||||
line = this.getLine(docRow).substring(docColumn);
|
line = this.getLine(docRow).substring(docColumn);
|
||||||
|
|
@ -1184,7 +1175,7 @@ var EditSession = function(text, mode) {
|
||||||
// Clamp docColumn.
|
// Clamp docColumn.
|
||||||
if (this.$useWrapMode) {
|
if (this.$useWrapMode) {
|
||||||
column = wrapData[docRow][row]
|
column = wrapData[docRow][row]
|
||||||
if (docColumn >= column) {
|
if (docColumn >= column) {
|
||||||
// We remove one character at the end such that the docColumn
|
// We remove one character at the end such that the docColumn
|
||||||
// position returned is not associated to the next row on the
|
// position returned is not associated to the next row on the
|
||||||
// screen.
|
// screen.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue