ledit

Text editor (WIP)
git clone git://lumidify.org/ledit.git (fast, but not encrypted)
git clone https://lumidify.org/ledit.git (encrypted, but very slow)
git clone git://4kcetb7mo7hj6grozzybxtotsub5bempzo4lirzc3437amof2c2impyd.onion/ledit.git (over tor)
Log | Files | Refs | README | LICENSE

pango-compat.c (1807B)


      1 #include <pango/pangoxft.h>
      2 
      3 /* FIXME: Is this illegal due to different licenses? */
      4 /* FIXME: Check earliest version of other used functions to get minimum pango version
      5    for ledit as a whole */
      6 /* FIXME: This is just copied from the newer version of pango. It *seems* like
      7    the structs used are public (they're in the documentation), but it does seem
      8    a bit dirty to do this here */
      9 /* This version check is disabled currently because an older version of pango had a 
     10    bug where pango_layout_get_direction didn't work with lines of length 0.
     11    I should actually check when that was changed so I can do a version check for that. */
     12 //#if !PANGO_VERSION_CHECK(1, 46, 0)
     13 #if 1
     14 static PangoLayoutRun *
     15 pango_layout_line_get_run(PangoLayoutLine *line, int index) {
     16 	GSList *run_list;
     17 
     18 	run_list = line->runs;
     19 	while (run_list) {
     20 		PangoLayoutRun *run = run_list->data;
     21 
     22 		if (run->item->offset <= index && run->item->offset + run->item->length > index)
     23 			return run;
     24 
     25 		run_list = run_list->next;
     26 	}
     27 
     28 	return NULL;
     29 }
     30 
     31 static int
     32 pango_layout_line_get_char_level(PangoLayoutLine *line, int index) {
     33 	PangoLayoutRun *run;
     34 
     35 	run = pango_layout_line_get_run(line, index);
     36 
     37 	if (run)
     38 		return run->item->analysis.level;
     39 
     40 	return 0;
     41 }
     42 
     43 static PangoDirection
     44 pango_layout_line_get_char_direction(PangoLayoutLine *layout_line, int index) {
     45 	return pango_layout_line_get_char_level(layout_line, index) % 2
     46 		? PANGO_DIRECTION_RTL
     47 		: PANGO_DIRECTION_LTR;
     48 }
     49 
     50 PangoDirection
     51 ledit_pango_layout_get_direction(PangoLayout *layout, int index) {
     52 	int lineno, x;
     53 	PangoLayoutLine *line;
     54 	pango_layout_index_to_line_x(layout, index, 0, &lineno, &x);
     55 	line = pango_layout_get_line_readonly(layout, lineno);
     56 
     57 	if (line)
     58 		return pango_layout_line_get_char_direction(line, index);
     59 
     60 	return PANGO_DIRECTION_LTR;
     61 }
     62 #endif