Improve flipimage(); function, enable pango for item, add rtl lang support

for items with SGR colors
This commit is contained in:
speedie 2023-03-04 19:59:36 +01:00
parent 57f963c9ee
commit c1990916e3
4 changed files with 33 additions and 35 deletions

View file

@ -57,8 +57,9 @@ drawitem(struct item *item, int x, int y, int w)
if (item->text[rd + alen + 2] == 'm') { /* character is 'm' which is the last character in the sequence */ if (item->text[rd + alen + 2] == 'm') { /* character is 'm' which is the last character in the sequence */
buffer[wr] = '\0'; /* clear out character */ buffer[wr] = '\0'; /* clear out character */
rw = pango_item ? TEXTWM(buffer) : TEXTW(buffer) - lrpad; apply_fribidi(buffer);
drw_text(drw, x, y, rw + lp, bh, lp, buffer, 0, pango_item ? True : False); rw = TEXTW(buffer) - lrpad;
drw_text(drw, x, y, rw + lp, bh, lp, isrtl ? fribidi_text : buffer, 0, pango_item ? True : False);
x += rw + lp; x += rw + lp;
ib = 1; ib = 1;

View file

@ -1,15 +1,19 @@
void void
flipimage(void) flipimage(void)
{ {
if (!flip) return; switch (flip) {
if (flip == 1) { /* horizontal */ case 1: /* horizontal */
imlib_image_flip_horizontal(); imlib_image_flip_horizontal();
} else if (flip == 2) { break;
case 2: /* vertical */
imlib_image_flip_vertical(); imlib_image_flip_vertical();
} else if (flip == 3) { break;
case 3: /* diagonal */
imlib_image_flip_diagonal(); imlib_image_flip_diagonal();
} else { break;
flip = 1; default:
flip = flip ? 1 : 0;
return;
} }
} }
@ -27,22 +31,15 @@ cleanupimage(void)
imlib_free_image(); imlib_free_image();
image = NULL; image = NULL;
} }
return;
} }
void void
drawimage(void) drawimage(void)
{ {
#if !USEIMAGE
return;
#endif
int width = 0, height = 0; int width = 0, height = 0;
char *limg = NULL; char *limg = NULL;
if (!lines) return; if (!lines || hideimage) return;
if (hideimage) return;
if (sel && sel->image && strcmp(sel->image, limg ? limg : "")) { if (sel && sel->image && strcmp(sel->image, limg ? limg : "")) {
if (longestedge) if (longestedge)

View file

@ -137,7 +137,7 @@ static char col_sgrcolor14[] = "#00ffff"; /* SGR color #14 */
static char col_sgrcolor15[] = "#ffffff"; /* SGR color #15 */ static char col_sgrcolor15[] = "#ffffff"; /* SGR color #15 */
/* Pango options */ /* Pango options */
static int pango_item = 0; /* Enable support for pango markup for the items */ static int pango_item = 1; /* Enable support for pango markup for the items */
static int pango_highlight = 1; /* Enable support for pango markup for the highlighting */ static int pango_highlight = 1; /* Enable support for pango markup for the highlighting */
static int pango_prompt = 1; /* Enable support for pango markup for the prompt */ static int pango_prompt = 1; /* Enable support for pango markup for the prompt */
static int pango_input = 1; /* Enable support for pango markup for user input */ static int pango_input = 1; /* Enable support for pango markup for user input */

View file

@ -30,7 +30,6 @@
#define USEXINERAMA 0 #define USEXINERAMA 0
#endif #endif
/* include right to left language library */ /* include right to left language library */
#if USERTL #if USERTL
#include <fribidi.h> #include <fribidi.h>
@ -735,7 +734,7 @@ navigatehistfile(int dir)
strncpy(def, text, sizeof(def)); strncpy(def, text, sizeof(def));
} }
switch(dir) { switch (dir) {
case 1: case 1:
if (histpos < histsz - 1) { if (histpos < histsz - 1) {
p = history[++histpos]; p = history[++histpos];
@ -750,6 +749,7 @@ navigatehistfile(int dir)
} }
break; break;
} }
if (p == NULL) { if (p == NULL) {
return; return;
} }