Skip to content

Commit

Permalink
* ui_color.h, */ui_color.c, cocoa.m, ui_bel_mode.[ch],
Browse files Browse the repository at this point in the history
  ui_color_cache.[ch], ui_color_manager.[ch], ui_layout.c,
  ui_mod_meta_mode.[ch], ui_sb_mode.[ch], ui_screen.[ch],
  ui_scrollbar.[ch], ui_type_engine.[ch], ui_im_status_screen.c,
  ui_window.h, vt_char_encoding.[ch], vt_ot_layout.[ch],
  vt_parser.[ch], vt_pty.[ch], vt_term.[ch]: Add const.
  • Loading branch information
arakiken committed Jan 1, 2025
1 parent b9b6305 commit 7d45c2b
Show file tree
Hide file tree
Showing 38 changed files with 118 additions and 97 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
2025-01-02 Araki Ken <arakiken@users.sf.net>

* ui_color.h, */ui_color.c, cocoa.m, ui_bel_mode.[ch],
ui_color_cache.[ch], ui_color_manager.[ch], ui_layout.c,
ui_mod_meta_mode.[ch], ui_sb_mode.[ch], ui_screen.[ch],
ui_scrollbar.[ch], ui_type_engine.[ch], ui_im_status_screen.c,
ui_window.h, vt_char_encoding.[ch], vt_ot_layout.[ch],
vt_parser.[ch], vt_pty.[ch], vt_term.[ch]: Add const.

* quartz/ui_im_status_screen-cocoa.m, im_wnn.c: Add const.

* im_ibus.c, im_common.h, skk/ef_str_parser.c, gtkxlfdsel.[ch],
Expand Down
6 changes: 2 additions & 4 deletions gtk/vte.c
Original file line number Diff line number Diff line change
Expand Up @@ -3660,8 +3660,7 @@ void vte_terminal_set_background_image_file(VteTerminal *terminal, const char *p
}

if (GTK_WIDGET_REALIZED(GTK_WIDGET(terminal))) {
ui_screen_set_config(PVT(terminal)->screen, NULL, "wall_picture",
(char*)path /* avoid warning "discard qualifiers" */);
ui_screen_set_config(PVT(terminal)->screen, NULL, "wall_picture", path);
} else {
free(PVT(terminal)->screen->pic_file_path);
PVT(terminal)->screen->pic_file_path = (*path == '\0') ? NULL : strdup(path);
Expand Down Expand Up @@ -4268,8 +4267,7 @@ void vte_terminal_set_encoding(VteTerminal *terminal, const char *codeset)
}

if (GTK_WIDGET_REALIZED(GTK_WIDGET(terminal))) {
ui_screen_set_config(PVT(terminal)->screen, NULL, "encoding",
(char*)codeset /* avoid warning "discard qualifiers" */);
ui_screen_set_config(PVT(terminal)->screen, NULL, "encoding", codeset);
} else {
vt_term_change_encoding(PVT(terminal)->term, vt_get_char_encoding(codeset));
}
Expand Down
2 changes: 1 addition & 1 deletion uitoolkit/console/ui_color.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/* --- global functions --- */

