added tabs

This commit is contained in:
Mazar Farran 2015-08-26 20:27:21 -07:00
parent 7981c8fdbb
commit f83099492a
2 changed files with 11 additions and 4 deletions

1
line.h
View File

@ -6,6 +6,7 @@
#include <stdlib.h>
#define LINE_SIZE 128 /* Max characters in a line. Expandable */
#define TAB_WIDTH 4
typedef struct
{

14
text.c
View File

@ -46,6 +46,7 @@ int main(int argc, char *argv[])
int beg = 0;
int end = WIN_SIZE;
int y, x; // position on screen
int i;
update_status("Press F4 to quit");
@ -56,6 +57,7 @@ int main(int argc, char *argv[])
char status[NAME_LIMIT + 10];
while(true)
{
print_loc(x, y);
beg = 0 + y_offset;
end = WIN_SIZE + y_offset;
int ch = getch();
@ -81,19 +83,15 @@ int main(int argc, char *argv[])
break;
case KEY_UP:
move_up(&page, &x, &y);
print_loc(x, y);
break;
case KEY_DOWN:
move_down(&page, &x, &y);
print_loc(x, y);
break;
case KEY_LEFT:
move_left(&x, &y);
print_loc(x, y);
break;
case KEY_RIGHT:
move_right(&page, &x, &y);
print_loc(x, y);
break;
case KEY_DC:
case 127: // backspace key...
@ -111,6 +109,14 @@ int main(int argc, char *argv[])
print_page(&page, beg, end);
move(y, x);
break;
case '\t':
for(i = 0; i < TAB_WIDTH; i++)
{
insert_char(&page.text[y + y_offset], ' ', x - 1);
print_page(&page, beg, end);
move_right(&page, &x, &y);
}
break;
case '\n': // newline
insert_line(&page, y + y_offset + 1);
print_page(&page, beg, end);