fixed tabs, cleaned up a bit

This commit is contained in:
Mazar Farran 2015-08-28 21:15:50 -07:00
parent a5e23c3a1d
commit 99b2eac924
3 changed files with 14 additions and 16 deletions

1
line.h
View File

@ -11,7 +11,6 @@
typedef struct
{
char *line;
int tabs; // keeps track of tabs so we can offset
int size; // size of array, not string
} LINE;

2
page.h
View File

@ -5,7 +5,7 @@
#include <ncurses.h> // might have to move this
#include "line.h"
#define PAGE_SIZE 500 /* Max number of lines. Currently not expandable. */
#define PAGE_SIZE 500 /* Default number of lines */
#define WIN_SIZE (LINES - 2) /* Size of window, making room for bottom prompt */
#define NAME_LIMIT 256 /* Max size of a unix filename + 1 */

25
text.c
View File

@ -226,25 +226,24 @@ void load_file(int argc, char **argv, PAGE *p)
int line;//, col;
init_page(p, argv[1], size);
/*for(line = 0; line < PAGE_SIZE && ch != EOF; line++)
{
for(col = 0;
col < LINE_SIZE - 1 && ((ch = fgetc(fp)) != '\n') && ch != EOF;
col++)
{
p->text[line].line[col] = ch;
}
p->text[line].line[col] = '\0';
p->numlines++;
}*/
for(line = 0; line < PAGE_SIZE && ch != EOF; line++)
for(line = 0; line < size && ch != EOF; line++)
{
ch = fgetc(fp);
while(ch != '\n' && ch != EOF)
{
LINE *currline = &(p->text[line]);
if(ch != '\t')
{
add_char(currline, ch);
}
else // tab. add 4 spaces instead
{
int i;
for(i = 0; i < TAB_WIDTH; i++)
{
add_char(currline, ' ');
}
}
ch = fgetc(fp);
}
p->numlines++;