int ui_load_named_xcolor(ui_display_t *disp, ui_color_t *xcolor, char *name) {
int ui_load_named_xcolor(ui_display_t *disp, ui_color_t *xcolor, const char *name) {
vt_color_t color;
u_int8_t red;
u_int8_t green;
Expand Down
2 changes: 1 addition & 1 deletion uitoolkit/fb/ui_color.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/* --- global functions --- */

int ui_load_named_xcolor(ui_display_t *disp, ui_color_t *xcolor, char *name) {
int ui_load_named_xcolor(ui_display_t *disp, ui_color_t *xcolor, const char *name) {
vt_color_t color;
u_int8_t red;
u_int8_t green;
Expand Down
2 changes: 1 addition & 1 deletion uitoolkit/quartz/cocoa.m
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ void window_get_position(NSWindow *window, int *x, int *y) {
[window.contentView frame].size.height;
}

static int is_valid_utf8(char *str, size_t len) {
static int is_valid_utf8(const char *str, size_t len) {
ef_parser_t *parser;

/* [window setTitle] can cause segfault if title is non UTF-8 text. */
Expand Down
2 changes: 1 addition & 1 deletion uitoolkit/quartz/ui_color.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/* --- global functions --- */

int ui_load_named_xcolor(ui_display_t *disp, ui_color_t *xcolor, char *name) {
int ui_load_named_xcolor(ui_display_t *disp, ui_color_t *xcolor, const char *name) {
vt_color_t color;
u_int8_t red;
u_int8_t green;
Expand Down
2 changes: 1 addition & 1 deletion uitoolkit/ui_bel_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static char *bel_mode_name_table[] = {"none", "sound", "visual", "sound|visual"}

/* --- global functions --- */

ui_bel_mode_t ui_get_bel_mode_by_name(char *name) {
ui_bel_mode_t ui_get_bel_mode_by_name(const char *name) {
ui_bel_mode_t mode;

for (mode = 0; mode < BEL_MODE_MAX; mode++) {
Expand Down
2 changes: 1 addition & 1 deletion uitoolkit/ui_bel_mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ typedef enum ui_bel_mode {

} ui_bel_mode_t;

ui_bel_mode_t ui_get_bel_mode_by_name(char *name);
ui_bel_mode_t ui_get_bel_mode_by_name(const char *name);

char *ui_get_bel_mode_name(ui_bel_mode_t mode);

Expand Down
2 changes: 1 addition & 1 deletion uitoolkit/ui_color.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ typedef struct ui_color {

} ui_color_t;

int ui_load_named_xcolor(ui_display_t *disp, ui_color_t *xcolor, char *name);
int ui_load_named_xcolor(ui_display_t *disp, ui_color_t *xcolor, const char *name);

int ui_load_rgb_xcolor(ui_display_t *disp, ui_color_t *xcolor, u_int8_t red, u_int8_t green,
u_int8_t blue, u_int8_t alpha);
Expand Down
2 changes: 1 addition & 1 deletion uitoolkit/ui_color_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void ui_color_cache_unload_all(void) {
}

/* Not cached */
int ui_load_xcolor(ui_color_cache_t *color_cache, ui_color_t *xcolor, char *name) {
int ui_load_xcolor(ui_color_cache_t *color_cache, ui_color_t *xcolor, const char *name) {
if (!ui_load_named_xcolor(color_cache->disp, xcolor, name)) {
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion uitoolkit/ui_color_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void ui_color_cache_unload(ui_color_cache_t *color_cache);

void ui_color_cache_unload_all(void);

int ui_load_xcolor(ui_color_cache_t *color_cache, ui_color_t *xcolor, char *name);
int ui_load_xcolor(ui_color_cache_t *color_cache, ui_color_t *xcolor, const char *name);

ui_color_t *ui_get_cached_xcolor(ui_color_cache_t *color_cache, vt_color_t color);

Expand Down
14 changes: 8 additions & 6 deletions uitoolkit/ui_color_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ enum {

/* --- static functions --- */

static int sys_color_set(ui_color_manager_t *color_man, char *name, int color) {
static int sys_color_set(ui_color_manager_t *color_man, const char *name, int color) {
ui_color_t xcolor;

if (bl_compare_str(color_man->sys_colors[color].name, name) == 0) {
Expand Down Expand Up @@ -143,27 +143,29 @@ void ui_color_manager_destroy(ui_color_manager_t *color_man) {
free(color_man);
}

int ui_color_manager_set_fg_color(ui_color_manager_t *color_man, char *name /* never NULL */) {
int ui_color_manager_set_fg_color(ui_color_manager_t *color_man,
const char *name /* never NULL */) {
return sys_color_set(color_man, name, _FG_COLOR);
}

int ui_color_manager_set_bg_color(ui_color_manager_t *color_man, char *name /* never NULL */) {
int ui_color_manager_set_bg_color(ui_color_manager_t *color_man,
const char *name /* never NULL */) {
return sys_color_set(color_man, name, _BG_COLOR);
}

int ui_color_manager_set_cursor_fg_color(ui_color_manager_t *color_man,
char *name /* can be NULL */) {
const char *name /* can be NULL */) {
return sys_color_set(color_man, name, _CUR_FG_COLOR);
}

int ui_color_manager_set_cursor_bg_color(ui_color_manager_t *color_man,
char *name /* can be NULL */) {
const char *name /* can be NULL */) {
return sys_color_set(color_man, name, _CUR_BG_COLOR);
}

int ui_color_manager_set_alt_color(ui_color_manager_t *color_man,
vt_color_t color, /* VT_BOLD_COLOR - VT_CROSSED_OUT_COLOR */
char *name /* never NULL */) {
const char *name /* never NULL */) {
return sys_color_set(color_man, name, color - VT_FG_COLOR);
}

Expand Down
11 changes: 6 additions & 5 deletions uitoolkit/ui_color_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ ui_color_manager_t *ui_color_manager_new(ui_display_t *disp, char *fg_color, cha

void ui_color_manager_destroy(ui_color_manager_t *color_man);

int ui_color_manager_set_fg_color(ui_color_manager_t *color_man, char *name);
int ui_color_manager_set_fg_color(ui_color_manager_t *color_man, const char *name);

int ui_color_manager_set_bg_color(ui_color_manager_t *color_man, char *name);
int ui_color_manager_set_bg_color(ui_color_manager_t *color_man, const char *name);

int ui_color_manager_set_cursor_fg_color(ui_color_manager_t *color_man, char *name);
int ui_color_manager_set_cursor_fg_color(ui_color_manager_t *color_man, const char *name);

int ui_color_manager_set_cursor_bg_color(ui_color_manager_t *color_man, char *name);
int ui_color_manager_set_cursor_bg_color(ui_color_manager_t *color_man, const char *name);

int ui_color_manager_set_alt_color(ui_color_manager_t *color_man, vt_color_t color, char *name);
int ui_color_manager_set_alt_color(ui_color_manager_t *color_man, vt_color_t color,
const char *name);

char *ui_color_manager_get_fg_color(ui_color_manager_t *color_man);

Expand Down
2 changes: 1 addition & 1 deletion uitoolkit/ui_im_status_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ static void replace_char(char *str, char orig, char new) {
}
}

static int set(ui_im_status_screen_t *stat_screen, ef_parser_t *parser, u_char *str) {
static int set(ui_im_status_screen_t *stat_screen, ef_parser_t *parser, const u_char *str) {
u_char *seq;
size_t len = strlen(str);

Expand Down
6 changes: 3 additions & 3 deletions uitoolkit/ui_layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ static void line_height_changed(void *p, u_int line_height) {
ui_scrollbar_set_line_height(&term->scrollbar, line_height);
}

static void change_fg_color(void *p, char *color) {
static void change_fg_color(void *p, const char *color) {
struct terminal *term;

term = p;
Expand All @@ -755,7 +755,7 @@ static char *get_fg_color(void *p) {
return term->scrollbar.fg_color;
}

static void change_bg_color(void *p, char *color) {
static void change_bg_color(void *p, const char *color) {
struct terminal *term;

term = p;
Expand All @@ -771,7 +771,7 @@ static char *get_bg_color(void *p) {
return term->scrollbar.bg_color;
}

static void change_view(void *p, char *name) {
static void change_view(void *p, const char *name) {
struct terminal *term;

term = p;
Expand Down
2 changes: 1 addition & 1 deletion uitoolkit/ui_mod_meta_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ static char *mod_meta_mode_name_table[] = {

/* --- global functions --- */

ui_mod_meta_mode_t ui_get_mod_meta_mode_by_name(char *name) {
ui_mod_meta_mode_t ui_get_mod_meta_mode_by_name(const char *name) {
ui_mod_meta_mode_t mode;

for (mode = 0; mode < MOD_META_MODE_MAX; mode++) {
Expand Down
2 changes: 1 addition & 1 deletion uitoolkit/ui_mod_meta_mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ typedef enum ui_mod_meta_mode {

} ui_mod_meta_mode_t;

ui_mod_meta_mode_t ui_get_mod_meta_mode_by_name(char *name);
ui_mod_meta_mode_t ui_get_mod_meta_mode_by_name(const char *name);

char *ui_get_mod_meta_mode_name(ui_mod_meta_mode_t mode);

Expand Down
2 changes: 1 addition & 1 deletion uitoolkit/ui_sb_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static char *sb_mode_name_table[] = {

/* --- global functions --- */

ui_sb_mode_t ui_get_sb_mode_by_name(char *name) {
ui_sb_mode_t ui_get_sb_mode_by_name(const char *name) {
#ifndef USE_CONSOLE
ui_sb_mode_t mode;

Expand Down
2 changes: 1 addition & 1 deletion uitoolkit/ui_sb_mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ typedef enum ui_sb_mode {

} ui_sb_mode_t;

ui_sb_mode_t ui_get_sb_mode_by_name(char *name);
ui_sb_mode_t ui_get_sb_mode_by_name(const char *name);

char *ui_get_sb_mode_name(ui_sb_mode_t mode);

Expand Down
30 changes: 15 additions & 15 deletions uitoolkit/ui_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1847,7 +1847,7 @@ static int receive_string_via_ucs(ui_screen_t *screen) {
}

/* referred in shortcut_match */
static void change_im(ui_screen_t *, char *);
static void change_im(ui_screen_t *, const char *);
static void xterm_set_selection(void *, vt_char_t *, u_int, u_char *);
static void copymode_start(ui_screen_t *);

Expand Down Expand Up @@ -3210,7 +3210,7 @@ static void utf_selection_notified(ui_window_t *win, u_char *str, size_t len) {
}

#ifndef DISABLE_XDND
static void set_xdnd_config(ui_window_t *win, char *dev, char *key, char *value) {
static void set_xdnd_config(ui_window_t *win, const char *dev, const char *key, const char *value) {
ui_screen_t *screen;

screen = (ui_screen_t *)win;
Expand Down Expand Up @@ -4426,13 +4426,13 @@ static void change_log_size(ui_screen_t *screen, u_int logsize) {
}
}

static void change_sb_view(ui_screen_t *screen, char *name) {
static void change_sb_view(ui_screen_t *screen, const char *name) {
if (HAS_SCROLL_LISTENER(screen, change_view)) {
(*screen->screen_scroll_listener->change_view)(screen->screen_scroll_listener->self, name);
}
}

static void change_mod_meta_key(ui_screen_t *screen, char *key) {
static void change_mod_meta_key(ui_screen_t *screen, const char *key) {
free(screen->mod_meta_key);

if (strcmp(key, "none") == 0) {
Expand Down Expand Up @@ -4492,7 +4492,7 @@ static void change_receive_string_via_ucs_flag(ui_screen_t *screen, int flag) {
screen->receive_string_via_ucs = flag;
}

static void change_fg_color(ui_screen_t *screen, char *name) {
static void change_fg_color(ui_screen_t *screen, const char *name) {
if (ui_color_manager_set_fg_color(screen->color_man, name) &&
ui_window_set_fg_color(&screen->window, ui_get_xcolor(screen->color_man, VT_FG_COLOR))) {
ui_xic_fg_color_changed(&screen->window);
Expand All @@ -4507,7 +4507,7 @@ static void change_fg_color(ui_screen_t *screen, char *name) {

static void picture_modifier_changed(ui_screen_t *screen);

static void change_bg_color(ui_screen_t *screen, char *name) {
static void change_bg_color(ui_screen_t *screen, const char *name) {
if (ui_color_manager_set_bg_color(screen->color_man, name) &&
ui_window_set_bg_color(&screen->window, ui_get_xcolor(screen->color_man, VT_BG_COLOR))) {
ui_xic_bg_color_changed(&screen->window);
Expand All @@ -4526,7 +4526,7 @@ static void change_bg_color(ui_screen_t *screen, char *name) {
}
}

static void change_alt_color(ui_screen_t *screen, vt_color_t color, char *name) {
static void change_alt_color(ui_screen_t *screen, vt_color_t color, const char *name) {
if (ui_color_manager_set_alt_color(screen->color_man, color, *name ? name : NULL)) {
vt_term_set_modified_all_lines_in_screen(screen->term);

Expand All @@ -4537,13 +4537,13 @@ static void change_alt_color(ui_screen_t *screen, vt_color_t color, char *name)
}
}

static void change_sb_fg_color(ui_screen_t *screen, char *name) {
static void change_sb_fg_color(ui_screen_t *screen, const char *name) {
if (HAS_SCROLL_LISTENER(screen, change_fg_color)) {
(*screen->screen_scroll_listener->change_fg_color)(screen->screen_scroll_listener->self, name);
}
}

static void change_sb_bg_color(ui_screen_t *screen, char *name) {
static void change_sb_bg_color(ui_screen_t *screen, const char *name) {
if (HAS_SCROLL_LISTENER(screen, change_bg_color)) {
(*screen->screen_scroll_listener->change_bg_color)(screen->screen_scroll_listener->self, name);
}
Expand Down Expand Up @@ -4691,7 +4691,7 @@ static void change_borderless_flag(ui_screen_t *screen, int flag) {
}
}

static void change_wall_picture(ui_screen_t *screen, char *file_path) {
static void change_wall_picture(ui_screen_t *screen, const char *file_path) {
if (screen->pic_file_path) {
if (strcmp(screen->pic_file_path, file_path) == 0) {
/* not changed */
Expand Down Expand Up @@ -4821,7 +4821,7 @@ static void change_fade_ratio(ui_screen_t *screen, u_int fade_ratio) {
* If screen->inputmethod is same as input_method, re-create a new input method
* forcibly because change_char_encoding() expects change_im() to do so.
*/
static void change_im(ui_screen_t *screen, char *input_method) {
static void change_im(ui_screen_t *screen, const char *input_method) {
ui_im_t *im;

ui_xic_deactivate(&screen->window);
Expand Down Expand Up @@ -4866,8 +4866,8 @@ static void change_im(ui_screen_t *screen, char *input_method) {
* Callbacks of ui_config_event_listener_t events.
*/

static void get_config_intern(ui_screen_t *screen, char *dev, /* can be NULL */
char *key, /* can be "error" */
static void get_config_intern(ui_screen_t *screen, const char *dev, /* can be NULL */
const char *key, /* can be "error" */
int to_menu, /* -1: don't output to pty and menu. */
int *flag /* 1(true), 0(false) or -1(other) is returned. */
) {
Expand Down Expand Up @@ -7239,8 +7239,8 @@ int ui_screen_exec_cmd(ui_screen_t *screen, char *cmd) {
* 0 -> Not processed
* 1 -> Processed (regardless of processing succeeded or not)
*/
int ui_screen_set_config(ui_screen_t *screen, char *dev, /* can be NULL */
char *key, char *value) {
int ui_screen_set_config(ui_screen_t *screen, const char *dev, /* can be NULL */
const char *key, const char *value) {
vt_term_t *term;
int echo;

Expand Down
8 changes: 4 additions & 4 deletions uitoolkit/ui_screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ typedef struct ui_screen_scroll_event_listener {
void (*scrolled_to)(void *, int);
void (*log_size_changed)(void *, u_int);
void (*line_height_changed)(void *, u_int);
void (*change_fg_color)(void *, char *);
void (*change_fg_color)(void *, const char *);
char *(*fg_color)(void *);
void (*change_bg_color)(void *, char *);
void (*change_bg_color)(void *, const char *);
char *(*bg_color)(void *);
void (*change_view)(void *, char *);
void (*change_view)(void *, const char *);
char *(*view_name)(void *);
void (*transparent_state_changed)(void *, int, ui_picture_modifier_t *);
ui_sb_mode_t (*sb_mode)(void *);
Expand Down Expand Up @@ -213,7 +213,7 @@ u_int ui_line_ascent(ui_screen_t *screen);

int ui_screen_exec_cmd(ui_screen_t *screen, char *cmd);

int ui_screen_set_config(ui_screen_t *screen, char *dev, char *key, char *value);
int ui_screen_set_config(ui_screen_t *screen, const char *dev, const char *key, const char *value);

void ui_screen_reset_view(ui_screen_t *screen);

Expand Down
Loading

0 comments on commit 7d45c2b

Please sign in to comment.