print command now accepts start + end lines
parent
b7a4fec162
commit
03d19d3169
6
buffer.c
6
buffer.c
|
@ -24,4 +24,10 @@ b_truncate(Row *row) {
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
b_countlines(Row *row) {
|
||||
int lines = 1;
|
||||
for(; row->n != NULL; row = row->n) lines++;
|
||||
return lines;
|
||||
}
|
||||
|
||||
|
|
19
c_print.c
19
c_print.c
|
@ -7,6 +7,7 @@ else printf("%c", row->text[i]);
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void
|
||||
c_print(char *c, char **argv) {
|
||||
Row *row = buffer;
|
||||
|
@ -22,6 +23,24 @@ c_print(char *c, char **argv) {
|
|||
row = row -> n;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void
|
||||
c_print(char *c, char **argv) {
|
||||
int start = argv[1] != NULL ? atoi(argv[1]) : 1;
|
||||
int end = argv[2] != NULL ? atoi(argv[2]) : b_countlines(buffer);
|
||||
start = start > 1 ? start : 1;
|
||||
end = end < b_countlines(buffer) ? end : b_countlines(buffer);
|
||||
Row *row = b_getline(buffer, start);
|
||||
for(int line = start; line <= end; line++) {
|
||||
printf("%3.i| ", line);
|
||||
print_with_fixed_tabs(row);
|
||||
puts("");
|
||||
row = row->n;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue