parent
0d2caffc2e
commit
ddb942cfbc
@ -0,0 +1,112 @@
|
||||
diff --git a/splashutils-1.5.4.4/docs/theme_format b/splashutils-1.5.4.4/docs/theme_format
|
||||
index 2cc629b..8932583 100644
|
||||
--- a/splashutils-1.5.4.4/docs/theme_format
|
||||
+++ b/splashutils-1.5.4.4/docs/theme_format
|
||||
@@ -91,6 +91,9 @@ that they enclose.
|
||||
* text_y=<n>
|
||||
The y coordinate of the main system message.
|
||||
|
||||
+* text_align [left|middle|right] [top|middle|bottom]
|
||||
+ Text align of the main system message.
|
||||
+
|
||||
* text_size=<n>
|
||||
The size of the font used to render the main system message.
|
||||
|
||||
diff --git a/splashutils-1.5.4.4/src/parse.c b/splashutils-1.5.4.4/src/parse.c
|
||||
index ad7676d..0728419 100644
|
||||
--- a/splashutils-1.5.4.4/src/parse.c
|
||||
+++ b/splashutils-1.5.4.4/src/parse.c
|
||||
@@ -20,7 +20,7 @@
|
||||
struct cfg_opt {
|
||||
char *name;
|
||||
enum {
|
||||
- t_int, t_path, t_box, t_icon, t_rect, t_color, t_fontpath,
|
||||
+ t_int, t_path, t_box, t_icon, t_rect, t_color, t_fontpath, t_align,
|
||||
t_type_open, t_type_close, t_anim, t_text, t_textbox_open, t_textbox_close,
|
||||
} type;
|
||||
void *val;
|
||||
@@ -28,6 +28,7 @@ struct cfg_opt {
|
||||
|
||||
int line = 0;
|
||||
u16 text_x, text_y;
|
||||
+u8 text_align = 0;
|
||||
u16 text_size;
|
||||
color text_color;
|
||||
char *text_font;
|
||||
@@ -147,6 +148,10 @@ struct cfg_opt opts[] =
|
||||
.type = t_fontpath,
|
||||
.val = &text_font },
|
||||
|
||||
+ { .name = "text_align",
|
||||
+ .type = t_align,
|
||||
+ .val = &text_align },
|
||||
+
|
||||
{ .name = "text",
|
||||
.type = t_text,
|
||||
.val = NULL },
|
||||
@@ -216,6 +221,44 @@ static bool skip_nonwhitespace(char **buf, bool req)
|
||||
return true;
|
||||
}
|
||||
|
||||
+static void parse_align(char *t, struct cfg_opt opt)
|
||||
+{
|
||||
+ (*(u8*)opt.val) = 0;
|
||||
+ /* Parse x position */
|
||||
+
|
||||
+ if (!strncmp(t, "left", 4)) {
|
||||
+ (*(u8*)opt.val) |= F_HS_LEFT;
|
||||
+ t += 4;
|
||||
+ } else if (!strncmp(t, "right", 5)) {
|
||||
+ (*(u8*)opt.val) |= F_HS_RIGHT;
|
||||
+ t += 5;
|
||||
+ } else if (!strncmp(t, "middle", 6)) {
|
||||
+ (*(u8*)opt.val) |= F_HS_HMIDDLE;
|
||||
+ t += 6;
|
||||
+ } else {
|
||||
+ parse_error("expected 'left', 'right' or 'middle' instead of '%s'", t);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (!skip_whitespace(&t, true))
|
||||
+ return;
|
||||
+ /* Parse y position */
|
||||
+
|
||||
+ if (!strncmp(t, "top", 3)) {
|
||||
+ (*(u8*)opt.val) |= F_HS_TOP;
|
||||
+ t += 3;
|
||||
+ } else if (!strncmp(t, "bottom", 6)) {
|
||||
+ (*(u8*)opt.val) |= F_HS_BOTTOM;
|
||||
+ t += 6;
|
||||
+ } else if (!strncmp(t, "middle", 6)) {
|
||||
+ (*(u8*)opt.val) |= F_HS_VMIDDLE;
|
||||
+ t += 6;
|
||||
+ } else {
|
||||
+ parse_error("expected 'top', 'bottom' or 'middle' instead of '%s'", t);
|
||||
+ (*(u8*)opt.val) |= F_HS_TOP;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static void parse_int(char *t, struct cfg_opt opt)
|
||||
{
|
||||
if (*t != '=') {
|
||||
@@ -1115,7 +1160,7 @@ void add_main_msg()
|
||||
return;
|
||||
}
|
||||
|
||||
- ct->hotspot = F_HS_LEFT | F_HS_TOP;
|
||||
+ ct->hotspot = text_align;
|
||||
ct->style = TTF_STYLE_NORMAL;
|
||||
ct->x = text_x;
|
||||
ct->y = text_y;
|
||||
@@ -1245,6 +1290,11 @@ int parse_cfg(char *cfgfile, stheme_t *theme)
|
||||
parse_int(t, opts[i]);
|
||||
break;
|
||||
|
||||
+ case t_align:
|
||||
+ skip_whitespace(&t, false);
|
||||
+ parse_align(t, opts[i]);
|
||||
+ break;
|
||||
+
|
||||
case t_box:
|
||||
{
|
||||
box *tbox = parse_box(t);
|
Loading…
Reference in new issue