1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-27 04:32:55 +00:00

tests for issue 236

This commit is contained in:
Syco 2021-01-29 23:25:58 +00:00 committed by Brenden Matthews
parent d06649ec52
commit bea6a5cb9b
7 changed files with 37 additions and 0 deletions

View File

@ -1015,6 +1015,16 @@ static int draw_mode; /* FG, BG or OUTLINE */
#ifdef BUILD_X11
static long current_color;
static int saved_coordinates_x[100];
static int saved_coordinates_y[100];
int get_saved_coordinates_x(int i) {
return saved_coordinates_x[i];
}
int get_saved_coordinates_y(int i) {
return saved_coordinates_y[i];
}
static int text_size_updater(char *s, int special_index) {
int w = 0;
char *p;
@ -1597,6 +1607,11 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied) {
cur_y += current->arg;
break;
case SAVE_COORDINATES:
saved_coordinates_x[static_cast<int>(current->arg)] = cur_x - text_start_x;
saved_coordinates_y[static_cast<int>(current->arg)] = cur_y + text_start_y - last_font_height;
break;
case TAB: {
int start = current->arg;
int step = current->width;

View File

@ -301,6 +301,9 @@ void set_updatereset(int);
int get_updatereset(void);
int get_total_updates(void);
int get_saved_coordinates_x(int);
int get_saved_coordinates_y(int);
/* defined in conky.c */
int spaced_print(char *, int, const char *, int, ...)
__attribute__((format(printf, 3, 5)));

View File

@ -1011,6 +1011,8 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
obj->callbacks.print = &new_offset;
END OBJ(voffset, nullptr) obj->data.l = arg != nullptr ? atoi(arg) : 1;
obj->callbacks.print = &new_voffset;
END OBJ(save_coordinates, nullptr) obj->data.l = arg != nullptr ? atoi(arg) : 0;
obj->callbacks.print = &new_save_coordinates;
END OBJ_ARG(goto, nullptr, "goto needs arguments") obj->data.l = atoi(arg);
obj->callbacks.print = &new_goto;
#ifdef BUILD_X11

View File

@ -148,6 +148,15 @@ void cimlib_add_image(const char *args) {
tmp += 3;
if (sscanf(tmp, "%d", &cur->flush_interval) != 0) { cur->no_cache = 0; }
}
tmp = strstr(args, "-i ");
if (tmp != nullptr) {
tmp += 3;
int i;
if (sscanf(tmp, "%d", &i) == 1) {
cur->x = get_saved_coordinates_x(i);
cur->y = get_saved_coordinates_y(i);
}
}
if (cur->flush_interval < 0) {
NORM_ERR("Imlib2: flush interval should be >= 0");
cur->flush_interval = 0;

View File

@ -310,6 +310,7 @@ const char *translate_nvidia_special_type[] = {
"nvidiagraph", // GRAPH
"", // OFFSET
"", // VOFFSET
"", // SAVE_COORDINATES
"", // FONT
"", // GOTO
"" // TAB

View File

@ -749,6 +749,11 @@ void new_voffset(struct text_object *obj, char *p, unsigned int p_max_size) {
new_special(p, VOFFSET)->arg = obj->data.l;
}
void new_save_coordinates(struct text_object *obj, char *p, unsigned int p_max_size) {
if (p_max_size == 0) { return; }
new_special(p, SAVE_COORDINATES)->arg = obj->data.l;
}
void new_alignr(struct text_object *obj, char *p, unsigned int p_max_size) {
if (p_max_size == 0) { return; }
new_special(p, ALIGNR)->arg = obj->data.l;

View File

@ -51,6 +51,7 @@ enum special_types {
GRAPH,
OFFSET,
VOFFSET,
SAVE_COORDINATES,
FONT,
GOTO,
TAB
@ -105,6 +106,7 @@ void new_bg(struct text_object *, char *, unsigned int);
void new_outline(struct text_object *, char *, unsigned int);
void new_offset(struct text_object *, char *, unsigned int);
void new_voffset(struct text_object *, char *, unsigned int);
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);