]> git.mdlowis.com Git - projs/tide.git/commitdiff
revised font loading so bad font arguments don't cause the editor to exit
authorMichael D. Lowis <mike.lowis@gentex.com>
Thu, 27 Sep 2018 13:37:17 +0000 (09:37 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Thu, 27 Sep 2018 13:37:17 +0000 (09:37 -0400)
TODO.md
lib/view.c
lib/x11.c

diff --git a/TODO.md b/TODO.md
index d3bdb41c4d22fc5925ed1a2c8f53f05f987e07b6..3e3c28b47bc6119054f38e20c1cf734adc18cbd3 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -7,6 +7,7 @@
 * gap buffer does not handle UTF-8 currently
 * mouse selection handling when mouse moves outside region
 * Line - Get the current line number(s) containing the selection
+* refactor selection handling to avoid swapping manually (use buf_selbeg and buf_selend)
 
 ## BACKLOG
 
index 9fcb9c8518f52e338dc5ed607c062c6a6e310447..50b0d50a2b4e9249ab4624e8798be865d12cf61f 100644 (file)
@@ -265,12 +265,12 @@ void view_insert(View* view, Rune rune) {
         size_t n = (TabWidth - ((off - buf_bol(BUF, off)) % TabWidth));
         for (; n > 0; n--) buf_putc(BUF, ' ');
     } else if (CopyIndent && rune == '\n') {
-         size_t off = buf_selbeg(BUF);
-         size_t beg = buf_bol(BUF, off-1), end = beg;
-         for (; end < buf_end(BUF) && (' ' == buf_getrat(BUF, end) || '\t' == buf_getrat(BUF, end)); end++);
+        size_t off = buf_selbeg(BUF);
+        size_t beg = buf_bol(BUF, off-1), end = beg;
+        for (; end < buf_end(BUF) && (' ' == buf_getrat(BUF, end) || '\t' == buf_getrat(BUF, end)); end++);
         buf_putc(BUF, '\n');
         for (; beg < end; beg++)
-             buf_putc(BUF, buf_getrat(BUF, beg));
+            buf_putc(BUF, buf_getrat(BUF, beg));
     } else {
         buf_putc(BUF, rune);
     }
index 620f3bb32acf2d8d200f6998e77fb50d19acffe7..fac36324940a879051eba52d2113b944083a5db9 100644 (file)
--- a/lib/x11.c
+++ b/lib/x11.c
@@ -78,7 +78,11 @@ static void font_load(char* name) {
     /* load the base font */
     FcResult result;
     FcPattern* match = XftFontMatch(X.display, X.screen, pattern, &result);
-    if (!match || !(X.font = XftFontOpenPattern(X.display, match)))
+    if (match) {
+        XftFont* font = XftFontOpenPattern(X.display, match);
+        X.font = (font ? font : X.font); // Update if we found a new font
+    }
+    if (!X.font)
         die("could not load base font\n");
     FcPatternDestroy(pattern);
     FcPatternDestroy(match);