URI: 
       ttextedit_wip.h - ltkx - GUI toolkit for X11 (WIP)
  HTML git clone git://lumidify.org/ltkx.git
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       ttextedit_wip.h (3097B)
       ---
            1 /*
            2  * This file is part of the Lumidify ToolKit (LTK)
            3  * Copyright (c) 2020 lumidify <nobody@lumidify.org>
            4  *
            5  * Permission is hereby granted, free of charge, to any person obtaining a copy
            6  * of this software and associated documentation files (the "Software"), to deal
            7  * in the Software without restriction, including without limitation the rights
            8  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
            9  * copies of the Software, and to permit persons to whom the Software is
           10  * furnished to do so, subject to the following conditions:
           11  *
           12  * The above copyright notice and this permission notice shall be included in all
           13  * copies or substantial portions of the Software.
           14  *
           15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
           16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
           17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
           18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
           19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
           20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
           21  * SOFTWARE.
           22  */
           23 
           24 #ifndef _TEXT_HB_H_
           25 #define _TEXT_HB_H_
           26 
           27 /*
           28 Requires the following includes:
           29 <X11/Xlib.h>, <X11/Xutil.h>, "stb_truetype.h",
           30 "khash.h", <harfbuzz/hb.h>, <fribidi.h>,
           31 <fontconfig/fontconfig.h>
           32 */
           33 
           34 #include "gap_buffer.h"
           35 #include "array.h"
           36 #include "stack.h"
           37 
           38 /* Note: hb_script_t and FriBidiLevel are really just uint32_t's, but
           39    I'm not sure if I should rely on that, so they're separate here */
           40 LTK_GAP_BUFFER_INIT_DECL(uint32, uint32_t)
           41 LTK_GAP_BUFFER_INIT_DECL(script, hb_script_t)
           42 LTK_GAP_BUFFER_INIT_DECL(int, int)
           43 LTK_ARRAY_INIT_DECL(level, FriBidiLevel)
           44 LTK_ARRAY_INIT_DECL(int, int)
           45 LTK_STACK_INIT_DECL(script, int, hb_script_t, pair_index, script);
           46 
           47 struct ltk_text_run {
           48         LtkGlyph *glyphs;
           49         unsigned int num_glyphs;
           50         struct ltk_text_run *next;
           51         struct ltk_text_run *last;
           52         size_t start_index;
           53         size_t len;
           54         int start_x;
           55         int start_y;
           56         int w;
           57         LtkFont *font;
           58         uint16_t font_id;
           59         hb_script_t script;
           60         hb_direction_t dir;
           61 }
           62 
           63 struct ltk_text_line {
           64         struct ltk_gap_buffer_uint32 *log_buf; /* buffer of the logical text */
           65         struct ltk_gap_buffer_script *scripts;
           66         struct ltk_gap_buffer_uint32 *vis_buf; /* buffer of visual text */
           67         struct ltk_gap_buffer_int *log2vis;
           68         struct ltk_gap_buffer_int *vis2log;
           69         struct ltk_array_level *bidi_levels;
           70         struct ltk_text_run *first_run; /* first node in the linked list of runs */
           71         struct ltk_text_run *last_run; /* last node in the linked list of runs */
           72         struct ltk_text_run *cur_run; /* current node in the linked list of runs */
           73         struct ltk_text_line *next; /* next text line in the buffer */
           74         unsigned int height; /* height of the line (including wrapping) */
           75         FribidiCharType dir; /* overall paragraph direction */
           76         struct ltk_array_int *wrap_indeces;
           77         size_t len;
           78         uint16_t font_size;
           79         int y_max;
           80         int y_min;
           81         int w;
           82         int h;
           83         XImage *img;
           84 };
           85 
           86 struct ltk_text_buffer {
           87         struct ltk_text_line *head;
           88         struct ltk_text_line *cur_line;
           89         unsigned int line_gap;
           90 };