Merge pull request #1678 from ajaxorg/line_widgets_pt1
Add support for line widgets
This commit is contained in:
commit
ed87f5326f
13 changed files with 632 additions and 123 deletions
|
|
@ -1037,8 +1037,20 @@ var EditSession = function(text, mode) {
|
|||
**/
|
||||
this.getScreenWidth = function() {
|
||||
this.$computeWidth();
|
||||
if (this.lineWidgets)
|
||||
return Math.max(this.getLineWidgetMaxWidth(), this.screenWidth);
|
||||
return this.screenWidth;
|
||||
};
|
||||
|
||||
this.getLineWidgetMaxWidth = function() {
|
||||
if (this.lineWidgetsWidth != null) return this.lineWidgetsWidth
|
||||
var width = 0;
|
||||
this.lineWidgets.forEach(function(w) {
|
||||
if (w && w.screenWidth > width)
|
||||
width = w.screenWidth;
|
||||
});
|
||||
return this.lineWidgetWidth = width;
|
||||
}
|
||||
|
||||
this.$computeWidth = function(force) {
|
||||
if (this.$modified || force) {
|
||||
|
|
@ -2043,6 +2055,7 @@ var EditSession = function(text, mode) {
|
|||
return [screenColumn, column];
|
||||
};
|
||||
|
||||
this.lineWidgets = null;
|
||||
/**
|
||||
* Returns number of screenrows in a wrapped line.
|
||||
* @param {Number} row The row number to check
|
||||
|
|
@ -2050,6 +2063,17 @@ var EditSession = function(text, mode) {
|
|||
* @returns {Number}
|
||||
**/
|
||||
this.getRowLength = function(row) {
|
||||
if (this.lineWidgets)
|
||||
var h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
|
||||
else
|
||||
h = 0
|
||||
if (!this.$useWrapMode || !this.$wrapData[row]) {
|
||||
return 1 + h;
|
||||
} else {
|
||||
return this.$wrapData[row].length + 1 + h;
|
||||
}
|
||||
};
|
||||
this.getRowLineCount = function(row) {
|
||||
if (!this.$useWrapMode || !this.$wrapData[row]) {
|
||||
return 1;
|
||||
} else {
|
||||
|
|
@ -2163,7 +2187,7 @@ var EditSession = function(text, mode) {
|
|||
|
||||
while (row <= screenRow) {
|
||||
rowLength = this.getRowLength(docRow);
|
||||
if (row + rowLength - 1 >= screenRow || docRow >= maxRow) {
|
||||
if (row + rowLength > screenRow || docRow >= maxRow) {
|
||||
break;
|
||||
} else {
|
||||
row += rowLength;
|
||||
|
|
@ -2198,9 +2222,10 @@ var EditSession = function(text, mode) {
|
|||
if (this.$useWrapMode) {
|
||||
var splits = this.$wrapData[docRow];
|
||||
if (splits) {
|
||||
column = splits[screenRow - row];
|
||||
if(screenRow > row && splits.length) {
|
||||
docColumn = splits[screenRow - row - 1] || splits[splits.length - 1];
|
||||
var splitIndex = Math.floor(screenRow - row);
|
||||
column = splits[splitIndex];
|
||||
if(splitIndex > 0 && splits.length) {
|
||||
docColumn = splits[splitIndex - 1] || splits[splits.length - 1];
|
||||
line = line.substring(docColumn);
|
||||
}
|
||||
}
|
||||
|
|
@ -2372,6 +2397,10 @@ var EditSession = function(text, mode) {
|
|||
}
|
||||
}
|
||||
|
||||
// todo
|
||||
if (this.lineWidgets)
|
||||
screenRows += this.$getWidgetScreenLength();
|
||||
|
||||
return screenRows;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue