Skip to content
Snippets Groups Projects
Commit 2e5f3a92 authored by Silas Dohm's avatar Silas Dohm
Browse files

renamed mode

parent 4b08af41
Branches
No related tags found
No related merge requests found
......@@ -91,7 +91,7 @@ class Word {
e.draw(color, "#bf060b");
});
}
//highlight
//red rectangle
ctx.strokeStyle = "#bf060b";
if (this.direction == activeDir) {
this.li.style.borderColor = "#bf060b";
......
......@@ -3,11 +3,11 @@ let canv = document.getElementById("mycanvas");
let ctx = canv.getContext("2d");
let statusBar = document.getElementById("status");
const mode = {
visual: 0,
normal: 0,
insert: 1,
replace: 2
};
let activeMode = mode.visual;
let activeMode = mode.normal;
let activeDir = 0; //0 = horizontal 1=vertical
let activeCell, lastCell;
let size = 80;
......@@ -25,7 +25,7 @@ function logKey(e) {
switch (activeMode) {
case mode.insert:
if (e.key == "Escape")
activeMode = mode.visual;
activeMode = mode.normal;
else if (e.key == "Backspace") {
activeCell.currentChar = "";
if (activeDir && activeCell.word[activeDir] == activeCell.neighbour[1].word[activeDir]) {
......@@ -41,25 +41,25 @@ function logKey(e) {
if (activeCell.word[1] == activeCell.neighbour[3].word[1] && activeCell != activeCell.neighbour[3])
activeCell = activeCell.neighbour[3];
else
activeMode = mode.visual;
activeMode = mode.normal;
}
else { //across
if (activeCell.word[0] == activeCell.neighbour[2].word[0] && activeCell != activeCell.neighbour[2])
activeCell = activeCell.neighbour[2];
else
activeMode = mode.visual;
activeMode = mode.normal;
}
}
break;
case mode.replace:
if (e.key == "Escape")
activeMode = mode.visual;
activeMode = mode.normal;
else if (e.keyCode > 64 && e.keyCode < 91) {
activeCell.currentChar = e.key;
activeMode = mode.visual;
activeMode = mode.normal;
}
break;
case mode.visual:
case mode.normal:
switch (e.key) {
case "ArrowDown":
case "j"://down
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment