Skip to content
Browse files

A little refactoring on the display

  • Loading branch information...
1 parent d1fae6f commit 26c85137081b359af6d560eca086f0142f12a70e @rhburrows committed Jul 4, 2011
Showing with 40 additions and 36 deletions.
  1. +40 −36 src/display.js
View
76 src/display.js
@@ -128,58 +128,62 @@
row = 0,
currentLine = 0;
var contents = this.editor.contents();
- this.lineLengths[row] = 0;
var tooLong = false,
cursorPainted = false;
+
+ this.lineLengths[row] = 0;
for (var i=0; i<contents.length; i++) {
var c = contents.charAt(i);
- if (!this.visibleFrame.visible(row)) {
- if (i == this.editor.pointPosition()) {
- this.visibleFrame.scrollTo(row);
- return this.repaint();
- }
+ while (!this.visibleFrame.visible(row)) {
if (c == '\n') {
row++;
this.lineLengths[row] = 0;
}
- } else{
- if (this.faceForPosition(i) != this.currentFace) {
- applyFace(this, this.faceForPosition(i));
+
+ if (this.editor.pointPosition() == i) {
+ this.visibleFrame.scrollTo(row);
+ return this.repaint();
}
+ i++;
+ c = contents.charAt(i);
+ }
+
+ if (this.faceForPosition(i) != this.currentFace) {
+ applyFace(this, this.faceForPosition(i));
+ }
- this.lineLengths[row]++;
+ this.lineLengths[row]++;
- if (i == this.editor.pointPosition()) {
- cursorPainted = true;
- paintCursor(this, col, currentLine);
- }
+ if (i == this.editor.pointPosition()) {
+ cursorPainted = true;
+ paintCursor(this, col, currentLine);
+ }
- if (c == '\n') {
- col = 0;
- row++;
- currentLine++;
- this.lineLengths[row] = 0;
- } else {
- paintCharacter(this, c, col, currentLine);
- col++;
- }
+ if (c == '\n') {
+ col = 0;
+ row++;
+ currentLine++;
+ this.lineLengths[row] = 0;
+ } else {
+ paintCharacter(this, c, col, currentLine);
+ col++;
+ }
- if (!this.visibleFrame.visible(row)) {
- tooLong = true;
- while (!cursorPainted && i < contents.length) {
- i++;
- c = contents.charAt(i);
- if (c == '\n') {
- row++;
- }
- if (i == this.editor.pointPosition()) {
- this.visibleFrame.scrollTo(row);
- return this.repaint();
- }
+ if (!this.visibleFrame.visible(row)) {
+ tooLong = true;
+ while (!cursorPainted && i < contents.length) {
+ i++;
+ c = contents.charAt(i);
+ if (c == '\n') {
+ row++;
+ }
+ if (i == this.editor.pointPosition()) {
+ this.visibleFrame.scrollTo(row);
+ return this.repaint();
}
- break;
}
+ break;
}
}

0 comments on commit 26c8513

Please sign in to comment.
Something went wrong with that request. Please try again.