aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2015-11-08 23:12:50 +0100
committerThomas White <taw@bitwiz.org.uk>2015-11-08 23:12:50 +0100
commit9fa18b75c1354989dabf682788b9ea41fe28c707 (patch)
treec3e2a7bdcc64f1d531bb420e25f117fa65e0c7bc /src
parent4f2a324e715ea835b6be56579d8f8380a9e7370d (diff)
WIP on breaks
Diffstat (limited to 'src')
-rw-r--r--src/render.c5
-rw-r--r--src/sc_editor.c22
-rw-r--r--src/sc_editor.h1
-rw-r--r--src/sc_interp.c6
-rw-r--r--src/sc_interp.h3
5 files changed, 31 insertions, 6 deletions
diff --git a/src/render.c b/src/render.c
index 1139ff6..7aaa8b4 100644
--- a/src/render.c
+++ b/src/render.c
@@ -431,7 +431,8 @@ int recursive_wrap(struct frame *fr, ImageStore *is, enum is_size isz)
struct frame *interp_and_shape(SCBlock *scblocks, SCBlock **stylesheets,
SCCallbackList *cbl, ImageStore *is,
enum is_size isz, int slide_number,
- cairo_t *cr, double w, double h)
+ cairo_t *cr, double w, double h,
+ PangoLanguage *lang)
{
cairo_font_options_t *fopts;
PangoFontMap *fontmap;
@@ -458,7 +459,7 @@ struct frame *interp_and_shape(SCBlock *scblocks, SCBlock **stylesheets,
top->w = w;
top->h = h;
- scin = sc_interp_new(pc, top);
+ scin = sc_interp_new(pc, lang, top);
if ( scin == NULL ) {
fprintf(stderr, "Failed to set up interpreter.\n");
frame_free(top);
diff --git a/src/sc_editor.c b/src/sc_editor.c
index 11ec724..f1af23f 100644
--- a/src/sc_editor.c
+++ b/src/sc_editor.c
@@ -778,6 +778,28 @@ void insert_scblock(SCBlock *scblock, SCEditor *e)
static void update_local(SCEditor *e, struct frame *fr, int line, int bn)
{
struct wrap_box *box = &fr->lines[line].boxes[bn];
+ const char *text;
+ size_t len_bytes;
+ int len_chars;
+ PangoLogAttr *log_attrs;
+ int offs;
+
+ text = sc_block_contents(box->scblock);
+ len_bytes = strlen(text);
+ len_chars = g_utf8_strlen(text, -1);
+
+ log_attrs = malloc((len_chars+1)*sizeof(PangoLogAttr));
+ if ( log_attrs == NULL ) return;
+ pango_get_log_attrs(text, len_bytes, -1, e->lang,
+ log_attrs, len_chars+1);
+
+ offs = box->offs_char + e->cursor_pos;
+
+ if ( log_attrs[offs].is_line_break ) {
+ printf("Just typed a break!\n");
+ }
+
+ free(log_attrs);
/* Shape the box again */
shape_box(box->cf->cf);
diff --git a/src/sc_editor.h b/src/sc_editor.h
index acbf9cf..289b56f 100644
--- a/src/sc_editor.h
+++ b/src/sc_editor.h
@@ -84,6 +84,7 @@ enum drag_status
struct _sceditor
{
GtkDrawingArea parent_instance;
+ PangoLanguage *lang;
/*< private >*/
GtkIMContext *im_context;
diff --git a/src/sc_interp.c b/src/sc_interp.c
index 4138a7a..566e8e4 100644
--- a/src/sc_interp.c
+++ b/src/sc_interp.c
@@ -483,7 +483,8 @@ static void set_frame(SCInterpreter *scin, struct frame *fr)
}
-SCInterpreter *sc_interp_new(PangoContext *pc, struct frame *top)
+SCInterpreter *sc_interp_new(PangoContext *pc, PangoLanguage *lang,
+ struct frame *top)
{
SCInterpreter *scin;
struct sc_state *st;
@@ -515,8 +516,7 @@ SCInterpreter *sc_interp_new(PangoContext *pc, struct frame *top)
}
st->macro_contents = NULL;
- /* FIXME: Determine proper language (somehow...) */
- scin->lang = pango_language_from_string("en_GB");
+ scin->lang = lang;
/* The "ultimate" default font */
set_font(scin, "Sans 12");
diff --git a/src/sc_interp.h b/src/sc_interp.h
index 4591bae..ec8fe06 100644
--- a/src/sc_interp.h
+++ b/src/sc_interp.h
@@ -38,7 +38,8 @@ typedef int (*SCCallbackBoxFunc)(SCInterpreter *scin, SCBlock *bl,
double *w, double *h, void **, void *);
typedef cairo_surface_t *(*SCCallbackDrawFunc)(int w, int h, void *, void *);
-extern SCInterpreter *sc_interp_new(PangoContext *pc, struct frame *top);
+extern SCInterpreter *sc_interp_new(PangoContext *pc, PangoLanguage *lang,
+ struct frame *top);
extern void sc_interp_destroy(SCInterpreter *scin);
extern void sc_interp_save(SCInterpreter *scin);