]> uap-core.de Git - note.git/commitdiff
fix paragraph style changes on gtk3
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Tue, 18 Mar 2025 17:35:28 +0000 (18:35 +0100)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Tue, 18 Mar 2025 17:35:28 +0000 (18:35 +0100)
application/gtk-text.c
ui/common/context.c

index 5181556e3d7f9f82cfc22aa68273c3261d62c613..1393e78e7e5e63101e3fdc26312b122f8f59f8e2 100644 (file)
@@ -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;
             }
index 585719440a876aff444f73c600815f475547bfb4..6969d1e1eb15fb6a2b1195e28bc21c1b00fa6aa0 100644 (file)
@@ -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) {