diff options
-rw-r--r-- | src/colloquium.c | 6 | ||||
-rw-r--r-- | src/colloquium.h | 1 | ||||
-rw-r--r-- | src/debugger.c | 3 | ||||
-rw-r--r-- | src/frame.c | 72 | ||||
-rw-r--r-- | src/frame.h | 13 | ||||
-rw-r--r-- | src/sc_editor.c | 20 | ||||
-rw-r--r-- | src/sc_editor.h | 4 | ||||
-rw-r--r-- | src/sc_interp.c | 70 | ||||
-rw-r--r-- | src/sc_interp.h | 15 | ||||
-rw-r--r-- | src/sc_parse.c | 92 | ||||
-rw-r--r-- | src/sc_parse.h | 7 | ||||
-rw-r--r-- | src/slide_window.c | 2 | ||||
-rw-r--r-- | src/slide_window.h | 1 | ||||
-rw-r--r-- | src/utils.c | 88 | ||||
-rw-r--r-- | src/utils.h | 1 |
15 files changed, 29 insertions, 366 deletions
diff --git a/src/colloquium.c b/src/colloquium.c index 66e3dcb..a8da4d9 100644 --- a/src/colloquium.c +++ b/src/colloquium.c @@ -320,12 +320,6 @@ int colloquium_get_hidepointer(Colloquium *app) } -GtkBuilder *colloquium_get_uibuilder(Colloquium *app) -{ - return app->builder; -} - - static void colloquium_startup(GApplication *papp) { Colloquium *app = COLLOQUIUM(papp); diff --git a/src/colloquium.h b/src/colloquium.h index 4c8133f..89f600f 100644 --- a/src/colloquium.h +++ b/src/colloquium.h @@ -38,7 +38,6 @@ typedef struct _colloquium Colloquium; extern const char *colloquium_get_imagestore(Colloquium *app); extern int colloquium_get_hidepointer(Colloquium *app); -extern GtkBuilder *colloquium_get_uibuilder(Colloquium *app); extern void open_about_dialog(GtkWidget *parent); diff --git a/src/debugger.c b/src/debugger.c index c8cab67..12ef9d8 100644 --- a/src/debugger.c +++ b/src/debugger.c @@ -118,7 +118,8 @@ static void debug_text_para(Paragraph *para, cairo_t *cr, double *ypos, } } - snprintf(tmp, 255, "Newline at end: %p", get_newline_at_end(para)); + snprintf(tmp, 255, "Newline at end: %p", + para_debug_get_newline_at_end(para)); plot_text(cr, ypos, fontdesc, tmp); } diff --git a/src/frame.c b/src/frame.c index 2f6d16b..2926d4e 100644 --- a/src/frame.c +++ b/src/frame.c @@ -184,7 +184,7 @@ struct frame *add_subframe(struct frame *fr) } -void show_hierarchy(struct frame *fr, const char *t) +void show_frame_hierarchy(struct frame *fr, const char *t) { int i; char tn[1024]; @@ -195,65 +195,12 @@ void show_hierarchy(struct frame *fr, const char *t) printf(_("%s%p (%.2f x %.2f)\n"), t, fr, fr->w, fr->h); for ( i=0; i<fr->num_children; i++ ) { - show_hierarchy(fr->children[i], tn); + show_frame_hierarchy(fr->children[i], tn); } } -static struct frame *find_parent(struct frame *fr, struct frame *search) -{ - int i; - - for ( i=0; i<fr->num_children; i++ ) { - if ( fr->children[i] == search ) { - return fr; - } - } - - for ( i=0; i<fr->num_children; i++ ) { - struct frame *tt; - tt = find_parent(fr->children[i], search); - if ( tt != NULL ) return tt; - } - - return NULL; -} - - -void delete_subframe(struct frame *top, struct frame *fr) -{ - struct frame *parent; - int i, idx, found; - - parent = find_parent(top, fr); - if ( parent == NULL ) { - fprintf(stderr, _("Couldn't find parent when deleting frame.\n")); - return; - } - - found = 0; - for ( i=0; i<parent->num_children; i++ ) { - if ( parent->children[i] == fr ) { - idx = i; - found = 1; - break; - } - } - - if ( !found ) { - fprintf(stderr, _("Couldn't find child when deleting frame.\n")); - return; - } - - for ( i=idx; i<parent->num_children-1; i++ ) { - parent->children[i] = parent->children[i+1]; - } - - parent->num_children--; -} - - struct frame *find_frame_with_scblocks(struct frame *fr, SCBlock *scblocks) { int i; @@ -382,12 +329,18 @@ void wrap_paragraph(Paragraph *para, PangoContext *pc, double w, para->height = pango_units_to_double(rect.height); } -SCBlock *get_newline_at_end(Paragraph *para) +static SCBlock *get_newline_at_end(Paragraph *para) { return para->newline_at_end; } +SCBlock *para_debug_get_newline_at_end(Paragraph *para) +{ + return get_newline_at_end(para); +} + + void set_newline_at_end(Paragraph *para, SCBlock *bl) { para->newline_at_end = bl; @@ -655,7 +608,7 @@ void render_paragraph(cairo_t *cr, Paragraph *para, ImageStore *is) } -size_t end_offset_of_para(struct frame *fr, int pn) +static size_t end_offset_of_para(struct frame *fr, int pn) { int i; size_t total = 0; @@ -894,11 +847,6 @@ void cursor_moveh(struct frame *fr, struct edit_pos *cp, signed int dir) } -void cursor_movev(struct frame *fr, struct edit_pos *cp, signed int dir) -{ -} - - void check_callback_click(struct frame *fr, int para) { Paragraph *p = fr->paras[para]; diff --git a/src/frame.h b/src/frame.h index f6a02b6..b786065 100644 --- a/src/frame.h +++ b/src/frame.h @@ -115,8 +115,6 @@ struct frame extern struct frame *frame_new(void); extern void frame_free(struct frame *fr); extern struct frame *add_subframe(struct frame *fr); -extern void show_hierarchy(struct frame *fr, const char *t); -extern void delete_subframe(struct frame *top, struct frame *fr); extern struct frame *find_frame_with_scblocks(struct frame *top, SCBlock *scblocks); @@ -130,9 +128,7 @@ extern void set_para_alignment(Paragraph *para, PangoAlignment align); extern double paragraph_height(Paragraph *para); extern void render_paragraph(cairo_t *cr, Paragraph *para, ImageStore *is); -extern SCBlock *get_newline_at_end(Paragraph *para); extern void set_newline_at_end(Paragraph *para, SCBlock *bl); -extern void check_run(struct frame *fr, int pn); extern void show_edit_pos(struct edit_pos a); extern void add_run(Paragraph *para, SCBlock *scblock, @@ -153,8 +149,6 @@ extern void add_image_para(struct frame *fr, SCBlock *scblock, extern void wrap_paragraph(Paragraph *para, PangoContext *pc, double w, size_t sel_start, size_t sel_end); -extern size_t end_offset_of_para(struct frame *fr, int pn); - extern int find_cursor(struct frame *fr, double x, double y, struct edit_pos *pos); @@ -174,8 +168,6 @@ extern int get_cursor_pos(struct frame *fr, int cursor_para, int cursor_pos, extern void cursor_moveh(struct frame *fr, struct edit_pos *cp, signed int dir); -extern void cursor_movev(struct frame *fr, struct edit_pos *cp, signed int dir); - extern void check_callback_click(struct frame *fr, int para); extern size_t pos_trail_to_offset(Paragraph *para, size_t offs, int trail); @@ -186,12 +178,12 @@ extern void insert_text_in_paragraph(Paragraph *para, size_t offs, extern void delete_text_from_frame(struct frame *fr, struct edit_pos p1, struct edit_pos p2, double wrap_w); -extern size_t delete_text_in_paragraph(struct frame *fr, int npara, size_t offs0, ssize_t offs2); - extern SCBlock *split_paragraph(struct frame *fr, int pn, size_t pos, PangoContext *pc); extern SCBlock *block_at_cursor(struct frame *fr, int para, size_t pos); +extern void show_frame_hierarchy(struct frame *fr, const char *t); + extern int get_sc_pos(struct frame *fr, int pn, size_t pos, SCBlock **bl, size_t *ppos); @@ -202,6 +194,7 @@ extern Paragraph *create_paragraph(struct frame *fr, SCBlock *bl); extern enum para_type para_type(Paragraph *para); extern SCBlock *para_scblock(Paragraph *para); +extern SCBlock *para_debug_get_newline_at_end(Paragraph *para); extern int para_debug_num_runs(Paragraph *para); extern int para_debug_run_info(Paragraph *para, int i, SCBlock **scblock); diff --git a/src/sc_editor.c b/src/sc_editor.c index 0bf2dc2..e95beb4 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -384,7 +384,7 @@ void sc_editor_ensure_cursor(SCEditor *e) } -void sc_editor_remove_cursor(SCEditor *e) +static void sc_editor_remove_cursor(SCEditor *e) { e->cursor_frame = NULL; e->cpos.para = 0; @@ -1979,30 +1979,12 @@ void sc_editor_set_scblock(SCEditor *e, SCBlock *scblocks) } -SCBlock *sc_editor_get_scblock(SCEditor *e) -{ - return e->scblocks; -} - - static void update_size_request(SCEditor *e) { gtk_widget_set_size_request(GTK_WIDGET(e), 0, e->h + 2.0*e->min_border); } -void sc_editor_set_size(SCEditor *e, int w, int h) -{ - e->w = w; - e->h = h; - update_size_request(e); - if ( gtk_widget_get_mapped(GTK_WIDGET(e)) ) { - full_rerender(e); - sc_editor_redraw(e); - } -} - - void sc_editor_set_logical_size(SCEditor *e, double w, double h) { e->log_w = w; diff --git a/src/sc_editor.h b/src/sc_editor.h index 35557d4..d3c111b 100644 --- a/src/sc_editor.h +++ b/src/sc_editor.h @@ -170,11 +170,8 @@ typedef struct _sceditorclass SCEditorClass; extern void sc_editor_set_scblock(SCEditor *e, SCBlock *scblocks); extern void sc_editor_set_stylesheet(SCEditor *e, Stylesheet *stylesheet); -extern SCBlock *sc_editor_get_scblock(SCEditor *e); -extern GtkWidget *sc_editor_get_widget(SCEditor *e); extern SCEditor *sc_editor_new(SCBlock *scblocks, Stylesheet *stylesheet, PangoLanguage *lang, const char *storename); -extern void sc_editor_set_size(SCEditor *e, int w, int h); extern void sc_editor_set_logical_size(SCEditor *e, double w, double h); extern void sc_editor_set_flow(SCEditor *e, int flow); extern void sc_editor_set_scale(SCEditor *e, int scale); @@ -189,7 +186,6 @@ extern void sc_editor_paste(SCEditor *e); extern void sc_editor_add_storycode(SCEditor *e, const char *sc); extern void sc_editor_copy_selected_frame(SCEditor *e); extern void sc_editor_delete_selected_frame(SCEditor *e); -extern void sc_editor_remove_cursor(SCEditor *e); extern void sc_editor_ensure_cursor(SCEditor *e); extern SCBlock *split_paragraph_at_cursor(SCEditor *e); diff --git a/src/sc_interp.c b/src/sc_interp.c index 05e9325..780663f 100644 --- a/src/sc_interp.c +++ b/src/sc_interp.c @@ -86,6 +86,17 @@ struct _sccallbacklist }; +static int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl, Stylesheet *ss) +{ + while ( bl != NULL ) { + if ( sc_interp_add_block(scin, bl, ss) ) return 1; + bl = sc_block_next(bl); + } + + return 0; +} + + SCCallbackList *sc_callback_list_new() { SCCallbackList *cbl; @@ -255,41 +266,6 @@ double *sc_interp_get_fgcol(SCInterpreter *scin) } -double *sc_interp_get_bgcol(SCInterpreter *scin) -{ - struct sc_state *st = &scin->state[scin->j]; - return st->bgcol; -} - - -double *sc_interp_get_bgcol2(SCInterpreter *scin) -{ - struct sc_state *st = &scin->state[scin->j]; - return st->bgcol2; -} - - -GradientType sc_interp_get_bggrad(SCInterpreter *scin) -{ - struct sc_state *st = &scin->state[scin->j]; - return st->bggrad; -} - - -int sc_interp_get_ascent(SCInterpreter *scin) -{ - struct sc_state *st = &scin->state[scin->j]; - return st->ascent; -} - - -int sc_interp_get_height(SCInterpreter *scin) -{ - struct sc_state *st = &scin->state[scin->j]; - return st->height; -} - - static void set_frame_default_style(struct frame *fr, SCInterpreter *scin) { if ( fr == NULL ) return; @@ -686,19 +662,6 @@ static void set_paraspace(SCInterpreter *scin, const char *opts) } -static void set_slide_size(SCInterpreter *scin, const char *opts) -{ - float p[2]; - struct sc_state *st = &scin->state[scin->j]; - - if ( parse_double(opts, p) ) return; - - st->slide_width = p[0]; - st->slide_height = p[1]; - st->have_size = 1; -} - - void update_geom(struct frame *fr) { char geom[256]; @@ -1233,14 +1196,3 @@ int sc_interp_add_block(SCInterpreter *scin, SCBlock *bl, Stylesheet *ss) return 0; } - -int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl, Stylesheet *ss) -{ - while ( bl != NULL ) { - if ( sc_interp_add_block(scin, bl, ss) ) return 1; - bl = sc_block_next(bl); - } - - return 0; -} - diff --git a/src/sc_interp.h b/src/sc_interp.h index 7593226..418d6a6 100644 --- a/src/sc_interp.h +++ b/src/sc_interp.h @@ -50,14 +50,8 @@ extern void sc_interp_destroy(SCInterpreter *scin); extern void sc_interp_save(SCInterpreter *scin); extern void sc_interp_restore(SCInterpreter *scin); -extern int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl, Stylesheet *ss); extern int sc_interp_add_block(SCInterpreter *scin, SCBlock *bl, Stylesheet *ss); -extern void sc_interp_run_stylesheet(SCInterpreter *scin, SCBlock *bl); -extern void sc_interp_run_style(SCInterpreter *scin, const char *sname); -extern void add_macro(SCInterpreter *scin, const char *mname, - const char *contents); - /* Callback lists */ extern SCCallbackList *sc_callback_list_new(); @@ -74,15 +68,6 @@ extern struct frame *sc_interp_get_frame(SCInterpreter *scin); extern PangoFont *sc_interp_get_font(SCInterpreter *scin); extern PangoFontDescription *sc_interp_get_fontdesc(SCInterpreter *scin); extern double *sc_interp_get_fgcol(SCInterpreter *scin); -extern double *sc_interp_get_bgcol(SCInterpreter *scin); -extern double *sc_interp_get_bgcol2(SCInterpreter *scin); -extern GradientType sc_interp_get_bggrad(SCInterpreter *scin); - -extern int sc_interp_get_slide_size(SCInterpreter *scin, double *w, double *h); -extern SCBlock *sc_interp_get_macro_real_block(SCInterpreter *scin); - -extern int sc_interp_get_ascent(SCInterpreter *scin); -extern int sc_interp_get_height(SCInterpreter *scin); extern void update_geom(struct frame *fr); diff --git a/src/sc_parse.c b/src/sc_parse.c index b66dc1f..e8904a0 100644 --- a/src/sc_parse.c +++ b/src/sc_parse.c @@ -264,26 +264,8 @@ static SCBlock *sc_find_parent(SCBlock *top, SCBlock *find) } -void sc_block_substitute(SCBlock **top, SCBlock *old, SCBlock *new) -{ - if ( old == NULL ) { - fprintf(stderr, _("Substituting nothing!\n")); - return; - } - - if ( old == *top ) { - /* It is the first block */ - new->next = old->next; - *top = new; - } else { - sc_block_unlink(top, old); - sc_block_append_p(*top, new); - } -} - - /* Unlink "deleteme", which is somewhere under "top" */ -int sc_block_unlink(SCBlock **top, SCBlock *deleteme) +static int sc_block_unlink(SCBlock **top, SCBlock *deleteme) { SCBlock *parent = sc_find_parent(*top, deleteme); if ( parent == NULL ) { @@ -413,36 +395,6 @@ char *serialise_sc_block(const SCBlock *bl) } -/* Serialise an entire chain of blocks */ -char *serialise_sc_block_chain(const SCBlock *bl) -{ - char *a = strdup(""); - size_t len = 1; - - if ( a == NULL ) return NULL; - - while ( bl != NULL ) { - - char *c = serialise_sc_block(bl); - if ( c == NULL ) { - free(a); - return NULL; - } - - len += strlen(c); - a = realloc(a, len); - if ( a == NULL ) return NULL; - strcat(a, c); - free(c); - - bl = bl->next; - - } - - return a; -} - - int save_sc_block(GOutputStream *fh, const SCBlock *bl) { while ( bl != NULL ) { @@ -770,17 +722,6 @@ void sc_block_set_contents(SCBlock *bl, char *con) } -SCBlock *find_last_child(SCBlock *bl) -{ - if ( bl == NULL ) return NULL; - if ( bl->child == NULL ) return NULL; - - bl = bl->child; - while ( bl->next != NULL ) bl = bl->next; - return bl; -} - - void sc_insert_text(SCBlock *b1, size_t o1, const char *t) { if ( b1->contents == NULL ) { @@ -850,37 +791,6 @@ size_t scblock_delete_text(SCBlock *b, ssize_t o1, ssize_t o2) } -/* Create a deep copy of "bl", including all its children */ -SCBlock *sc_block_copy(const SCBlock *bl) -{ - SCBlock *copy; - SCBlock *first_copy; - - first_copy = sc_block_new(); - - copy = first_copy; - do { - - if ( bl->name != NULL ) copy->name = strdup(bl->name); - if ( bl->options != NULL ) copy->options = strdup(bl->options); - if ( bl->contents != NULL ) copy->contents = strdup(bl->contents); - if ( bl->child != NULL ) copy->child = sc_block_copy(bl->child); - - bl = bl->next; - - if ( bl != NULL ) { - SCBlock *nn; - nn = sc_block_new(); - copy->next = nn; - copy = nn; - } - - } while ( bl != NULL ); - - return first_copy; -} - - static char *s_strdup(const char *a) { if ( a == NULL ) return NULL; diff --git a/src/sc_parse.h b/src/sc_parse.h index 9277ee6..17ce2dd 100644 --- a/src/sc_parse.h +++ b/src/sc_parse.h @@ -37,14 +37,11 @@ extern SCBlock *sc_parse(const char *sc); extern SCBlock *sc_block_new(void); extern void sc_block_free(SCBlock *bl); -extern SCBlock *sc_block_copy(const SCBlock *bl); - extern SCBlock *sc_block_next(const SCBlock *bl); extern SCBlock *sc_block_child(const SCBlock *bl); extern const char *sc_block_name(const SCBlock *bl); extern const char *sc_block_options(const SCBlock *bl); extern const char *sc_block_contents(const SCBlock *bl); -extern void sc_block_substitute(SCBlock **top, SCBlock *old, SCBlock *new); extern SCBlock *sc_block_append(SCBlock *bl, char *name, char *opt, char *contents, @@ -68,9 +65,6 @@ extern SCBlock *sc_block_insert_after(SCBlock *afterme, char *name, char *opt, char *contents); extern int sc_block_delete(SCBlock **top, SCBlock *deleteme); -extern int sc_block_unlink(SCBlock **top, SCBlock *deleteme); - -extern SCBlock *find_last_child(SCBlock *bl); extern void sc_block_set_name(SCBlock *bl, char *nam); @@ -84,7 +78,6 @@ extern void show_sc_blocks(const SCBlock *bl); extern void show_sc_block(const SCBlock *bl, const char *prefix); extern char *serialise_sc_block(const SCBlock *bl); -extern char *serialise_sc_block_chain(const SCBlock *bl); extern int save_sc_block(GOutputStream *fh, const SCBlock *bl); extern size_t scblock_delete_text(SCBlock *b, ssize_t o1, ssize_t o2); diff --git a/src/slide_window.c b/src/slide_window.c index b010d1b..e23a3d7 100644 --- a/src/slide_window.c +++ b/src/slide_window.c @@ -109,7 +109,7 @@ static void delete_frame_sig(GSimpleAction *action, GVariant *parameter, /* Change the editor's slide to "np" */ -void change_edit_slide(SlideWindow *sw, SCBlock *np) +static void change_edit_slide(SlideWindow *sw, SCBlock *np) { sc_editor_set_slidenum(sw->sceditor, slide_number(sw->p, np)); diff --git a/src/slide_window.h b/src/slide_window.h index 77de920..b1d39a8 100644 --- a/src/slide_window.h +++ b/src/slide_window.h @@ -31,6 +31,5 @@ typedef struct _slidewindow SlideWindow; extern SlideWindow *slide_window_open(struct presentation *p, SCBlock *scblocks, GApplication *app); -extern void change_edit_slide(SlideWindow *sw, SCBlock *np); #endif /* SLIDEWINDOW_H */ diff --git a/src/utils.c b/src/utils.c index bafbb99..277b3f1 100644 --- a/src/utils.c +++ b/src/utils.c @@ -54,61 +54,6 @@ int safe_strcmp(const char *a, const char *b) } -static char *fgets_long(FILE *fh, size_t *lp) -{ - char *line; - size_t la; - size_t l = 0; - - la = 1024; - line = malloc(la); - if ( line == NULL ) return NULL; - - do { - - int r; - - r = fgetc(fh); - if ( r == EOF ) { - if ( l == 0 ) { - free(line); - *lp = 0; - return NULL; - } else { - line[l++] = '\0'; - *lp = l; - return line; - } - } - - line[l++] = r; - - if ( r == '\n' ) { - line[l++] = '\0'; - *lp = l; - return line; - } - - if ( l == la ) { - - char *ln; - - la += 1024; - ln = realloc(line, la); - if ( ln == NULL ) { - free(line); - *lp = 0; - return NULL; - } - - line = ln; - - } - - } while ( 1 ); -} - - int parse_double(const char *a, float v[2]) { int nn; @@ -136,36 +81,3 @@ int parse_tuple(const char *a, float v[4]) return 0; } - -char *load_everything(const char *filename) -{ - FILE *fh; - size_t el = 1; - char *everything = strdup(""); - - fh = fopen(filename, "r"); - if ( fh == NULL ) return NULL; - - while ( !feof(fh) ) { - - size_t len = 0; - char *line = fgets_long(fh, &len); - - if ( line != NULL ) { - - everything = realloc(everything, el+len); - if ( everything == NULL ) { - fprintf(stderr, _("Failed to allocate memory\n")); - return NULL; - } - el += len; - - strcat(everything, line); - } - - } - - fclose(fh); - - return everything; -} diff --git a/src/utils.h b/src/utils.h index 8870a98..fc843c3 100644 --- a/src/utils.h +++ b/src/utils.h @@ -32,7 +32,6 @@ extern void chomp(char *s); extern int safe_strcmp(const char *a, const char *b); extern int parse_double(const char *a, float v[2]); extern int parse_tuple(const char *a, float v[4]); -extern char *load_everything(const char *filename); #include <libintl.h> #define _(x) gettext(x) |