Fixed cursor movement
This commit is contained in:
parent
e7ff6f6306
commit
5fe122d53e
1 changed files with 21 additions and 4 deletions
25
main.cpp
25
main.cpp
|
@ -64,16 +64,33 @@ void move_cursor(char ch) {
|
||||||
|
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
case 'h':
|
case 'h':
|
||||||
if(col > 0) move(row, --col);
|
if(col > 0)
|
||||||
|
move(row, --col);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'j':
|
case 'j':
|
||||||
if(row < file.size()-1) move(++row, col);
|
if(row < file.size()-1) {
|
||||||
|
move(++row, col);
|
||||||
|
if(file[row].size() <= col) {
|
||||||
|
col = file[row].size()-1;
|
||||||
|
move(row, col);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'k':
|
case 'k':
|
||||||
if(row > 0) move(--row, col);
|
if(row > 0) {
|
||||||
|
move(--row, col);
|
||||||
|
if(file[row].size() <= col) {
|
||||||
|
col = file[row].size()-1;
|
||||||
|
move(row, col);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
if(col < file[row].size()) move(row, ++col);
|
if(col < file[row].size()-1)
|
||||||
|
move(row, ++col);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue