URI: 
       tChange include style - ltkx - GUI toolkit for X11 (WIP)
  HTML git clone git://lumidify.org/ltkx.git
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 809bd045ef627e90e5f062f49fdc44582a901dc8
   DIR parent 2a84c41d72caee1321ea6ec0d7bbb05d8727ef9d
  HTML Author: lumidify <nobody@lumidify.org>
       Date:   Sun, 12 Apr 2020 09:40:55 +0200
       
       Change include style
       
       Diffstat:
         M button.c                            |      11 +++++++++++
         M button.h                            |       2 +-
         M grid.c                              |       4 ++++
         M grid.h                              |       2 +-
         M ltk.c                               |      49 +++++++------------------------
         M ltk.h                               |      16 +++++++---------
         A ltkx.h                              |      13 +++++++++++++
         M test1.c                             |       2 +-
         M text-hb.c                           |      19 ++++++++-----------
         M text-hb.h                           |      16 +++++++---------
       
       10 files changed, 64 insertions(+), 70 deletions(-)
       ---
   DIR diff --git a/button.c b/button.c
       t@@ -21,13 +21,24 @@
         * SOFTWARE.
         */
        
       +#include <X11/Xlib.h>
       +#include <X11/Xutil.h>
       +#include "khash.h"
        #include "ltk.h"
       +#include "stb_truetype.h"
       +#include <fribidi.h>
       +#include <harfbuzz/hb.h>
       +#include <fontconfig/fontconfig.h>
       +#include "text-hb.h"
        #include "button.h"
        
        extern Ltk *ltk_global;
        
        void ltk_button_ini_handler(LtkTheme *theme, const char *prop, const char *value)
        {
       +        if (theme->button == NULL) {
       +                theme->button = malloc(sizeof(LtkButtonTheme));
       +        }
                if (strcmp(prop, "border_width") == 0) {
                        theme->button->border_width = atoi(value);
                } else if (strcmp(prop, "font_size") == 0) {
   DIR diff --git a/button.h b/button.h
       t@@ -24,7 +24,7 @@
        #ifndef _LTK_BUTTON_H_
        #define _LTK_BUTTON_H_
        
       -#include "text-hb.h"
       +/* Requires the following includes: <X11/Xlib.h>, "ltk.h", "text-hb.h" */
        
        typedef struct {
                LtkWidget widget;
   DIR diff --git a/grid.c b/grid.c
       t@@ -23,6 +23,10 @@
        
        /* TODO: remove_widget function that also adjusts static width */
        
       +#include <X11/Xlib.h>
       +#include <X11/Xutil.h>
       +#include "khash.h"
       +#include "ltk.h"
        #include "grid.h"
        
        void ltk_set_row_weight(LtkGrid * grid, int row, int weight)
   DIR diff --git a/grid.h b/grid.h
       t@@ -24,7 +24,7 @@
        #ifndef _LTK_GRID_H_
        #define _LTK_GRID_H_
        
       -#include "ltk.h"
       +/* Requires the following incude: <X11/Xlib.h>, "ltk.h" */
        
        /*
         * Struct to represent a grid widget.
   DIR diff --git a/ltk.c b/ltk.c
       t@@ -24,7 +24,15 @@
        #include <stdio.h>
        #include <stdlib.h>
        #include "ini.h"
       +#include <X11/Xlib.h>
       +#include <X11/Xutil.h>
       +#include "khash.h"
        #include "ltk.h"
       +#include "stb_truetype.h"
       +#include <fribidi.h>
       +#include <harfbuzz/hb.h>
       +#include <fontconfig/fontconfig.h>
       +#include "text-hb.h"
        
        Ltk *ltk_global;
        
       t@@ -88,16 +96,6 @@ void ltk_mainloop(void)
                while (1) {
                        XNextEvent(ltk_global->display, &event);
                        ltk_handle_event(event);
       -                /*
       -                   if (event.type == KeyPress && XLookupString(&event.xkey, text, 255, &key, 0) == 1)
       -                   {
       -                   if (text[0] == 'q')
       -                   {
       -                   XCloseDisplay(ltk_global->display);
       -                   exit(0);
       -                   }
       -                   }
       -                 */
                }
        }
        
       t@@ -107,6 +105,7 @@ void ltk_redraw_window(LtkWindow * window)
                if (!window) {
                        return;
                }
       +        XClearWindow(ltk_global->display, window->xwindow);
                if (!window->root_widget) {
                        return;
                }
       t@@ -178,7 +177,7 @@ void ltk_destroy_window(LtkWindow * window)
        
        void ltk_window_other_event(void *widget, XEvent event)
        {
       -        LtkWindow *window = widget;
       +        LtkWindow *window = (LtkWindow *) widget;
                LtkWidget *ptr = window->root_widget;
                if (event.type == ConfigureNotify) {
                        unsigned int w, h;
       t@@ -229,37 +228,11 @@ LtkTheme *ltk_load_theme(const char *path)
        {
                LtkTheme *theme = malloc(sizeof(LtkTheme));
                theme->window = malloc(sizeof(LtkWindowTheme));
       -        theme->button = malloc(sizeof(LtkButtonTheme));
       +        theme->button = NULL;
                if (ini_parse(path, ltk_ini_handler, theme) < 0) {
                        fprintf(stderr, "ERROR: Can't load theme %s\n.", path);
                        exit(1);
                }
       -        /*
       -        char *file_contents = ltk_read_file(path);
       -
       -        cJSON *json = cJSON_Parse(file_contents);
       -        if (!json) {
       -                printf("Theme error before: [%s]\n", cJSON_GetErrorPtr());
       -                return NULL;
       -        }
       -        cJSON *button_json = cJSON_GetObjectItem(json, "button");
       -        if (!button_json) {
       -                printf("Theme error before: [%s]\n", cJSON_GetErrorPtr());
       -                return NULL;
       -        }
       -        cJSON *window_json = cJSON_GetObjectItem(json, "window");
       -        if (!window_json) {
       -                printf("Theme error before: [%s]\n", cJSON_GetErrorPtr());
       -                return NULL;
       -        }
       -
       -        LtkTheme *theme = malloc(sizeof(LtkTheme));
       -        theme->button = ltk_parse_button_theme(button_json);
       -        theme->window = ltk_parse_window_theme(window_json);
       -
       -        free(file_contents);
       -        cJSON_Delete(json);
       -        */
        
                return theme;
        }
   DIR diff --git a/ltk.h b/ltk.h
       t@@ -24,10 +24,7 @@
        #ifndef _LTK_H_
        #define _LTK_H_
        
       -#include <X11/Xlib.h>
       -#include <X11/Xutil.h>
       -#include "khash.h"
       -#include "text-hb.h"
       +/* Requires the following includes: <X11/Xlib.h>, <X11/Xutil.h>, "khash.h" */
        
        typedef struct {
                int x;
       t@@ -82,9 +79,6 @@ typedef struct LtkWidget {
                unsigned short sticky;
        } LtkWidget;
        
       -/* Window hash */
       -KHASH_MAP_INIT_INT(winhash, LtkWindow*)
       -
        typedef struct LtkWindow {
                Window xwindow;
                GC gc;
       t@@ -100,8 +94,7 @@ typedef struct LtkWindowTheme {
                XColor bg;
        } LtkWindowTheme;
        
       -#include "button.h"
       -#include "grid.h"
       +typedef struct LtkButtonTheme LtkButtonTheme;
        
        typedef struct {
                LtkWindowTheme *window;
       t@@ -110,6 +103,11 @@ typedef struct {
        
        LtkTheme *ltk_load_theme(const char *path);
        
       +typedef struct LtkTextManager LtkTextManager;
       +
       +/* Window hash */
       +KHASH_MAP_INIT_INT(winhash, LtkWindow*)
       +
        typedef struct {
                LtkTheme *theme;
                LtkTextManager *tm;
   DIR diff --git a/ltkx.h b/ltkx.h
       t@@ -0,0 +1,13 @@
       +/* This just includes all the other files for convenience */
       +#include <X11/Xlib.h>
       +#include <X11/Xutil.h>
       +#include "khash.h"
       +#include "ltk.h"
       +#include "stb_truetype.h" /* http://nothings.org/stb/stb_truetype.h */
       +#include <fontconfig/fontconfig.h>
       +#include <fribidi.h>
       +#include <harfbuzz/hb.h>
       +#include <harfbuzz/hb-ot.h>
       +#include "text-hb.h"
       +#include "button.h"
       +#include "grid.h"
   DIR diff --git a/test1.c b/test1.c
       t@@ -1,4 +1,4 @@
       -#include "ltk.h"
       +#include "ltkx.h"
        
        void bob1(void)
        {
   DIR diff --git a/text-hb.c b/text-hb.c
       t@@ -25,9 +25,16 @@
        #include <stdlib.h>
        #include <stdint.h>
        #include <limits.h>
       +#include <X11/Xlib.h>
       +#include <X11/Xutil.h>
        #include "stb_truetype.h" /* http://nothings.org/stb/stb_truetype.h */
       -#include "ltk.h"
       +#include <fontconfig/fontconfig.h>
       +#include "khash.h"
       +#include <fribidi.h>
       +#include <harfbuzz/hb.h>
       +#include <harfbuzz/hb-ot.h>
        #include "text-hb.h"
       +#include "ltk.h"
        
        extern Ltk *ltk_global;
        
       t@@ -297,7 +304,6 @@ ltk_load_font(LtkTextManager *tm, char *path)
        uint16_t
        ltk_get_font(LtkTextManager *tm, char *path)
        {
       -        printf("%s\n", path);
                int ret;
                khint_t k;
                uint16_t id;
       t@@ -439,15 +445,6 @@ ltk_create_text_segment(LtkTextManager *tm, uint32_t *text, unsigned int len, ui
                LtkFont *font;
                khash_t(glyphinfo) *glyph_cache;
                khint_t k;
       -        char bob[4];
       -        for (int i = 0; i < len; i++) {
       -                for (int j = 0; j < 3; j++) {
       -                        bob[j] = '\0';
       -                }
       -                u8_wc_toutf8(bob, text[i]);
       -                printf("%s", bob);
       -        }
       -        printf("END\n");
        
                k = kh_get(fontstruct, tm->font_cache, fontid);
                font = kh_value(tm->font_cache, k);
   DIR diff --git a/text-hb.h b/text-hb.h
       t@@ -24,14 +24,12 @@
        #ifndef _TEXT_HB_H_
        #define _TEXT_HB_H_
        
       -#include <X11/Xlib.h>
       -#include <X11/Xutil.h>
       -#include "stb_truetype.h" /* http://nothings.org/stb/stb_truetype.h */
       -#include <fontconfig/fontconfig.h>
       -#include "khash.h"
       -#include <fribidi.h>
       -#include <harfbuzz/hb.h>
       -#include <harfbuzz/hb-ot.h>
       +/*
       +Requires the following includes:
       +<X11/Xlib.h>, <X11/Xutil.h>, "stb_truetype.h",
       +"khash.h", <harfbuzz/hb.h>, <fribidi.h>,
       +<fontconfig/fontconfig.h>
       +*/
        
        typedef struct {
                stbtt_fontinfo info;
       t@@ -106,7 +104,7 @@ KHASH_MAP_INIT_STR(fontid, uint16_t)
        /* font id -> font struct */
        KHASH_MAP_INIT_INT(fontstruct, LtkFont*)
        
       -typedef struct LtkTextManager_ {
       +typedef struct LtkTextManager {
                khash_t(fontid) *font_paths;
                khash_t(fontstruct) *font_cache;
                khash_t(glyphcache) *glyph_cache;