ref: b9ac29a8e5985f63ec1f20e1fe2b3bc027c02fb9
parent: 75db9e5e065040075706b9a6c102b04d1b43d130
author: glenda <glenda@krsna>
date: Sat Aug 16 22:20:29 EDT 2025
fixed-some-bugs
--- a/fc.c
+++ b/fc.c
@@ -200,7 +200,6 @@
void eval_text(Box*);
void eval_number(Box*);
void eval_formula(Box*);
-void draw_box_generic(Box*, Image*);
void recalc_all(void);
void handle_normal_mode(int key);
void handle_cell_edit(int key);
@@ -210,10 +209,16 @@
void handle_edit_mouse(Mouse m);
void handle_label_mouse(Mouse m);
void handle_filename_mouse(Mouse m);
+void draw_box_generic(Box*, Image*);
void draw_normal_overlay(void);
void draw_cell_edit_overlay(void);
void draw_label_edit_overlay(void);
void draw_filename_overlay(void);
+void draw_background(void);
+void draw_grid_lines(void);
+void draw_all_boxes(void);
+void draw_emoji_banner(void);
+void draw_status_line(void);
void cmd_quit(void);
void cmd_save(void);
void cmd_save_as(void);
@@ -223,17 +228,13 @@
void cmd_toggle_grid(void);
void cmd_delete_box(void);
void cmd_cycle_emoji(void);
+void cmd_toggle_emoji(void);
void ctl_addbox(char**, int);
void ctl_load(char**, int);
void ctl_save(char**, int);
void ctl_quit(char**, int);
-void draw_background(void);
-void draw_grid_lines(void);
-void draw_all_boxes(void);
-void draw_status_line(void);
void init_emoji(void);
-void draw_emoji_banner(void);
-void cmd_toggle_emoji(void);
+void initcolors(void);
int cistrcmp(char *s1, char *s2);
int tokenize_formula(char *formula, Token *tokens, int maxtokens);
int cellref_lookup(char *ref);
@@ -290,7 +291,7 @@
};
InputMode input_modes[] = {
- [0] = {"normal", handle_normal_mode, handle_normal_mouse, draw_normal_overlay, "S:save O:open L:label G:grid"},
+ [0] = {"normal", handle_normal_mode, handle_normal_mouse, draw_normal_overlay, "E:moji-off S:ave O:pen l:abel g:rid e:next-emoji"},
[1] = {"edit", handle_cell_edit, handle_edit_mouse, draw_cell_edit_overlay, "Enter:save Esc:cancel"},
[2] = {"label", handle_label_edit, handle_label_mouse, draw_label_edit_overlay,"Enter:save Esc:cancel"},
[3] = {"filename", handle_filename_input, handle_filename_mouse, draw_filename_overlay, "Tab:.spr ` Enter:confirm `Esc:cancel"},
@@ -1828,8 +1829,16 @@
return;
}
- sheet.nboxes = 0;
-
+ memset(&sheet, 0, sizeof(sheet));
+ sheet.selected = -1;
+ sheet.editing = -1;
+ sheet.editing_label = -1;
+ sheet.entering_filename = 0;
+ sheet.current_mode = 0;
+ sheet.gridsize = 32;
+ sheet.gridsnap = 1;
+ init_emoji();
+
while((line = Brdline(b, '\n')) != nil){
line[Blinelen(b)-1] = '\0';
@@ -1840,8 +1849,12 @@
if(nf >= 2 && strcmp(fields[0], "box") == 0){
- if(sheet.nboxes < MAXBOXES)
+ if(sheet.nboxes < MAXBOXES){
+ Box *box = &sheet.boxes[sheet.nboxes];
+ memset(box, 0, sizeof(Box));
+ box->r = Rect(0, 0, BOXWIDTH, BOXHEIGHT);
sheet.nboxes++;
+ }
} else if(nf >= 3 && strcmp(fields[0], "pos") == 0){
Box *box = &sheet.boxes[sheet.nboxes-1];
box->pos.x = atoi(fields[1]);
@@ -1876,6 +1889,7 @@
if (bt->eval) bt->eval(box);
}
}
+ recalc_all();
redraw();
}
@@ -1905,8 +1919,8 @@
sheet.needredraw = 1;
} else if(key == '\t') {
/* Tab completion */
- if(!strstr(sheet.filenamebuf, ".spr")) {
- strcat(sheet.filenamebuf, ".spr");
+ if(!strstr(sheet.filenamebuf, "/tmp/")) {
+ strcat(sheet.filenamebuf, "/tmp/");
sheet.filenamepos = strlen(sheet.filenamebuf);
sheet.needredraw = 1;
}
--
⑨