diff options
author | KatolaZ <[email protected]> | 2018-04-20 18:23:24 +0100 |
---|---|---|
committer | KatolaZ <[email protected]> | 2018-04-20 18:23:24 +0100 |
commit | b10f9522863c937c08d41e2d6da48174cdb3906a (patch) | |
tree | 96afc00c5ac6918767302b67829584fcf84bde2c /main.c | |
parent | 99c9a9e20f80f5d04dfddaf19e18d1179c65c91e (diff) |
Implemented 'c' command
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 42 |
1 files changed, 28 insertions, 14 deletions
@@ -4,12 +4,14 @@ #include "buff.h" #include <ctype.h> + + line_t *b_start = NULL; line_t *b_end = NULL; line_t *cur = NULL; unsigned int num = 0; unsigned int pos = 0; -/* addr1 is the lasr address, while addr2 is the previous one */ +/* addr1 is the last address, while addr2 is the previous one */ int addr1, addr2; @@ -117,28 +119,40 @@ void main_loop(){ } switch(cmd[0]){ - case 'i': - if (addr1 > -1) - move_to_line(addr1, 0); - insert_lines(); - break; case 'a': if (addr1 > -1) move_to_line(addr1, 0); append_lines(); break; + case 'c': + if (addr1 > -1) + move_to_line(addr1,0); + delete_lines(); + addr1 = addr2 = pos; + append_lines(); case 'd': + if (ret == -1){ + E; + break; + } + if (ret == 2){ + CHECKADDR; + } + if (ret == 1) + addr2 = addr1; delete_lines(); break; + case 'i': + if (addr1 > -1) + move_to_line(addr1, 0); + insert_lines(); + break; case 'n': p = 1; case 'p': - if (ret == 2) - if (addr1 < addr2){ - printf("?\n"); - break; - } - else - print_lines(p); + if (ret == 2){ + CHECKADDR; + print_lines(p); + } else if (ret == 1) move_to_line(addr2, 1); else if (ret == 0) @@ -166,7 +180,7 @@ void main_loop(){ break; default: fprintf(stderr, ">>> **** unknown command: '%c'****\n", cmd[0]); - printf("?\n"); + E; } } } |