aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2021-04-16 10:29:11 -0400
committerGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2021-04-16 10:29:11 -0400
commitdea80d78f9b1779fd29ba07e86b47643b27ff437 (patch)
tree34e31018d6d1d9e4315c352eb63635c339409a94
parentfaf8a95eea2a27ea1f776c9e61882bc27af9c735 (diff)
Added ability to specify find & replace pane entry font via `ui.find.entry_font`.
Also use type checks when setting find & replace text and labels.
-rw-r--r--docs/api.md6
-rw-r--r--docs/manual.md4
-rw-r--r--modules/lua/ta_api1
-rw-r--r--modules/lua/ta_tags1
-rw-r--r--modules/textadept/find.lua3
-rw-r--r--src/textadept.c35
-rw-r--r--themes/dark.lua3
-rw-r--r--themes/light.lua3
8 files changed, 39 insertions, 17 deletions
diff --git a/docs/api.md b/docs/api.md
index 251b037a..61d61dbe 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -8390,6 +8390,12 @@ Emitted when a text search wraps (passes through the beginning of the buffer), e
Whether or not the Find & Replace pane is active.
+<a id="ui.find.entry_font"></a>
+#### `ui.find.entry_font` (string, Write-only)
+
+The font to use in the "Find" and "Replace" entries in "name size" format.
+ The default value is system-dependent.
+
<a id="ui.find.find_entry_text"></a>
#### `ui.find.find_entry_text` (string)
diff --git a/docs/manual.md b/docs/manual.md
index 769045fa..6189a984 100644
--- a/docs/manual.md
+++ b/docs/manual.md
@@ -1298,6 +1298,7 @@ A theme consists of a single Lua file, and is typically responsible for:
and documentation popups.
* Specifying what symbols to use for margin markers and how to display visual elements like
the brace match indicator and snippet placeholders.
+* Specifying the find & replace pane entry font name and size.
[colors]: api.html#lexer.colors
[text display settings]: api.html#lexer.styles
@@ -1334,7 +1335,8 @@ your changes.
[`reset()`]: api.html#reset
The widgets in the GUI version of Textadept cannot be themed using Lua theme files. Instead,
-you must use [GTK Resource Files][], which are part of the GUI toolkit Textadept uses.
+you must use [GTK Resource Files][], which are part of the GUI toolkit Textadept uses. The
+exception to this is find & replace entry font, which can be changed.
**Note:** Textadept's pre-built binaries are built for and linked against GTK 2,
not GTK 3.
diff --git a/modules/lua/ta_api b/modules/lua/ta_api
index 63132b07..d1c83c0e 100644
--- a/modules/lua/ta_api
+++ b/modules/lua/ta_api
@@ -493,6 +493,7 @@ end_styled buffer.end_styled (number, Read-only)\nThe current styling position o
end_undo_action buffer.end_undo_action(buffer)\nEnds a sequence of actions to be undone or redone as a single action.\n@param buffer A buffer.
ensure_visible view.ensure_visible(view, line)\nEnsures line number *line* is visible by expanding any fold points hiding it.\n@param view A view.\n@param line The line number in *view* to ensure visible.
ensure_visible_enforce_policy view.ensure_visible_enforce_policy(view, line)\nEnsures line number *line* is visible by expanding any fold points hiding it based on the\nvertical caret policy previously defined in `view.set_visible_policy()`.\n@param view A view.\n@param line The line number in *view* to ensure visible.
+entry_font ui.find.entry_font (string, Write-only)\nThe font to use in the "Find" and "Replace" entries in "name size" format.\nThe default value is system-dependent.
eol_annotation_clear_all buffer.eol_annotation_clear_all(buffer)\nClears EOL annotations from all lines.\n@param buffer A buffer.
eol_annotation_style buffer.eol_annotation_style (table)\nTable of style numbers for EOL annotation text per line number.\nOnly some style attributes are active in annotations: font, size/size_fractional, bold/weight,\nitalics, fore, back, and character_set.
eol_annotation_text buffer.eol_annotation_text (table)\nTable of EOL annotation text per line number.
diff --git a/modules/lua/ta_tags b/modules/lua/ta_tags
index 0c5842bf..5471b09f 100644
--- a/modules/lua/ta_tags
+++ b/modules/lua/ta_tags
@@ -495,6 +495,7 @@ end_styled _HOME/core/.buffer.luadoc /^module('buffer')$/;" F class:buffer
end_undo_action _HOME/core/.buffer.luadoc /^function end_undo_action(buffer) end$/;" f class:buffer
ensure_visible _HOME/core/.view.luadoc /^function ensure_visible(view, line) end$/;" f class:view
ensure_visible_enforce_policy _HOME/core/.view.luadoc /^function ensure_visible_enforce_policy(view, line) end$/;" f class:view
+entry_font _HOME/modules/textadept/find.lua /^module('ui.find')]]$/;" F class:ui.find
eol_annotation_clear_all _HOME/core/.buffer.luadoc /^function eol_annotation_clear_all(buffer) end$/;" f class:buffer
eol_annotation_style _HOME/core/.buffer.luadoc /^module('buffer')$/;" F class:buffer
eol_annotation_text _HOME/core/.buffer.luadoc /^module('buffer')$/;" F class:buffer
diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua
index df51048b..b8f70ca6 100644
--- a/modules/textadept/find.lua
+++ b/modules/textadept/find.lua
@@ -55,6 +55,9 @@ local M = ui.find
-- @field in_files_label_text (string, Write-only)
-- The text of the "In files" label.
-- This is primarily used for localization.
+-- @field entry_font (string, Write-only)
+-- The font to use in the "Find" and "Replace" entries in "name size" format.
+-- The default value is system-dependent.
-- @field active (boolean)
-- Whether or not the Find & Replace pane is active.
-- @field highlight_all_matches (boolean)
diff --git a/src/textadept.c b/src/textadept.c
index 1e8a1c2b..3cdd04f4 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -486,9 +486,9 @@ static int find_index(lua_State *L) {
static int find_newindex(lua_State *L) {
const char *key = lua_tostring(L, 2);
if (strcmp(key, "find_entry_text") == 0)
- set_entry_text(find_text, lua_tostring(L, 3));
+ set_entry_text(find_text, luaL_checkstring(L, 3));
else if (strcmp(key, "replace_entry_text") == 0)
- set_entry_text(repl_text, lua_tostring(L, 3));
+ set_entry_text(repl_text, luaL_checkstring(L, 3));
else if (strcmp(key, "match_case") == 0)
toggle(match_case, lua_toboolean(L, -1));
else if (strcmp(key, "whole_word") == 0)
@@ -498,25 +498,32 @@ static int find_newindex(lua_State *L) {
else if (strcmp(key, "in_files") == 0)
toggle(in_files, lua_toboolean(L, -1));
else if (strcmp(key, "find_label_text") == 0)
- set_label_text(find_label, lua_tostring(L, 3));
+ set_label_text(find_label, luaL_checkstring(L, 3));
else if (strcmp(key, "replace_label_text") == 0)
- set_label_text(repl_label, lua_tostring(L, 3));
+ set_label_text(repl_label, luaL_checkstring(L, 3));
else if (strcmp(key, "find_next_button_text") == 0)
- set_button_label(find_next, lua_tostring(L, 3));
+ set_button_label(find_next, luaL_checkstring(L, 3));
else if (strcmp(key, "find_prev_button_text") == 0)
- set_button_label(find_prev, lua_tostring(L, 3));
+ set_button_label(find_prev, luaL_checkstring(L, 3));
else if (strcmp(key, "replace_button_text") == 0)
- set_button_label(replace, lua_tostring(L, 3));
+ set_button_label(replace, luaL_checkstring(L, 3));
else if (strcmp(key, "replace_all_button_text") == 0)
- set_button_label(replace_all, lua_tostring(L, 3));
+ set_button_label(replace_all, luaL_checkstring(L, 3));
else if (strcmp(key, "match_case_label_text") == 0)
- set_option_label(match_case, 0, lua_tostring(L, 3));
+ set_option_label(match_case, 0, luaL_checkstring(L, 3));
else if (strcmp(key, "whole_word_label_text") == 0)
- set_option_label(whole_word, 1, lua_tostring(L, 3));
+ set_option_label(whole_word, 1, luaL_checkstring(L, 3));
else if (strcmp(key, "regex_label_text") == 0)
- set_option_label(regex, 2, lua_tostring(L, 3));
+ set_option_label(regex, 2, luaL_checkstring(L, 3));
else if (strcmp(key, "in_files_label_text") == 0)
- set_option_label(in_files, 3, lua_tostring(L, 3));
+ set_option_label(in_files, 3, luaL_checkstring(L, 3));
+#if GTK
+ else if (strcmp(key, "entry_font") == 0) {
+ PangoFontDescription *font = pango_font_description_from_string(luaL_checkstring(L, 3));
+ gtk_widget_modify_font(find_entry, font), gtk_widget_modify_font(repl_entry, font);
+ pango_font_description_free(font);
+ }
+#endif
else
lua_rawset(L, 1);
return 0;
@@ -2141,10 +2148,6 @@ static GtkWidget *new_combo(GtkWidget **label, GtkWidget **entry, ListStore **hi
*entry = gtk_bin_get_child(GTK_BIN(combo));
gtk_entry_set_text(GTK_ENTRY(*entry), " "),
gtk_entry_set_text(GTK_ENTRY(*entry), ""); // initialize with non-NULL
- PangoFontDescription *font = pango_font_description_new();
- pango_font_description_set_family_static(font, "monospace");
- gtk_widget_modify_font(*entry, font);
- pango_font_description_free(font);
gtk_label_set_mnemonic_widget(GTK_LABEL(*label), *entry);
g_signal_connect(*entry, "key-press-event", G_CALLBACK(find_keypress), lua);
return combo;
diff --git a/themes/dark.lua b/themes/dark.lua
index 0177a2a6..d42156d2 100644
--- a/themes/dark.lua
+++ b/themes/dark.lua
@@ -127,3 +127,6 @@ view.call_tip_fore_hlt = colors.light_blue
-- Long Lines.
view.edge_color = colors.dark_grey
+
+-- Find & replace pane entries.
+ui.find.entry_font = font .. ' ' .. size
diff --git a/themes/light.lua b/themes/light.lua
index 5779903e..3a49168a 100644
--- a/themes/light.lua
+++ b/themes/light.lua
@@ -127,3 +127,6 @@ view.call_tip_fore_hlt = colors.light_blue
-- Long Lines.
view.edge_color = colors.grey
+
+-- Find & replace pane entries.
+ui.find.entry_font = font .. ' ' .. size