diff ui.c @ 713:93d0e1547842

th-libs now uses stdbool.h if possible, so we need to rename all BOOL/TRUE/FALSE to bool/true/false.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 07 Dec 2022 13:20:25 +0200
parents ff1af7410bba
children
line wrap: on
line diff
--- a/ui.c	Wed Dec 07 13:19:25 2022 +0200
+++ b/ui.c	Wed Dec 07 13:20:25 2022 +0200
@@ -10,7 +10,7 @@
 nn_window_t *chatWindows[SET_MAX_WINDOWS],
             *currWin = NULL;
 
-BOOL    appCursesInit = FALSE, appQuitFlag = FALSE;
+bool    appCursesInit = false, appQuitFlag = false;
 int     cursorVisible = ERR,
         scrWidth, scrHeight;
 
@@ -71,7 +71,7 @@
 }
 
 
-BOOL nnwin_init(int delay)
+bool nnwin_init(int delay)
 {
     // Sanity check the terminal size
     if (LINES < 0 || LINES > 1000) LINES = 24;
@@ -80,11 +80,11 @@
     // Initialize (n)curses library and terminal settings
     initscr();
     raw();
-    keypad(stdscr, TRUE);
+    keypad(stdscr, true);
     noecho();
-    meta(stdscr, TRUE);
+    meta(stdscr, true);
     timeout(delay);
-    scrollok(stdscr, FALSE);
+    scrollok(stdscr, false);
     cursorVisible = curs_set(1);
 
     if (has_colors())
@@ -109,7 +109,7 @@
         init_pair(16, COLOR_CYAN,    COLOR_RED);
     }
 
-    appCursesInit = TRUE;
+    appCursesInit = true;
     nnwin_reset();
 
 #ifdef PDCURSES
@@ -121,7 +121,7 @@
     nn_log_open(chatWindows[0]);
     currWin = chatWindows[0];
 
-    return TRUE;
+    return true;
 }
 
 
@@ -165,16 +165,16 @@
 }
 
 
-BOOL nnwin_open(const char *name, BOOL curwin)
+bool nnwin_open(const char *name, bool curwin)
 {
     nn_window_t *res;
     int i;
 
     if (name == NULL)
-        return FALSE;
+        return false;
 
     if ((res = nn_window_new(name)) == NULL)
-        return FALSE;
+        return false;
 
     nn_log_open(res);
 
@@ -185,10 +185,10 @@
         chatWindows[i] = res;
         if (curwin)
             currWin = res;
-        return TRUE;
+        return true;
     }
 
-    return FALSE;
+    return false;
 }
 
 
@@ -208,7 +208,7 @@
 }
 
 
-static BOOL nnwin_get_color(char const **s, int *col)
+static bool nnwin_get_color(char const **s, int *col)
 {
     int val = 0;
 
@@ -219,33 +219,33 @@
         (*s)++;
     }
     if (**s != '½')
-        return FALSE;
+        return false;
 
     if (val < 9)
         *col = A_DIM | COLOR_PAIR(val);
     else if (val < 30)
         *col = A_BOLD | COLOR_PAIR(val - 9);
 
-    return TRUE;
+    return true;
 }
 
 
 #define QPUTCH(ch) nnwin_putch(&(win->line->buf), &(win->line->bufsize), &(win->line->len), col, ch)
 
-static BOOL nnwin_putch(int **buf, size_t *bufsize, size_t *len, int color, char ch)
+static bool nnwin_putch(int **buf, size_t *bufsize, size_t *len, int color, char ch)
 {
     if (*buf == NULL || *len + 1 >= *bufsize)
     {
         *bufsize += TH_BUFGROW;
         *buf = (int *) th_realloc(*buf, *bufsize * sizeof(int));
         if (*buf == NULL)
-            return FALSE;
+            return false;
     }
 
     (*buf)[*len] = ((unsigned char) ch) | color;
     (*len)++;
 
-    return TRUE;
+    return true;
 }
 
 
@@ -283,7 +283,7 @@
         {
             th_ringbuf_add(win->data, win->line);
             win->line = NULL;
-            win->dirty = TRUE;
+            win->dirty = true;
         }
         else if (*s != '\r')
         {
@@ -297,7 +297,7 @@
 }
 
 
-static void nnwin_print_str(WINDOW *win, const char *fmt, BOOL clip)
+static void nnwin_print_str(WINDOW *win, const char *fmt, bool clip)
 {
     const char *s = fmt;
     int col = 0;
@@ -329,10 +329,10 @@
 }
 
 
