summaryrefslogtreecommitdiff
path: root/gramscii.c
diff options
context:
space:
mode:
Diffstat (limited to 'gramscii.c')
-rw-r--r--gramscii.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/gramscii.c b/gramscii.c
index 0d94d4a..ade73ee 100644
--- a/gramscii.c
+++ b/gramscii.c
@@ -146,9 +146,11 @@ char* state_str(){
void status_bar(){
printf("\033[%d;1f\033[7m", HEIGHT+1);
+ printf("%100s", " ");
+ printf("\033[%d;1f\033[7m", HEIGHT+1);
printf(" x: %3d y: %3d -- mode: %4s hl: %c vl: %c cn: %c <: %c >: %c %10s",
x, y, state_str(), line_h, line_v, corner, mark_st, mark_end, "");
-
+ printf(" [%s]", fname );
printf("\033[0m");
}
@@ -302,8 +304,10 @@ void get_box(){
status_bar();
show_cursor();
}
- if (c == 'b')
+ if (c == 'b'){
draw_box(orig_x, orig_y, FIX);
+ modified = 1;
+ }
redraw();
state = MOVE;
}
@@ -392,8 +396,10 @@ void get_arrow(){
status_bar();
show_cursor();
}
- if (c == 'a')
+ if (c == 'a'){
draw_arrow(orig_x, orig_y, arrow, arrow_len, FIX);
+ modified = 1;
+ }
redraw();
state = MOVE;
}
@@ -435,7 +441,7 @@ void write_file(){
if (!fname[0] || force_new){
get_string(fname, 255);
if (f=fopen(fname, "r")){
- if (!is_yes(get_key("File exists. Overwrite [y/N]?")) ){
+ if (!is_yes(get_key("File exists. Overwrite [y/n]?")) ){
fclose(f);
return;
}
@@ -450,6 +456,7 @@ void write_file(){
fprintf(f, "%s\n", screen[i]);
}
fclose(f);
+ modified = 0;
get_key("File saved.");
}
@@ -533,6 +540,7 @@ void delete(){
check_bound();
step = 1;
do_delete(orig_x, orig_y);
+ modified = 1;
orig_x = x;
orig_y = y;
redraw();
@@ -542,6 +550,17 @@ void delete(){
state = MOVE;
}
+void check_modified(){
+
+ if (modified){
+ if (!is_yes(get_key("Unsaved changes. Write to file [y/n]?")) ){
+ return;
+ }
+ write_file(0);
+ }
+}
+
+
void commands(){
@@ -617,8 +636,9 @@ void commands(){
case '>':
toggle_end_mark();
break;
- case 'Q':
case 'q':
+ check_modified();
+ case 'Q':
cleanup(0);
exit(0);
break;