Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove line wrapping and fix click handling

The click events were having trouble registering clicks on lines if
they were past the last character. Fix this and remove line wrapping
(for now) to make things simpler
  • Loading branch information...
commit bfb1c620982e6831faecc382d929ea42874ab99e 1 parent a57c44b
@rhburrows authored
Showing with 7 additions and 21 deletions.
  1. +7 −21 src/display.js
View
28 src/display.js
@@ -21,7 +21,6 @@
this.faces = [];
this.defaultFace = defaultFace();
applyFace(this, this.defaultFace);
- // Used for line wrapping. Messy? Yes
this.lineLengths = [];
}
@@ -37,12 +36,17 @@
function clickToPosition(display, x, y) {
var line = yToLine(display, y);
- var position = 0, i = 0;
+ var position = 0,
+ i = 0;
while (i < line - 1) {
position += display.lineLengths[i];
- line = line - Math.ceil(display.lineLengths[i] / display.lineLength);
+ i++;
}
var col = xToCol(display, x);
+
+ if (col > display.lineLengths[line-1]) {
+ col = display.lineLengths[line-1];
+ }
return position + (col - 1);
}
@@ -73,17 +77,6 @@
applyFace(display, face);
}
- function paintLineWrappingMarker(display, col, row) {
- var pixelX = columnToX(display, col);
- var pixelY = rowToY(display, row);
- var face = display.currentFace;
-
- display.context.fillStyle = 'gray';
- display.context.fillRect(pixelX, pixelY - (display.lineHeight / 2), 5, 5);
-
- applyFace(display, face);
- }
-
function applyFace(display, face) {
display.context.fillStyle = face.color;
display.charWidth = face.size * 0.8;
@@ -132,13 +125,6 @@
paintCharacter(this, c, col, row);
col++;
currentLineCount++;
-
- if (currentLineCount == this.lineLength) {
- paintLineWrappingMarker(this, col, row);
- col = 0;
- row++;
- currentLineCount = 0;
- }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.