summaryrefslogtreecommitdiff
path: root/src/entry.h
blob: 4ee6316b509583d3e74c7083bfd6d440061b3b05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#ifndef ENTRY_H
#define ENTRY_H

#include "entry_backend/pango.h"
#include "entry_backend/harfbuzz.h"

#include <cairo/cairo.h>
#include <uchar.h>
#include "color.h"
#include "desktop_vec.h"
#include "history.h"
#include "image.h"
#include "surface.h"
#include "string_vec.h"

#define MAX_INPUT_LENGTH 256
#define MAX_PROMPT_LENGTH 256
#define MAX_FONT_NAME_LENGTH 256
#define MAX_FONT_FEATURES_LENGTH 128
#define MAX_FONT_VARIATIONS_LENGTH 128

struct directional {
	int32_t top;
	int32_t right;
	int32_t bottom;
	int32_t left;
};

struct text_theme {
	struct color foreground_color;
	struct color background_color;
	struct directional padding;
	uint32_t background_corner_radius;

	bool foreground_specified;
	bool background_specified;
	bool padding_specified;
	bool radius_specified;
};

struct entry {
	struct image image;
	struct entry_backend_harfbuzz harfbuzz;
	struct entry_backend_pango pango;
	struct {
		cairo_surface_t *surface;
		cairo_t *cr;
	} cairo[2];
	int index;

	uint32_t input_utf32[MAX_INPUT_LENGTH];
	char input_utf8[4*MAX_INPUT_LENGTH];
	uint32_t input_utf32_length;
	uint32_t input_utf8_length;

	uint32_t selection;
	uint32_t first_result;
	char *command_buffer;
	struct string_ref_vec results;
	struct string_ref_vec commands;
	struct desktop_vec apps;
	struct history history;
	bool use_pango;

	uint32_t clip_x;
	uint32_t clip_y;
	uint32_t clip_width;
	uint32_t clip_height;

	/* Options */
	bool drun;
	bool horizontal;
	bool hide_input;
	char hidden_character_utf8[6];
	uint8_t hidden_character_utf8_length;
	uint32_t num_results;
	uint32_t num_results_drawn;
	uint32_t last_num_results_drawn;
	int32_t result_spacing;
	uint32_t font_size;
	char font_name[MAX_FONT_NAME_LENGTH];
	char font_features[MAX_FONT_FEATURES_LENGTH];
	char font_variations[MAX_FONT_VARIATIONS_LENGTH];
	char prompt_text[MAX_PROMPT_LENGTH];
	char placeholder_text[MAX_PROMPT_LENGTH];
	uint32_t prompt_padding;
	uint32_t corner_radius;
	uint32_t padding_top;
	uint32_t padding_bottom;
	uint32_t padding_left;
	uint32_t padding_right;
	bool padding_top_is_percent;
	bool padding_bottom_is_percent;
	bool padding_left_is_percent;
	bool padding_right_is_percent;
	bool clip_to_padding;
	uint32_t input_width;
	uint32_t border_width;
	uint32_t outline_width;
	struct color foreground_color;
	struct color background_color;
	struct color selection_highlight_color;
	struct color border_color;
	struct color outline_color;

	struct text_theme prompt_theme;
	struct text_theme input_theme;
	struct text_theme placeholder_theme;
	struct text_theme default_result_theme;
	struct text_theme alternate_result_theme;
	struct text_theme selection_theme;
};

void entry_init(struct entry *entry, uint8_t *restrict buffer, uint32_t width, uint32_t height);
void entry_destroy(struct entry *entry);
void entry_update(struct entry *entry);

#endif /* ENTRY_H */