fixed tabs, cleaned up a bit
This commit is contained in:
parent
a5e23c3a1d
commit
99b2eac924
1
line.h
1
line.h
@ -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
2
page.h
@ -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 */
|
||||
|
||||
|
27
text.c
27
text.c
@ -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]);
|
||||
add_char(currline, ch);
|
||||
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++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user