summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/main.c b/main.c
index aeeb680..e0b60ff 100644
--- a/main.c
+++ b/main.c
@@ -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;
}
}
}