Added an option to flip lines upwards/downwards.
This commit is contained in:
@@ -35,6 +35,8 @@ If you are planning to use special characters like (á, é, í, ó, ú, ¡, ¿,
|
||||
Ctrl-Q : Exit
|
||||
Ctrl-F : Search text (ESC, arrows and enter to interact once searching)
|
||||
Ctrl-S : Save
|
||||
Ctrl-E : Flip line upwards
|
||||
Ctrl-D : Flip line downwards
|
||||
```
|
||||
|
||||
## Current supported languages
|
||||
|
||||
@@ -865,6 +865,15 @@ void editorFreeRow(editor_row* row) {
|
||||
free(row -> highlight);
|
||||
}
|
||||
|
||||
// -1 down, 1 up
|
||||
void editorFlipRow(int dir) {
|
||||
editor_row c_row = ec.row[ec.cursor_y];
|
||||
ec.row[ec.cursor_y] = ec.row[ec.cursor_y - dir];
|
||||
ec.row[ec.cursor_y - dir] = c_row;
|
||||
ec.cursor_y -= dir;
|
||||
ec.dirty++;
|
||||
}
|
||||
|
||||
void editorDelRow(int at) {
|
||||
if (at < 0 || at >= ec.num_rows)
|
||||
return;
|
||||
@@ -1485,6 +1494,14 @@ void editorProcessKeypress() {
|
||||
case CTRL_KEY('s'):
|
||||
editorSave();
|
||||
break;
|
||||
case CTRL_KEY('e'):
|
||||
if (ec.cursor_y > 0)
|
||||
editorFlipRow(1);
|
||||
break;
|
||||
case CTRL_KEY('d'):
|
||||
if (ec.cursor_y < ec.num_rows - 1)
|
||||
editorFlipRow(-1);
|
||||
break;
|
||||
case ARROW_UP:
|
||||
case ARROW_DOWN:
|
||||
case ARROW_LEFT:
|
||||
@@ -1564,7 +1581,9 @@ void printHelp() {
|
||||
printf("Keybinding\t\tAction\n\n");
|
||||
printf("Ctrl-Q \t\tExit\n");
|
||||
printf("Ctrl-S \t\tSave\n");
|
||||
printf("Ctrl-F \t\tSearch (Esc, enter and arrows to interact once searching)\n");
|
||||
printf("Ctrl-F \t\tSearch. Esc, enter and arrows to interact once searching\n");
|
||||
printf("Ctrl-E \t\tFlip line upwards\n");
|
||||
printf("Ctrl-D \t\tFlip line downwards\n");
|
||||
|
||||
printf("\n\nOPTIONS\n-------\n\n");
|
||||
printf("Option \t\tAction\n\n");
|
||||
@@ -1609,4 +1628,4 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user