Old bug fixes that I never commited.
Also added a .gitignore and modified the readme.
This commit is contained in:
parent
00cd082403
commit
fe910b6e31
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
*.out
|
||||||
|
*.o
|
||||||
|
*.txt
|
||||||
|
text
|
18
README.md
18
README.md
@ -2,7 +2,23 @@ Text Editor
|
|||||||
===========
|
===========
|
||||||
|
|
||||||
I learned ncurses and figured why not.
|
I learned ncurses and figured why not.
|
||||||
Posting this now (9/30) because school is starting
|
Posting this now (9/30/15) because school is starting
|
||||||
so I don't plan on working on it anymore.
|
so I don't plan on working on it anymore.
|
||||||
|
|
||||||
Probably the most well-developed program I made this summer.
|
Probably the most well-developed program I made this summer.
|
||||||
|
|
||||||
|
How to use:
|
||||||
|
|
||||||
|
F4 quits (no prompt)
|
||||||
|
F5 saves the current file as save.txt
|
||||||
|
|
||||||
|
Current issues:
|
||||||
|
|
||||||
|
x-y coordinates in ncurses correspond to rows and columns in
|
||||||
|
the text document. This means tabs are an issue and text
|
||||||
|
wrapping is impossible. Solution: separate screen logic
|
||||||
|
from document logic.
|
||||||
|
|
||||||
|
Can only save files under the name save.txt. Solution: create
|
||||||
|
a prompt window (from scratch...) that retuns a string to the
|
||||||
|
caller.
|
||||||
|
15
makefile
15
makefile
@ -2,17 +2,20 @@
|
|||||||
|
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=-Wall -g
|
CFLAGS=-Wall -g
|
||||||
OBJS=line.o page.o
|
OBJS=text.o page.o line.o
|
||||||
LIBS=-lncurses
|
LIBS=-lncurses
|
||||||
|
|
||||||
text: text.c text.h $(OBJS)
|
text: $(OBJS)
|
||||||
$(CC) $(CFLAGS) -o text text.c $(OBJS) $(LIBS)
|
$(CC) $(CFLAGS) -o text $(OBJS) $(LIBS)
|
||||||
|
|
||||||
line.o: line.c line.h
|
text.o: text.c text.h page.h line.h
|
||||||
$(CC) $(CFLAGS) -c line.c
|
$(CC) $(CFLAGS) -c text.c
|
||||||
|
|
||||||
page.o: page.c page.h line.h
|
page.o: page.c page.h line.h
|
||||||
$(CC) $(CFLAGS) -c page.c
|
$(CC) $(CFLAGS) -c page.c
|
||||||
|
|
||||||
|
line.o: line.c line.h
|
||||||
|
$(CC) $(CFLAGS) -c line.c
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJS) text
|
rm -f $(OBJS) text
|
||||||
|
6
page.c
6
page.c
@ -85,6 +85,12 @@ void print_page(const PAGE *p, int start, int end)
|
|||||||
clrtoeol();
|
clrtoeol();
|
||||||
printw(" %s", p->text[i].line);
|
printw(" %s", p->text[i].line);
|
||||||
}
|
}
|
||||||
|
if(start < end)
|
||||||
|
{
|
||||||
|
move(line, 0);
|
||||||
|
clrtoeol(); // if we deleted a line this may be necessary
|
||||||
|
move(line-1, 1);
|
||||||
|
}
|
||||||
refresh();
|
refresh();
|
||||||
} // print_page
|
} // print_page
|
||||||
|
|
||||||
|
13
text.c
13
text.c
@ -9,6 +9,7 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
int y_offset = 0; // TODO: move to local scope
|
int y_offset = 0; // TODO: move to local scope
|
||||||
|
int tab_offset = 0;
|
||||||
|
|
||||||
#define DEBUG
|
#define DEBUG
|
||||||
|
|
||||||
@ -143,7 +144,14 @@ void move_left(int *x, int *y)
|
|||||||
|
|
||||||
void move_right(PAGE *p, int *x, int *y)
|
void move_right(PAGE *p, int *x, int *y)
|
||||||
{
|
{
|
||||||
if(*x <= strlen(p->text[*y + y_offset].line)) move(*y, ++(*x));
|
if(*x <= strlen(p->text[*y + y_offset].line))
|
||||||
|
{
|
||||||
|
if(p->text[*y + y_offset].line[*x + tab_offset] == '\t') {
|
||||||
|
move(*y, ++(*x));
|
||||||
|
} else {
|
||||||
|
move(*y, ++(*x));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void move_up(PAGE *p, int *x, int *y)
|
void move_up(PAGE *p, int *x, int *y)
|
||||||
@ -187,7 +195,8 @@ int count_lines(int argc, char **argv)
|
|||||||
while((ch = fgetc(fp)) != EOF)
|
while((ch = fgetc(fp)) != EOF)
|
||||||
if( ch == '\n' )
|
if( ch == '\n' )
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
return count;
|
return count;
|
||||||
} // count_lines
|
} // count_lines
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user