aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2014-06-30 23:54:53 +0200
committerThomas White <taw@bitwiz.org.uk>2014-06-30 23:54:53 +0200
commit2c6cd610074fc9d0ed3050d4bfa39b5031de876a (patch)
tree58f115e02b5a2fb1ef7bb416b37337a51d2e5c68 /src
parentf6f225c85e8c252623af5f0a5fb1460707c8fc4b (diff)
Debugging stuff
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.c23
-rw-r--r--src/render.c46
-rw-r--r--src/wrap.c2
3 files changed, 49 insertions, 22 deletions
diff --git a/src/mainwindow.c b/src/mainwindow.c
index 8133d91..aa77ce5 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -1075,8 +1075,30 @@ void update_titlebar(struct presentation *p)
}
+static void cur_box_diag(struct presentation *p)
+{
+ int sln, sbx, sps;
+ struct frame *fr;
+
+ fr = p->cursor_frame;
+ sln = p->cursor_line;
+ sbx = p->cursor_box;
+ sps = p->cursor_pos;
+
+ struct wrap_box *sbox = &p->cursor_frame->lines[sln].boxes[sbx];
+
+ printf("line/box/pos: [%i of %i]/[%i of %i]/%i\n", sln, fr->n_lines,
+ sbx, p->cursor_frame->lines[sln].n_boxes, sps);
+ printf("box type is %i, space type is %i\n", sbox->type, sbox->space);
+ if ( sbox->type == WRAP_BOX_NOTHING ) {
+ printf("Warning: in a nothing box!\n");
+ }
+}
+
+
static void move_cursor(struct presentation *p, signed int x, signed int y)
{
+ cur_box_diag(p);
if ( x > 0 ) {
int advance = 0;
@@ -1139,6 +1161,7 @@ static void move_cursor(struct presentation *p, signed int x, signed int y)
} else {
move_cursor_back(p);
}
+ cur_box_diag(p);
}
diff --git a/src/render.c b/src/render.c
index 2d45261..5d4e7e9 100644
--- a/src/render.c
+++ b/src/render.c
@@ -125,7 +125,7 @@ static void draw_outline(cairo_t *cr, struct wrap_box *box)
cairo_rectangle(cr, pango_units_to_double(box->width), -asc,
pango_units_to_double(box->sp), asc + desc);
- cairo_set_source_rgb(cr, 0.7, 0.4, 0.7);
+ cairo_set_source_rgba(cr, 0.7, 0.4, 0.7, 0.2);
cairo_fill(cr);
}
@@ -177,27 +177,23 @@ static void render_boxes(struct wrap_line *line, cairo_t *cr, ImageStore *is,
static void draw_overfull_marker(cairo_t *cr, struct frame *fr, int i)
{
-#if 0
- cairo_move_to(cr, fr->w - fr->lop.pad_l- fr->lop.pad_r, 0.0);
- cairo_line_to(cr, fr->w - fr->lop.pad_l - fr->lop.pad_r,
+ cairo_move_to(cr, fr->w - fr->pad_l- fr->pad_r, 0.0);
+ cairo_line_to(cr, fr->w - fr->pad_l - fr->pad_r,
pango_units_to_double(fr->lines[i].height));
cairo_set_source_rgb(cr, 1.0, 0.0, 0.0);
cairo_set_line_width(cr, 4.0);
cairo_stroke(cr);
-#endif
}
static void draw_underfull_marker(cairo_t *cr, struct frame *fr, int i)
{
-#if 0
- cairo_move_to(cr, fr->w - fr->lop.pad_l- fr->lop.pad_r, 0.0);
- cairo_line_to(cr, fr->w - fr->lop.pad_l - fr->lop.pad_r,
+ cairo_move_to(cr, fr->w - fr->pad_l- fr->pad_r, 0.0);
+ cairo_line_to(cr, fr->w - fr->pad_l - fr->pad_r,
pango_units_to_double(fr->lines[i].height));
cairo_set_source_rgb(cr, 0.0, 0.0, 1.0);
cairo_set_line_width(cr, 4.0);
cairo_stroke(cr);
-#endif
}
@@ -206,6 +202,7 @@ static void render_lines(struct frame *fr, cairo_t *cr, ImageStore *is,
{
int i;
double y_pos = 0.0;
+ const int debug = 1;
for ( i=0; i<fr->n_lines; i++ ) {
@@ -214,15 +211,24 @@ static void render_lines(struct frame *fr, cairo_t *cr, ImageStore *is,
/* Move to beginning of the line */
cairo_translate(cr, 0.0, y_pos);
- #if 0
- cairo_move_to(cr, 0.0,
- 0.5+pango_units_to_double(fr->lines[i].ascent));
- cairo_line_to(cr, pango_units_to_double(fr->lines[i].width),
- 0.5+pango_units_to_double(fr->lines[i].ascent));
- cairo_set_source_rgb(cr, 0.0, 0.0, 1.0);
- cairo_set_line_width(cr, 1.0);
- cairo_stroke(cr);
- #endif
+ if ( debug ) {
+ cairo_move_to(cr,
+ 0.0,
+ 0.5+pango_units_to_double(fr->lines[i].ascent));
+ cairo_line_to(cr,
+ pango_units_to_double(fr->lines[i].width),
+ 0.5+pango_units_to_double(fr->lines[i].ascent));
+ cairo_set_source_rgb(cr, 0.0, 0.0, 1.0);
+ cairo_set_line_width(cr, 1.0);
+ cairo_stroke(cr);
+
+ cairo_move_to(cr, 0.0, 0.0);
+ cairo_line_to(cr, 0.0,
+ pango_units_to_double(fr->lines[i].height));
+ cairo_set_line_width(cr, 3.0);
+ cairo_set_source_rgb(cr, 0.0, 1.0, 0.0);
+ cairo_stroke(cr);
+ }
/* Render the line */
cairo_save(cr);
@@ -231,10 +237,10 @@ static void render_lines(struct frame *fr, cairo_t *cr, ImageStore *is,
render_boxes(&fr->lines[i], cr, is, isz);
cairo_restore(cr);
- if ( fr->lines[i].overfull ) {
+ if ( debug && fr->lines[i].overfull ) {
draw_overfull_marker(cr, fr, i);
}
- if ( fr->lines[i].underfull ) {
+ if ( debug && fr->lines[i].underfull ) {
draw_underfull_marker(cr, fr, i);
}
diff --git a/src/wrap.c b/src/wrap.c
index d58cce2..f56b29b 100644
--- a/src/wrap.c
+++ b/src/wrap.c
@@ -177,11 +177,9 @@ void move_cursor_back(struct presentation *p)
cp = p->cursor_pos;
cb = p->cursor_box;
cl = p->cursor_line;
- printf("moving back from %i %i %i\n", cl, cb, cp);
line = &p->cursor_frame->lines[p->cursor_line];
box = &line->boxes[p->cursor_box];
- printf("box = %p\n", box);
if ( box->type == WRAP_BOX_PANGO ) {
if ( cp == 0 ) {