aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornytpu <alex@nytpu.com>2021-06-04 16:30:54 -0600
committernytpu <alex@nytpu.com>2021-06-04 16:30:54 -0600
commit0f52010d006615597d65c6b47d518c31d26a82ad (patch)
tree9e2077351edd5748ba6d33d68008d3b79c11327d
parentfix unfreed memory on q/Q command (diff)
downloaded-0f52010d006615597d65c6b47d518c31d26a82ad.tar.bz2
ed-0f52010d006615597d65c6b47d518c31d26a82ad.zip
basic implementations of most commands
-rw-r--r--main.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/main.c b/main.c
index 9a99913..4d690c5 100644
--- a/main.c
+++ b/main.c
@@ -104,9 +104,38 @@ main(int argc, char *argv[])
case 'a':
insert_mode(cmd.end+1);
break;
+ case 'c':
+ if (cmd.start == 0) cmd.start = 1;
+ if (cmd.end == 0) cmd.end = 1;
+ delete_rows(cmd.start, cmd.end);
+ insert_mode(cmd.start);
+ break;
+ case 'd':
+ delete_rows(cmd.start, cmd.end);
+ break;
+ case 'h':
+ fprintf(stderr, "%s\n", E.last_err);
+ break;
+ case 'H':
+ E.verbose = !E.verbose;
+ if (E.verbose) fprintf(stderr, "%s\n", E.last_err);
+ break;
+ case 'i':
+ if (cmd.end == 0) cmd.end = 1;
+ insert_mode(cmd.end);
+ break;
+ case 'l':
+ print_rows_escaped(cmd.start, cmd.end);
+ break;
case 'n':
print_rows_numbered(cmd.start, cmd.end);
break;
+ case 'p':
+ print_rows(cmd.start, cmd.end);
+ break;
+ case 'P':
+ E.prompt_enabled = !E.prompt_enabled;
+ break;
case 'q':
if (E.dirty) {
error("Buffer modified");
@@ -116,6 +145,12 @@ main(int argc, char *argv[])
case 'Q':
free(line);
goto quit;
+ case '=':
+ printf("%ld\n", cmd.end);
+ break;
+ case '\0':
+ print_rows(cmd.end, cmd.end);
+ break;
default:
error("Unknown command");
break;