From d845b9670fb506102b6063b01e1c50ea1be9a25d Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Tue, 18 Mar 2025 18:35:28 +0100 Subject: [PATCH] fix paragraph style changes on gtk3 --- application/gtk-text.c | 11 +++++++++-- ui/common/context.c | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/application/gtk-text.c b/application/gtk-text.c index 5181556..1393e78 100644 --- a/application/gtk-text.c +++ b/application/gtk-text.c @@ -626,15 +626,22 @@ void editor_set_paragraph_style(UiText *text, const char *style) { while(gtk_text_iter_forward_line(&next_line)) { GtkTextIter begin = next_line; GtkTextIter end = next_line; + // gtk3 and gtk4 have different behavior here + // with gtk3, when the following line is empty, the end iter is set + // to the next line gtk_text_iter_set_line_offset(&begin, 0); gtk_text_iter_forward_to_line_end(&end); - + char *line_str = gtk_text_buffer_get_slice(buffer, &begin, &end, TRUE); char *str = line_str; int blank = TRUE; while(*str) { char c = *str; - if(!isspace(*str)) { + // necessary check for gtk3 + if(c == '\n') { + break; + } + if(!isspace(c)) { blank = FALSE; break; } diff --git a/ui/common/context.c b/ui/common/context.c index 5857194..6969d1e 100644 --- a/ui/common/context.c +++ b/ui/common/context.c @@ -101,7 +101,7 @@ void uic_context_attach_document(UiContext *ctx, void *document) { if(var_ctx->vars_unbound && cxMapSize(var_ctx->vars_unbound) > 0) { CxMapIterator i = cxMapIterator(var_ctx->vars_unbound); cx_foreach(CxMapEntry*, entry, i) { - printf("attach %s\n", entry->key->data); + printf("attach %.*s\n", (int)entry->key->len, entry->key->data); UiVar *var = entry->value; UiVar *docvar = cxMapGet(doc_ctx->vars, *entry->key); if(docvar) { -- 2.43.5