From bb1d942cea33b37676e220b551402552ba2fc57c Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Thu, 3 Apr 2025 21:11:06 +0200 Subject: [PATCH] ai: tweak gtk sourceview properties --- .../ags/modules/sideleft/apis/ai_chatmessage.js | 14 +++++++++++++- .config/ags/scss/_common.scss | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.config/ags/modules/sideleft/apis/ai_chatmessage.js b/.config/ags/modules/sideleft/apis/ai_chatmessage.js index 4b3a702e..a1e041c3 100644 --- a/.config/ags/modules/sideleft/apis/ai_chatmessage.js +++ b/.config/ags/modules/sideleft/apis/ai_chatmessage.js @@ -49,7 +49,12 @@ const HighlightedCode = (content, lang) => { const buffer = new GtkSource.Buffer(); const sourceView = new GtkSource.View({ buffer: buffer, - wrap_mode: Gtk.WrapMode.NONE + wrap_mode: Gtk.WrapMode.NONE, + insertSpacesInsteadOfTabs: true, + indentWidth: 4, + tabWidth: 4, + smartHomeEnd: true, + smartBackspace: true, }); const langManager = GtkSource.LanguageManager.get_default(); let displayLang = langManager.get_language(substituteLang(lang)); // Set your preferred language @@ -176,6 +181,13 @@ const CodeBlock = (content = '', lang = 'txt') => { const codeBlock = Box({ attribute: { 'updateText': (text) => { + // Enable useful features for multi-line code + if (text.split('\n').length > 1) { + sourceView.autoIndent = true; + sourceView.highlightCurrentLine = true; + sourceView.showLineNumbers = true; + sourceView.showLineMarks = true; + } sourceView.get_buffer().set_text(text, -1); } }, diff --git a/.config/ags/scss/_common.scss b/.config/ags/scss/_common.scss index 1ce5f70b..e12a2031 100644 --- a/.config/ags/scss/_common.scss +++ b/.config/ags/scss/_common.scss @@ -373,4 +373,8 @@ widget { .spinbutton-reset:active { background-color: $layer2Active; +} + +textview { + caret-color: $onBackground; } \ No newline at end of file