diff options
author | Thomas White <taw@physics.org> | 2017-11-12 22:02:30 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2017-11-12 22:02:30 +0100 |
commit | 0ecdb80b9c959d995777f206b1a63f44110e4a82 (patch) | |
tree | b9bdace5f2e05b29968e1e5663aa6328fe589d4d | |
parent | 34fc6a05736db1121a792b3aeb7c1c45deff510b (diff) |
Debug stuff (revert me later)
-rw-r--r-- | src/debugger.c | 2 | ||||
-rw-r--r-- | src/frame.c | 48 | ||||
-rw-r--r-- | src/sc_editor.c | 6 | ||||
-rw-r--r-- | src/sc_interp.c | 3 |
4 files changed, 57 insertions, 2 deletions
diff --git a/src/debugger.c b/src/debugger.c index c1e971e..2116ed7 100644 --- a/src/debugger.c +++ b/src/debugger.c @@ -309,7 +309,7 @@ void open_debugger(struct frame *fr) dbgw->drawingarea = gtk_drawing_area_new(); gtk_container_add(GTK_CONTAINER(scroll), dbgw->drawingarea); - gtk_widget_set_size_request(dbgw->drawingarea, 100, 2000); + gtk_widget_set_size_request(dbgw->drawingarea, 100, 8000); g_signal_connect(G_OBJECT(dbgw->drawingarea), "draw", G_CALLBACK(draw_sig), dbgw); diff --git a/src/frame.c b/src/frame.c index 435fcc0..9ff8d00 100644 --- a/src/frame.c +++ b/src/frame.c @@ -881,6 +881,14 @@ size_t pos_trail_to_offset(Paragraph *para, size_t offs, int trail) return 0; } + if ( sc_block_contents(run->scblock) == NULL ) { + fprintf(stderr, "pos_trail_to_offset: No contents " + "(%p name=%s, options=%s)\n", + run->scblock, sc_block_name(run->scblock), + sc_block_options(run->scblock)); + return 0; + } + /* Get the text for the run */ run_text = sc_block_contents(run->scblock) + run->scblock_offs_bytes; @@ -1274,6 +1282,27 @@ void merge_paragraphs(struct frame *fr, int para) } +static void check_para(Paragraph *para) +{ + int i; + for ( i=0; i<para->n_runs; i++ ) { + const char *run_text; + if ( sc_block_contents(para->runs[i].scblock) == NULL ) continue; + run_text = sc_block_contents(para->runs[i].scblock) + + para->runs[i].scblock_offs_bytes; + if ( strlen(run_text) < para->runs[i].len_bytes ) { + printf("found a wrong run\n"); + printf("run %i sc offs %li, para offs %li text '%s'\n", i, + (long int)para->runs[i].scblock_offs_bytes, + (long int)para->runs[i].para_offs_bytes, + run_text); + printf("(the SCBlock contains '%s'\n", sc_block_contents(para->runs[i].scblock)); + printf("run %p block %p\n", ¶->runs[i], para->runs[i].scblock); + } + } +} + + static SCBlock *split_text_paragraph(struct frame *fr, int pn, size_t pos, PangoContext *pc) { @@ -1308,6 +1337,7 @@ static SCBlock *split_text_paragraph(struct frame *fr, int pn, size_t pos, rr = ¶->runs[run]; run_offs = pos - rr->para_offs_bytes; + printf("split at run %i\n", run); if ( rr->len_bytes == run_offs ) { @@ -1316,6 +1346,7 @@ static SCBlock *split_text_paragraph(struct frame *fr, int pn, size_t pos, if ( run == para->n_runs-1 ) { /* It's actually a paragraph boundary. Even easier still... */ + printf("splitting at end of para\n"); pnew->runs[0].para_offs_bytes = 0; pnew->runs[0].scblock = rr->scblock; pnew->runs[0].macro_real_block = rr->macro_real_block; @@ -1350,6 +1381,8 @@ static SCBlock *split_text_paragraph(struct frame *fr, int pn, size_t pos, pnew->runs[0].scblock_offs_bytes = rr->scblock_offs_bytes + run_offs; pnew->runs[0].para_offs_bytes = 0; pnew->runs[0].len_bytes = rr->len_bytes - run_offs; + printf("%i - %i\n", (int)rr->len_bytes, (int)run_offs); + printf("second run len = %i\n", (int)pnew->runs[0].len_bytes); pnew->runs[0].fontdesc = pango_font_description_copy(rr->fontdesc); pnew->runs[0].col[0] = rr->col[0]; pnew->runs[0].col[1] = rr->col[1]; @@ -1381,8 +1414,18 @@ static SCBlock *split_text_paragraph(struct frame *fr, int pn, size_t pos, size_t sc_offs; sc_offs = rr->scblock_offs_bytes + run_offs; + printf("splitting SCBlock at %i\n", (int)sc_offs); + printf("old block: '%s'\n", sc_block_contents(rr->scblock)); pnew->runs[0].scblock = sc_block_split(rr->scblock, sc_offs); pnew->runs[0].scblock_offs_bytes = 0; + printf("new block 1: '%s'\n", sc_block_contents(rr->scblock)); + printf("new block 2: '%s'\n", sc_block_contents(pnew->runs[0].scblock)); + printf("run %p block %p\n", &pnew->runs[0], pnew->runs[0].scblock); + + printf("run %i sc offs %li, para offs %li\n", 0, + (long int)pnew->runs[0].scblock_offs_bytes, + (long int)pnew->runs[0].para_offs_bytes); + printf("len %i\n", (int)pnew->runs[0].len_bytes); } /* Add a \newpara after the end of the first paragraph's SC */ @@ -1393,6 +1436,11 @@ static SCBlock *split_text_paragraph(struct frame *fr, int pn, size_t pos, pnew->open = para->open; para->open = 0; + printf("first para:\n"); + check_para(para); + printf("second para:\n"); + check_para(pnew); + wrap_paragraph(para, pc, fr->w - fr->pad_l - fr->pad_r, 0, 0); wrap_paragraph(pnew, pc, fr->w - fr->pad_l - fr->pad_r, 0, 0); diff --git a/src/sc_editor.c b/src/sc_editor.c index dce5bb4..ed4db5b 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -1033,6 +1033,12 @@ static void rewrap_paragraph_range(struct frame *fr, int a, int b, sort_positions(&sel_start, &sel_end); + //printf("frame %p\n", fr); + //printf("start: "); + //show_edit_pos(sel_start); + //printf(" end: "); + //show_edit_pos(sel_end); + para = fr->paras[sel_start.para]; sel_s = pos_trail_to_offset(para, sel_start.pos, sel_start.trail); para = fr->paras[sel_end.para]; diff --git a/src/sc_interp.c b/src/sc_interp.c index fe563c2..93a23d4 100644 --- a/src/sc_interp.c +++ b/src/sc_interp.c @@ -304,7 +304,8 @@ static void update_font(SCInterpreter *scin) scin->pc, st->fontdesc); if ( st->font == NULL ) { char *f = pango_font_description_to_string(st->fontdesc); - fprintf(stderr, "Couldn't load font '%s'\n", f); + fprintf(stderr, "Couldn't load font '%s' (font map %p, pc %p)\n", + f, pango_context_get_font_map(scin->pc), scin->pc); g_free(f); return; } |