URI:
       ttheme.c - ledit - Text editor (WIP)
  HTML git clone git://lumidify.org/ledit.git (fast, but not encrypted)
  HTML git clone https://lumidify.org/git/ledit.git (encrypted, but very slow)
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       ttheme.c (2666B)
       ---
            1 #include <stddef.h>
            2 
            3 #include <X11/Xlib.h>
            4 #include <X11/Xft/Xft.h>
            5 
            6 #include "memory.h"
            7 #include "common.h"
            8 #include "theme.h"
            9 #include "theme_config.h"
           10 
           11 ledit_theme *
           12 theme_create(ledit_common *common) {
           13         ledit_theme *theme = ledit_malloc(sizeof(ledit_theme));
           14         theme->scrollbar_width = SCROLLBAR_WIDTH;
           15         theme->scrollbar_step = SCROLLBAR_STEP;
           16         theme->text_font = TEXT_FONT;
           17         theme->text_size = TEXT_SIZE;
           18         theme->text_fg_hex = TEXT_FG;
           19         theme->text_bg_hex = TEXT_BG;
           20         theme->cursor_fg_hex = CURSOR_FG;
           21         theme->cursor_bg_hex = CURSOR_BG;
           22         theme->selection_fg_hex = SELECTION_FG;
           23         theme->selection_bg_hex = SELECTION_BG;
           24         theme->bar_fg_hex = BAR_FG;
           25         theme->bar_bg_hex = BAR_BG;
           26         theme->bar_cursor_hex = BAR_CURSOR;
           27         theme->scrollbar_fg_hex = SCROLLBAR_FG;
           28         theme->scrollbar_bg_hex = SCROLLBAR_BG;
           29         XftColorAllocName(common->dpy, common->vis, common->cm, TEXT_FG, &theme->text_fg);
           30         XftColorAllocName(common->dpy, common->vis, common->cm, TEXT_BG, &theme->text_bg);
           31         XftColorAllocName(common->dpy, common->vis, common->cm, CURSOR_FG, &theme->cursor_fg);
           32         XftColorAllocName(common->dpy, common->vis, common->cm, CURSOR_BG, &theme->cursor_bg);
           33         XftColorAllocName(common->dpy, common->vis, common->cm, SELECTION_FG, &theme->selection_fg);
           34         XftColorAllocName(common->dpy, common->vis, common->cm, SELECTION_BG, &theme->selection_bg);
           35         XftColorAllocName(common->dpy, common->vis, common->cm, BAR_FG, &theme->bar_fg);
           36         XftColorAllocName(common->dpy, common->vis, common->cm, BAR_BG, &theme->bar_bg);
           37         XftColorAllocName(common->dpy, common->vis, common->cm, BAR_CURSOR, &theme->bar_cursor);
           38         XftColorAllocName(common->dpy, common->vis, common->cm, SCROLLBAR_FG, &theme->scrollbar_fg);
           39         XftColorAllocName(common->dpy, common->vis, common->cm, SCROLLBAR_BG, &theme->scrollbar_bg);
           40         return theme;
           41 }
           42 
           43 void
           44 theme_destroy(ledit_common *common, ledit_theme *theme) {
           45         XftColorFree(common->dpy, common->vis, common->cm, &theme->text_fg);
           46         XftColorFree(common->dpy, common->vis, common->cm, &theme->text_bg);
           47         XftColorFree(common->dpy, common->vis, common->cm, &theme->cursor_fg);
           48         XftColorFree(common->dpy, common->vis, common->cm, &theme->cursor_bg);
           49         XftColorFree(common->dpy, common->vis, common->cm, &theme->selection_fg);
           50         XftColorFree(common->dpy, common->vis, common->cm, &theme->selection_bg);
           51         XftColorFree(common->dpy, common->vis, common->cm, &theme->bar_fg);
           52         XftColorFree(common->dpy, common->vis, common->cm, &theme->bar_bg);
           53         XftColorFree(common->dpy, common->vis, common->cm, &theme->bar_cursor);
           54         XftColorFree(common->dpy, common->vis, common->cm, &theme->scrollbar_fg);
           55         XftColorFree(common->dpy, common->vis, common->cm, &theme->scrollbar_bg);
           56         free(theme);
           57 }