summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorailin-nemui <ailin-nemui@users.noreply.github.com>2017-01-20 10:32:23 +0100
committerailin-nemui <ailin-nemui@users.noreply.github.com>2017-01-20 10:32:23 +0100
commit876c1dd93e06b9e627918f142f547e3deea682be (patch)
tree00cc3e49382a46977b0c760363829241820b4dfc
parent7fd3c1f50a1842152a8a9ca652154c5350f6aed8 (diff)
downloadirssi-876c1dd93e06b9e627918f142f547e3deea682be.zip
implement break_wide
for more pleasant east asian mixed display
-rw-r--r--src/fe-text/gui-windows.c10
-rw-r--r--src/fe-text/textbuffer-view.c12
-rw-r--r--src/fe-text/textbuffer-view.h3
3 files changed, 21 insertions, 4 deletions
diff --git a/src/fe-text/gui-windows.c b/src/fe-text/gui-windows.c
index 4213149d..c63c495c 100644
--- a/src/fe-text/gui-windows.c
+++ b/src/fe-text/gui-windows.c
@@ -49,6 +49,7 @@ static GUI_WINDOW_REC *gui_window_init(WINDOW_REC *window,
settings_get_int("indent"),
!settings_get_bool("indent_always"),
get_default_indent_func());
+ textbuffer_view_set_break_wide(gui->view, settings_get_bool("break_wide"));
if (parent->active == window)
textbuffer_view_set_window(gui->view, parent->screen_win);
return gui;
@@ -201,12 +202,14 @@ void gui_windows_reset_settings(void)
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
WINDOW_REC *rec = tmp->data;
- GUI_WINDOW_REC *gui = WINDOW_GUI(rec);
+ GUI_WINDOW_REC *gui = WINDOW_GUI(rec);
- textbuffer_view_set_default_indent(gui->view,
+ textbuffer_view_set_break_wide(gui->view, settings_get_bool("break_wide"));
+
+ textbuffer_view_set_default_indent(gui->view,
settings_get_int("indent"),
!settings_get_bool("indent_always"),
- get_default_indent_func());
+ get_default_indent_func());
textbuffer_view_set_scroll(gui->view,
gui->use_scroll ? gui->scroll :
@@ -281,6 +284,7 @@ void gui_windows_init(void)
settings_add_bool("lookandfeel", "autostick_split_windows", TRUE);
settings_add_int("lookandfeel", "indent", 10);
settings_add_bool("lookandfeel", "indent_always", FALSE);
+ settings_add_bool("lookandfeel", "break_wide", FALSE);
settings_add_bool("lookandfeel", "scroll", TRUE);
window_create_override = -1;
diff --git a/src/fe-text/textbuffer-view.c b/src/fe-text/textbuffer-view.c
index e2e3707b..486b7234 100644
--- a/src/fe-text/textbuffer-view.c
+++ b/src/fe-text/textbuffer-view.c
@@ -307,7 +307,7 @@ view_update_line_cache(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line)
continue;
}
- if (!view->utf8 && char_width > 1) {
+ if (view->break_wide && char_width > 1) {
last_space = xpos;
last_space_ptr = next_ptr;
last_color = color; last_fg24 = fg24; last_bg24 = bg24;
@@ -665,6 +665,16 @@ void textbuffer_view_set_default_indent(TEXT_BUFFER_VIEW_REC *view,
view->default_indent_func = indent_func;
}
+/* Enable breaking of wide chars */
+void textbuffer_view_set_break_wide(TEXT_BUFFER_VIEW_REC *view,
+ gboolean break_wide)
+{
+ if (view->break_wide != break_wide) {
+ view->break_wide = break_wide;
+ view_reset_cache(view);
+ }
+}
+
static void view_unregister_indent_func(TEXT_BUFFER_VIEW_REC *view,
INDENT_FUNC indent_func)
{
diff --git a/src/fe-text/textbuffer-view.h b/src/fe-text/textbuffer-view.h
index 21a9bde6..5e7a9d0a 100644
--- a/src/fe-text/textbuffer-view.h
+++ b/src/fe-text/textbuffer-view.h
@@ -59,6 +59,7 @@ struct _TEXT_BUFFER_VIEW_REC {
unsigned int longword_noindent:1;
unsigned int scroll:1; /* scroll down automatically when at bottom */
unsigned int utf8:1; /* use UTF8 in this view */
+ unsigned int break_wide:1; /* Break wide chars in this view */
TEXT_BUFFER_CACHE_REC *cache;
int ypos; /* cursor position - visible area is 0..height-1 */
@@ -97,6 +98,8 @@ void textbuffer_view_set_default_indent(TEXT_BUFFER_VIEW_REC *view,
int longword_noindent,
INDENT_FUNC indent_func);
void textbuffer_views_unregister_indent_func(INDENT_FUNC indent_func);
+void textbuffer_view_set_break_wide(TEXT_BUFFER_VIEW_REC *view,
+ gboolean break_wide);
void textbuffer_view_set_scroll(TEXT_BUFFER_VIEW_REC *view, int scroll);
void textbuffer_view_set_utf8(TEXT_BUFFER_VIEW_REC *view, int utf8);