-void nnwin_update(BOOL force, BOOL mask, nn_editbuf_t *ebuf, const char *username, const unsigned int usercolor)
+void nnwin_update(bool force, bool mask, nn_editbuf_t *ebuf, const char *username, const unsigned int usercolor)
 {
     int sx, sy;
-    BOOL changed = FALSE;
+    bool changed = false;
 
     // Clear screen if forced or main or editbuf are dirty
     if (force || (currWin != NULL && currWin->dirty) || (ebuf != NULL && ebuf->dirty))
@@ -343,8 +343,8 @@
         wattrset(stdscr, A_NORMAL);
         wbkgdset(stdscr, COLOR_PAIR(0));
         werase(stdscr);
-        force = TRUE;
-        changed = TRUE;
+        force = true;
+        changed = true;
     }
     else
     {
@@ -358,7 +358,7 @@
         int y, offs;
         th_ringbuf_t *buf = currWin->data;
 
-        changed = TRUE;
+        changed = true;
 
         for (y = scrHeight - 4, offs = buf->size - 1 - currWin->pos; offs >= 0 && y > 0; offs--)
         {
@@ -394,7 +394,7 @@
             }
         }
 
-        currWin->dirty = FALSE;
+        currWin->dirty = false;
     }
 
     // Update statusline
@@ -428,7 +428,7 @@
         wmove(stdscr, scrHeight - 4, 0);
         wbkgdset(stdscr, COLOR_PAIR(10));
         wclrtoeol(stdscr);
-        nnwin_print_str(stdscr, tmpStr, TRUE);
+        nnwin_print_str(stdscr, tmpStr, true);
 
         for (i = 0; i < SET_MAX_WINDOWS; i++)
         {
@@ -453,7 +453,7 @@
         wattrset(stdscr, A_NORMAL);
         wbkgdset(stdscr, COLOR_PAIR(0));
 
-        ebuf->dirty = FALSE;
+        ebuf->dirty = false;
         if (mask)
         {
             size_t i;
@@ -470,7 +470,7 @@
         }
         wmove(stdscr, scrHeight - 3 + yoffs, xoffs);
 
-        changed = TRUE;
+        changed = true;
     }
 
     if (changed)
@@ -479,7 +479,7 @@
 
 
 void nnwin_input_process(nn_editbuf_t *editBuf, nn_editstate_t *editState,
-    BOOL (*callback)(int, nn_editbuf_t *, nn_editstate_t *))
+    bool (*callback)(int, nn_editbuf_t *, nn_editstate_t *))
 {
     int c, cnt = 0;
 
@@ -584,7 +584,7 @@
             erase();
             timeout(SET_DELAY);
             nnwin_reset();
-            editState->update = TRUE;
+            editState->update = true;
             break;
 #endif
 
@@ -594,7 +594,7 @@
                 editBuf->pos--;
             while (editBuf->pos > 0 && !isspace((int) editBuf->data[editBuf->pos - 1]))
                 editBuf->pos--;
-            editBuf->dirty = TRUE;
+            editBuf->dirty = true;
             break;
 
         case 0x206: // ctrl+right arrow = Skip words right
@@ -603,7 +603,7 @@
                 editBuf->pos++;
             while (editBuf->pos < editBuf->len && !isspace((int) editBuf->data[editBuf->pos]))
                 editBuf->pos++;
-            editBuf->dirty = TRUE;
+            editBuf->dirty = true;
             break;
 
         case KEY_HOME:
@@ -642,7 +642,7 @@
             break;
 
         case 0x0c: // Ctrl + L
-            editState->update = TRUE;
+            editState->update = true;
             break;
 
         case ERR:
@@ -671,14 +671,14 @@
 
 
 
-char *nnwin_prompt_requester(BOOL allowEmpty, nn_editstate_t *editState,
-    BOOL (*callback)(int, nn_editbuf_t *, nn_editstate_t *),
+char *nnwin_prompt_requester(bool allowEmpty, nn_editstate_t *editState,
+    bool (*callback)(int, nn_editbuf_t *, nn_editstate_t *),
     void (*update)(nn_editbuf_t *, nn_editstate_t *))
 {
     nn_editbuf_t *editBuf = nn_editbuf_new(NN_TMPBUF_SIZE);
     char *res;
 
-    editState->done = FALSE;
+    editState->done = false;
     while (!editState->isError && !appQuitFlag && !editState->done)
     {
         nnwin_input_process(editBuf, editState, callback);