diff --git a/doc/variables.yaml b/doc/variables.yaml index 9625792dd6..d5a6c48a83 100644 --- a/doc/variables.yaml +++ b/doc/variables.yaml @@ -2359,6 +2359,11 @@ values: - (interface) - name: version desc: Git version number. DragonFly only. + - name: vgoto + desc: The next element will be printed at vertical position 'y'. See + also $goto. + args: + - y - name: voffset desc: |- Change vertical offset by N pixels. Negative values will diff --git a/src/conky.cc b/src/conky.cc index b316b18f0e..f218ff3f60 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -982,6 +982,10 @@ static int text_size_updater(char *s, int special_index) { last_font_height += current->arg; } else if (current->type == GOTO) { if (current->arg > cur_x) { w = static_cast(current->arg); } + } else if (current->type == VGOTO) { + if (current->arg > cur_y) { + last_font_height = static_cast(current->arg); + } } else if (current->type == TAB) { int start = current->arg; int step = current->width; @@ -1510,14 +1514,28 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied) { case GOTO: if (current->arg >= 0) { #ifdef BUILD_GUI - cur_x = static_cast(current->arg); + cur_x = static_cast(current->arg) + text_start_x; // make sure shades are 1 pixel to the right of the text if (draw_mode == BG) { cur_x++; } #endif /* BUILD_GUI */ - cur_x = static_cast(current->arg); + cur_x = static_cast(current->arg) + text_start_x; for (auto output : display_outputs()) output->gotox(cur_x); } break; + + case VGOTO: + if (current->arg >= 0) { +#ifdef BUILD_GUI + cur_y = + static_cast(current->arg) + text_start_y + font_ascent(); + // make sure shades are 1 pixel to the bottom of the text + if (draw_mode == BG) cur_y++; +#endif /* BUILD_GUI */ + cur_y = + static_cast(current->arg) + text_start_y + font_ascent(); + for (auto output : display_outputs()) output->gotoy(cur_y); + } + break; } #ifdef BUILD_GUI diff --git a/src/core.cc b/src/core.cc index 99bbffb25e..4027b00536 100644 --- a/src/core.cc +++ b/src/core.cc @@ -1034,6 +1034,9 @@ struct text_object *construct_text_object(char *s, const char *arg, long line, END OBJ_ARG(goto, nullptr, "goto needs arguments") obj->data.l = strtol(arg, nullptr, 10); obj->callbacks.print = &new_goto; + END OBJ_ARG(vgoto, nullptr, "vgoto needs arguments") obj->data.l = + strtol(arg, nullptr, 10); + obj->callbacks.print = &new_vgoto; #ifdef BUILD_GUI END OBJ(tab, nullptr) scan_tab(obj, arg); obj->callbacks.print = &new_tab; diff --git a/src/nvidia.cc b/src/nvidia.cc index 48c5083ed5..3c4b83f5fd 100644 --- a/src/nvidia.cc +++ b/src/nvidia.cc @@ -315,6 +315,7 @@ const char *translate_nvidia_special_type[] = { "", // SAVE_COORDINATES "", // FONT "", // GOTO + "", // VGOTO "" // TAB }; diff --git a/src/specials.cc b/src/specials.cc index 133193cac9..fb46e208dc 100644 --- a/src/specials.cc +++ b/src/specials.cc @@ -794,6 +794,11 @@ void new_goto(struct text_object *obj, char *p, unsigned int p_max_size) { new_special(p, GOTO)->arg = dpi_scale(obj->data.l); } +void new_vgoto(struct text_object *obj, char *p, unsigned int p_max_size) { + if (p_max_size == 0) { return; } + new_special(p, VGOTO)->arg = dpi_scale(obj->data.l); +} + void scan_tab(struct text_object *obj, const char *arg) { struct tab *t; diff --git a/src/specials.h b/src/specials.h index 513b43f7a8..cac55ff581 100644 --- a/src/specials.h +++ b/src/specials.h @@ -57,6 +57,7 @@ enum special_types { SAVE_COORDINATES, FONT, GOTO, + VGOTO, TAB }; @@ -115,6 +116,7 @@ void new_save_coordinates(struct text_object *, char *, unsigned int); void new_alignr(struct text_object *, char *, unsigned int); void new_alignc(struct text_object *, char *, unsigned int); void new_goto(struct text_object *, char *, unsigned int); +void new_vgoto(struct text_object *, char *, unsigned int); void new_tab(struct text_object *, char *, unsigned int); void clear_stored_graphs();