URI: 
       tStandardize some type names - ltk - Socket-based GUI for X11 (WIP)
  HTML git clone git://lumidify.org/ltk.git (fast, but not encrypted)
  HTML git clone https://lumidify.org/git/ltk.git (encrypted, but very slow)
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit b942851b8d877294a2efc68efa8447b4d580cd7f
   DIR parent 75115e459d76c7f38fe5e743f90b2c4f0d21055a
  HTML Author: lumidify <nobody@lumidify.org>
       Date:   Mon, 22 Feb 2021 20:01:43 +0100
       
       Standardize some type names
       
       Diffstat:
         M button.c                            |      24 ++++++++++++------------
         M button.h                            |       2 +-
         M color.c                             |       2 +-
         M color.h                             |       4 ++--
         M label.c                             |       4 ++--
         M label.h                             |       2 +-
         M ltk.h                               |       4 ++--
         M scrollbar.c                         |      14 +++++++-------
         M text.h                              |      14 +++++++-------
         M text_pango.c                        |      16 ++++++++--------
         M text_stb.c                          |     102 ++++++++++++++++----------------
       
       11 files changed, 94 insertions(+), 94 deletions(-)
       ---
   DIR diff --git a/button.c b/button.c
       t@@ -55,20 +55,20 @@ static struct ltk_widget_vtable vtable = {
        
        static struct {
                int border_width;
       -        LtkColor text_color;
       +        ltk_color text_color;
                int pad;
        
       -        LtkColor border;
       -        LtkColor fill;
       +        ltk_color border;
       +        ltk_color fill;
        
       -        LtkColor border_pressed;
       -        LtkColor fill_pressed;
       +        ltk_color border_pressed;
       +        ltk_color fill_pressed;
        
       -        LtkColor border_active;
       -        LtkColor fill_active;
       +        ltk_color border_active;
       +        ltk_color fill_active;
        
       -        LtkColor border_disabled;
       -        LtkColor fill_disabled;
       +        ltk_color border_disabled;
       +        ltk_color fill_disabled;
        } theme;
        
        /* FIXME: do this more efficiently (don't create color twice if
       t@@ -154,8 +154,8 @@ ltk_button_redraw_pixmap(ltk_button *button) {
                ltk_window *window = button->widget.window;
                ltk_rect rect = button->widget.rect;
                int bw = theme.border_width;
       -        LtkColor *border;
       -        LtkColor *fill;
       +        ltk_color *border;
       +        ltk_color *fill;
                switch (button->widget.state) {
                case LTK_NORMAL:
                        border = &theme.border;
       t@@ -220,7 +220,7 @@ ltk_button_resize(ltk_widget *self) {
        static void
        ltk_button_change_state(ltk_widget *self) {
                ltk_button *button = (ltk_button *)self;
       -        LtkColor *fill;
       +        ltk_color *fill;
                switch (button->widget.state) {
                case LTK_NORMAL:
                        fill = &theme.fill;
   DIR diff --git a/button.h b/button.h
       t@@ -28,7 +28,7 @@
        
        typedef struct {
                ltk_widget widget;
       -        LtkTextLine *tl;
       +        ltk_text_line *tl;
                Pixmap pixmap;
        } ltk_button;
        
   DIR diff --git a/color.c b/color.c
       t@@ -6,7 +6,7 @@
        #include "color.h"
        
        void
       -ltk_color_create(Display *dpy, int screen, Colormap cm, const char *hex, LtkColor *col) {
       +ltk_color_create(Display *dpy, int screen, Colormap cm, const char *hex, ltk_color *col) {
                if (!XParseColor(dpy, cm, hex, &col->xcolor)) {
                        /* FIXME: better error reporting!!! */
                        ltk_fatal("ltk_color_create");
   DIR diff --git a/color.h b/color.h
       t@@ -10,8 +10,8 @@ typedef struct {
                #if USE_PANGO == 1
                XftColor xftcolor;
                #endif
       -} LtkColor;
       +} ltk_color;
        
       -void ltk_color_create(Display *dpy, int screen, Colormap cm, const char *hex, LtkColor *col);
       +void ltk_color_create(Display *dpy, int screen, Colormap cm, const char *hex, ltk_color *col);
        
        #endif /* _LTK_COLOR_H_ */
   DIR diff --git a/label.c b/label.c
       t@@ -48,8 +48,8 @@ static struct ltk_widget_vtable vtable = {
        };
        
        static struct {
       -        LtkColor text_color;
       -        LtkColor bg_color;
       +        ltk_color text_color;
       +        ltk_color bg_color;
                int pad;
        } theme;
        
   DIR diff --git a/label.h b/label.h
       t@@ -28,7 +28,7 @@
        
        typedef struct {
                ltk_widget widget;
       -        LtkTextLine *tl;
       +        ltk_text_line *tl;
                Pixmap text_pixmap;
        } ltk_label;
        
   DIR diff --git a/ltk.h b/ltk.h
       t@@ -118,8 +118,8 @@ typedef struct {
                int border_width;
                uint16_t font_size;
                char *font;
       -        LtkColor fg;
       -        LtkColor bg;
       +        ltk_color fg;
       +        ltk_color bg;
        } ltk_window_theme;
        
        struct ltk_event_queue {
   DIR diff --git a/scrollbar.c b/scrollbar.c
       t@@ -50,12 +50,12 @@ static struct ltk_widget_vtable vtable = {
        
        static struct {
                int size; /* width or height, depending on orientation */
       -        LtkColor bg_normal;
       -        LtkColor bg_disabled;
       -        LtkColor fg_normal;
       -        LtkColor fg_active;
       -        LtkColor fg_pressed;
       -        LtkColor fg_disabled;
       +        ltk_color bg_normal;
       +        ltk_color bg_disabled;
       +        ltk_color fg_normal;
       +        ltk_color fg_active;
       +        ltk_color fg_pressed;
       +        ltk_color fg_disabled;
        } theme;
        
        void
       t@@ -115,7 +115,7 @@ static void
        ltk_scrollbar_draw(ltk_widget *self, ltk_rect clip) {
                (void)clip; /* FIXME: actually use this */
                ltk_scrollbar *scrollbar = (ltk_scrollbar *)self;
       -        LtkColor *bg, *fg;
       +        ltk_color *bg, *fg;
                int handle_x, handle_y, handle_w, handle_h;
                ltk_window *window = scrollbar->widget.window;
                ltk_rect rect = scrollbar->widget.rect;
   DIR diff --git a/text.h b/text.h
       t@@ -3,16 +3,16 @@
        
        #include "color.h"
        
       -typedef struct LtkTextLine LtkTextLine;
       +typedef struct ltk_text_line ltk_text_line;
        
        void ltk_init_text(const char *default_font, Display *dpy, int screen, Colormap cm);
        void ltk_cleanup_text(void);
       -LtkTextLine *ltk_text_line_create(Window window, uint16_t font_size, char *text, int width);
       -void ltk_text_line_render(LtkTextLine *tl, LtkColor *bg, LtkColor *fg);
       -void ltk_text_line_draw(LtkTextLine *tl, Drawable d, GC gc, int x, int y, ltk_rect clip);
       -void ltk_text_line_set_width(LtkTextLine *tl, int width);
       -void ltk_text_line_get_size(LtkTextLine *tl, int *w, int *h);
       -void ltk_text_line_destroy(LtkTextLine *tl);
       +ltk_text_line *ltk_text_line_create(Window window, uint16_t font_size, char *text, int width);
       +void ltk_text_line_render(ltk_text_line *tl, ltk_color *bg, ltk_color *fg);
       +void ltk_text_line_draw(ltk_text_line *tl, Drawable d, GC gc, int x, int y, ltk_rect clip);
       +void ltk_text_line_set_width(ltk_text_line *tl, int width);
       +void ltk_text_line_get_size(ltk_text_line *tl, int *w, int *h);
       +void ltk_text_line_destroy(ltk_text_line *tl);
        
        #if USE_PANGO == 1
          #include <pango/pangoxft.h>
   DIR diff --git a/text_pango.c b/text_pango.c
       t@@ -16,7 +16,7 @@
        #include "util.h"
        #include "text.h"
        
       -struct LtkTextLine {
       +struct ltk_text_line {
                char *text;
                uint16_t font_size;
                int w;
       t@@ -53,17 +53,17 @@ ltk_cleanup_text(void) {
        }
        
        void
       -ltk_text_line_set_width(LtkTextLine *tl, int width) {
       +ltk_text_line_set_width(ltk_text_line *tl, int width) {
                (void)tl;
                (void)width;
                /* TODO: Implement! */
        }
        
       -LtkTextLine *
       +ltk_text_line *
        ltk_text_line_create(Window window, uint16_t font_size, char *text, int width) {
                if (!tm.context)
                        ltk_fatal("ltk_text_line_create (pango): text not initialized yet");
       -        LtkTextLine *line = ltk_malloc(sizeof(LtkTextLine));
       +        ltk_text_line *line = ltk_malloc(sizeof(ltk_text_line));
                line->text = text;
                line->font_size = font_size;
                line->layout = pango_layout_new(tm.context);
       t@@ -94,25 +94,25 @@ ltk_text_line_create(Window window, uint16_t font_size, char *text, int width) {
        }
        
        void
       -ltk_text_line_render(LtkTextLine *tl, LtkColor *bg, LtkColor *fg) {
       +ltk_text_line_render(ltk_text_line *tl, ltk_color *bg, ltk_color *fg) {
                XftDrawRect(tl->draw, &bg->xftcolor, 0, 0, tl->w, tl->h);
                pango_xft_render_layout(tl->draw, &fg->xftcolor, tl->layout, 0, 0);
        }
        
        void
       -ltk_text_line_draw(LtkTextLine *tl, Drawable d, GC gc, int x, int y, ltk_rect clip) {
       +ltk_text_line_draw(ltk_text_line *tl, Drawable d, GC gc, int x, int y, ltk_rect clip) {
                (void)clip; /* FIXME: use this */
                XCopyArea(tm.dpy, tl->pixmap, d, gc, 0, 0, tl->w, tl->h, x, y);
        }
        
        void
       -ltk_text_line_get_size(LtkTextLine *tl, int *w, int *h) {
       +ltk_text_line_get_size(ltk_text_line *tl, int *w, int *h) {
                *w = tl->w;
                *h = tl->h;
        }
        
        void
       -ltk_text_line_destroy(LtkTextLine *tl) {
       +ltk_text_line_destroy(ltk_text_line *tl) {
                g_object_unref(tl->layout);
                XftDrawDestroy(tl->draw);
                XFreePixmap(tm.dpy, tl->pixmap);
   DIR diff --git a/text_stb.c b/text_stb.c
       t@@ -47,7 +47,7 @@ typedef struct {
                int index; /* index in font file */
                uint16_t id;
                unsigned int refs;
       -} LtkFont;
       +} ltk_font;
        
        /* Contains general info on glyphs that doesn't change regardless of the context */
        typedef struct {
       t@@ -60,20 +60,20 @@ typedef struct {
                unsigned int refs;
                /* FIXME: does refs need to be long? It could cause problems if a
                program tries to cache/"keep alive" a lot of pages of text. */
       -} LtkGlyphInfo;
       +} ltk_glyph_info;
        
        /* Contains glyph info specific to one run of text */
        typedef struct {
       -        LtkGlyphInfo *info;
       +        ltk_glyph_info *info;
                int x;
                int y;
       -} LtkGlyph;
       +} ltk_glyph;
        
       -struct LtkTextLine {
       +struct ltk_text_line {
                Window window;
                XImage *img;
                char *text;
       -        LtkGlyph *glyphs;
       +        ltk_glyph *glyphs;
                size_t glyph_len;
                uint16_t font_size;
                int w;
       t@@ -84,17 +84,17 @@ struct LtkTextLine {
        
        /* Hash definitions */
        /* glyph id -> glyph info struct */
       -KHASH_MAP_INIT_INT(glyphinfo, LtkGlyphInfo*)
       +KHASH_MAP_INIT_INT(glyphinfo, ltk_glyph_info*)
        /* font path, size -> glyph cache hash */
        KHASH_MAP_INIT_INT(glyphcache, khash_t(glyphinfo)*)
        
        static struct {
                khash_t(glyphcache) *glyph_cache;
       -        LtkFont **fonts;
       +        ltk_font **fonts;
                int num_fonts;
                int fonts_bufsize;
                FcPattern *fcpattern;
       -        LtkFont *default_font;
       +        ltk_font *default_font;
                uint16_t font_id_cur;
                Display *dpy;
                int screen;
       t@@ -102,25 +102,25 @@ static struct {
        } tm = {NULL, NULL, 0, 0, NULL, NULL, 1, NULL, 0, 0};
        
        
       -static LtkFont *ltk_get_font(char *path, int index);
       -static LtkGlyphInfo *ltk_create_glyph_info(LtkFont *font, int id,
       +static ltk_font *ltk_get_font(char *path, int index);
       +static ltk_glyph_info *ltk_create_glyph_info(ltk_font *font, int id,
            float scale);
       -static void ltk_destroy_glyph_info(LtkGlyphInfo *gi);
       -static LtkGlyphInfo *ltk_get_glyph_info(LtkFont *font, int id,
       +static void ltk_destroy_glyph_info(ltk_glyph_info *gi);
       +static ltk_glyph_info *ltk_get_glyph_info(ltk_font *font, int id,
            float scale, khash_t(glyphinfo) *cache);
        static khash_t(glyphinfo) *ltk_get_glyph_cache(uint16_t font_id,
            uint16_t font_size);
        static khint_t ltk_create_glyph_cache(uint16_t font_id, uint16_t font_size);
        static void ltk_destroy_glyph_cache(khash_t(glyphinfo) *cache);
        static void ltk_load_default_font(const char *name);
       -static LtkFont *ltk_create_font(char *path, uint16_t id, int index);
       -static void ltk_destroy_font(LtkFont *font);
       -static LtkFont *ltk_load_font(char *path, int index);
       -static LtkFont *ltk_get_font(char *path, int index);
       -static void ltk_text_to_glyphs(LtkGlyph *glyphs, int num_glyphs, char *text,
       +static ltk_font *ltk_create_font(char *path, uint16_t id, int index);
       +static void ltk_destroy_font(ltk_font *font);
       +static ltk_font *ltk_load_font(char *path, int index);
       +static ltk_font *ltk_get_font(char *path, int index);
       +static void ltk_text_to_glyphs(ltk_glyph *glyphs, int num_glyphs, char *text,
            uint16_t font_size, int *x_min, int *y_min, int *x_max, int *y_max);
       -static void ltk_text_line_create_glyphs(LtkTextLine *tl);
       -static void ltk_text_line_draw_glyph(LtkGlyph *glyph, int xoff, int yoff,
       +static void ltk_text_line_create_glyphs(ltk_text_line *tl);
       +static void ltk_text_line_draw_glyph(ltk_glyph *glyph, int xoff, int yoff,
            XImage *img, XColor fg);
        static XImage *ltk_create_ximage(int w, int h, int depth, XColor bg);
        
       t@@ -203,7 +203,7 @@ void
        ltk_init_text(const char *default_font, Display *dpy, int screen, Colormap cm) {
                tm.fonts_bufsize = 1;
                tm.glyph_cache = kh_init(glyphcache);
       -        tm.fonts = ltk_malloc(sizeof(LtkFont *));
       +        tm.fonts = ltk_malloc(sizeof(ltk_font *));
                ltk_load_default_font(default_font);
                tm.dpy = dpy;
                tm.screen = screen;
       t@@ -224,9 +224,9 @@ ltk_cleanup_text(void) {
                kh_destroy(glyphcache, tm.glyph_cache);
        }
        
       -static LtkGlyphInfo *
       -ltk_create_glyph_info(LtkFont *font, int id, float scale) {
       -        LtkGlyphInfo *glyph = ltk_malloc(sizeof(LtkGlyphInfo));
       +static ltk_glyph_info *
       +ltk_create_glyph_info(ltk_font *font, int id, float scale) {
       +        ltk_glyph_info *glyph = ltk_malloc(sizeof(ltk_glyph_info));
        
                glyph->id = id;
                glyph->refs = 0;
       t@@ -239,16 +239,16 @@ ltk_create_glyph_info(LtkFont *font, int id, float scale) {
        }
        
        static void
       -ltk_destroy_glyph_info(LtkGlyphInfo *gi) {
       +ltk_destroy_glyph_info(ltk_glyph_info *gi) {
                ltk_free(gi->alphamap);
                ltk_free(gi);
        }
        
       -static LtkGlyphInfo *
       -ltk_get_glyph_info(LtkFont *font, int id, float scale, khash_t(glyphinfo) *cache) {
       +static ltk_glyph_info *
       +ltk_get_glyph_info(ltk_font *font, int id, float scale, khash_t(glyphinfo) *cache) {
                int ret;
                khint_t k;
       -        LtkGlyphInfo *glyph;
       +        ltk_glyph_info *glyph;
                k = kh_get(glyphinfo, cache, id);
                if (k == kh_end(cache)) {
                        glyph = ltk_create_glyph_info(font, id, scale);
       t@@ -318,10 +318,10 @@ ltk_load_default_font(const char *name) {
                FcPatternDestroy(match);
        }
        
       -static LtkFont *
       +static ltk_font *
        ltk_create_font(char *path, uint16_t id, int index) {
                unsigned long len;
       -        LtkFont *font = ltk_malloc(sizeof(LtkFont));
       +        ltk_font *font = ltk_malloc(sizeof(ltk_font));
                char *contents = ltk_read_file(path, &len);
                if (!contents)
                        ltk_fatal_errno("Unable to read font file %s\n", path);
       t@@ -337,16 +337,16 @@ ltk_create_font(char *path, uint16_t id, int index) {
        }
        
        static void
       -ltk_destroy_font(LtkFont *font) {
       +ltk_destroy_font(ltk_font *font) {
                ltk_free(font->info.data);
                ltk_free(font);
        }
        
       -static LtkFont *
       +static ltk_font *
        ltk_load_font(char *path, int index) {
       -        LtkFont *font = ltk_create_font(path, tm.font_id_cur++, index);
       +        ltk_font *font = ltk_create_font(path, tm.font_id_cur++, index);
                if (tm.num_fonts == tm.fonts_bufsize) {
       -                LtkFont **new = ltk_realloc(tm.fonts, tm.fonts_bufsize * 2 * sizeof(LtkFont *));
       +                ltk_font **new = ltk_realloc(tm.fonts, tm.fonts_bufsize * 2 * sizeof(ltk_font *));
                        tm.fonts = new;
                        tm.fonts_bufsize *= 2;
                }
       t@@ -355,9 +355,9 @@ ltk_load_font(char *path, int index) {
                return font;
        }
        
       -static LtkFont *
       +static ltk_font *
        ltk_get_font(char *path, int index) {
       -        LtkFont *font = NULL;
       +        ltk_font *font = NULL;
                for (int i = 0; i < tm.num_fonts; i++) {
                        if (tm.fonts[i]->index == index &&
                            strcmp(tm.fonts[i]->path, path) == 0) {
       t@@ -371,7 +371,7 @@ ltk_get_font(char *path, int index) {
        }
        
        static void
       -ltk_text_to_glyphs(LtkGlyph *glyphs, int num_glyphs, char *text, uint16_t font_size,
       +ltk_text_to_glyphs(ltk_glyph *glyphs, int num_glyphs, char *text, uint16_t font_size,
            int *x_min, int *y_min, int *x_max, int *y_max) {
                uint32_t c1, c2 = 0;
                int gid;
       t@@ -383,9 +383,9 @@ ltk_text_to_glyphs(LtkGlyph *glyphs, int num_glyphs, char *text, uint16_t font_s
                float scale;
                int ascent, descent, line_gap;
                *x_min = INT_MAX, *x_max = INT_MIN, *y_min = INT_MAX, *y_max = INT_MIN;
       -        LtkGlyphInfo *ginfo;
       +        ltk_glyph_info *ginfo;
        
       -        LtkFont *font = tm.default_font;
       +        ltk_font *font = tm.default_font;
                khash_t(glyphinfo) *glyph_cache = ltk_get_glyph_cache(font->id, font_size);
        
                scale = stbtt_ScaleForPixelHeight(&font->info, font_size);
       t@@ -489,7 +489,7 @@ ltk_create_ximage(int w, int h, int depth, XColor bg) {
        
        /* based on http://codemadness.org/git/dwm-font/file/drw.c.html#l315 */
        static void
       -ltk_text_line_draw_glyph(LtkGlyph *glyph, int xoff, int yoff, XImage *img, XColor fg) {
       +ltk_text_line_draw_glyph(ltk_glyph *glyph, int xoff, int yoff, XImage *img, XColor fg) {
                int x = glyph->x + xoff;
                int y = glyph->y + yoff;
                double a;
       t@@ -510,9 +510,9 @@ ltk_text_line_draw_glyph(LtkGlyph *glyph, int xoff, int yoff, XImage *img, XColo
        
        void
        ltk_text_line_render(
       -        LtkTextLine *tl,
       -        LtkColor *bg,
       -        LtkColor *fg)
       +        ltk_text_line *tl,
       +        ltk_color *bg,
       +        ltk_color *fg)
        {
                XWindowAttributes attrs;
                XGetWindowAttributes(tm.dpy, tl->window, &attrs);
       t@@ -528,7 +528,7 @@ ltk_text_line_render(
        
        /* FIXME: error checking if img is rendered yet, tm initialized, etc. */
        void
       -ltk_text_line_draw(LtkTextLine *tl, Drawable d, GC gc, int x, int y, ltk_rect clip) {
       +ltk_text_line_draw(ltk_text_line *tl, Drawable d, GC gc, int x, int y, ltk_rect clip) {
                (void)clip;
                /*
                int xoff = clip.x - x;
       t@@ -543,20 +543,20 @@ ltk_text_line_draw(LtkTextLine *tl, Drawable d, GC gc, int x, int y, ltk_rect cl
        }
        
        void
       -ltk_text_line_set_width(LtkTextLine *tl, int width) {
       +ltk_text_line_set_width(ltk_text_line *tl, int width) {
                (void)tl;
                (void)width;
                /* FIXME: implement */
        }
        
        void
       -ltk_text_line_get_size(LtkTextLine *tl, int *w, int *h) {
       +ltk_text_line_get_size(ltk_text_line *tl, int *w, int *h) {
                *w = tl->w;
                *h = tl->h;
        }
        
        static void
       -ltk_text_line_create_glyphs(LtkTextLine *tl) {
       +ltk_text_line_create_glyphs(ltk_text_line *tl) {
                int x_min, x_max, y_min, y_max;
                ltk_text_to_glyphs(tl->glyphs, tl->glyph_len, tl->text, tl->font_size,
                    &x_min, &y_min, &x_max, &y_max);
       t@@ -567,22 +567,22 @@ ltk_text_line_create_glyphs(LtkTextLine *tl) {
                tl->h = y_max - y_min;
        }
        
       -LtkTextLine *
       +ltk_text_line *
        ltk_text_line_create(Window window, uint16_t font_size, char *text, int width) {
                (void)width;
       -        LtkTextLine *line = ltk_malloc(sizeof(LtkTextLine));
       +        ltk_text_line *line = ltk_malloc(sizeof(ltk_text_line));
                line->window = window;
                line->img = NULL;
                line->text = text;
                line->glyph_len = u8_strlen(text);
       -        line->glyphs = ltk_malloc(line->glyph_len * sizeof(LtkGlyph));
       +        line->glyphs = ltk_malloc(line->glyph_len * sizeof(ltk_glyph));
                line->font_size = font_size;
                ltk_text_line_create_glyphs(line);
                return line;
        }
        
        void
       -ltk_text_line_destroy(LtkTextLine *tl) {
       +ltk_text_line_destroy(ltk_text_line *tl) {
                ltk_free(tl->text);
                /* FIXME: Reference count glyph infos */
                ltk_free(tl->glyphs);