Skip to content

Commit

Permalink
Enable Code Search (#917)
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnyp authored Apr 3, 2024
1 parent 9f6af15 commit 4c2944e
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 32 deletions.
9 changes: 9 additions & 0 deletions data/app.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@
</screenshots>
<content_rating type="oars-1.1" />
<releases>
<release version="46.1" date="2024-xx-xx">
<description translatable="no">
<ul>
<li>List editor shortcuts in Shortcuts</li>
<li>Add "Find" to search for code in the current editor</li>
</ul>
</description>
</release>

<release version="46" date="2024-03-20">
<description translatable="no">
<ul>
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project('Workbench', ['vala', 'c', 'rust'],
version: '46',
version: '46.1',
meson_version: '>= 0.59.0',
license: 'GPL-3.0-only'
)
Expand Down
48 changes: 34 additions & 14 deletions src/shortcutsWindow.blp
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,6 @@ ShortcutsWindow window {
title: _("Inspector");
}

ShortcutsShortcut {
accelerator: "<Control>Z";
title: _("Undo");
}

ShortcutsShortcut {
accelerator: "<Control><Shift>Z";
title: _("Redo");
}

// ShortcutsShortcut {
// accelerator: "<Control>F";
// title: _("Find");
// }
ShortcutsShortcut {
accelerator: "<Control>W";
title: _("Close Window");
Expand All @@ -62,6 +48,40 @@ ShortcutsWindow window {
}
}

ShortcutsGroup {
title: _("Editor");

ShortcutsShortcut {
accelerator: "<Control>X";
title: _("Cut");
}

ShortcutsShortcut {
accelerator: "<Control>C";
title: _("Copy");
}

ShortcutsShortcut {
accelerator: "<Control>V";
title: _("Paste");
}

ShortcutsShortcut {
accelerator: "<Control>F";
title: _("Find");
}

ShortcutsShortcut {
accelerator: "<Control>Z";
title: _("Undo");
}

ShortcutsShortcut {
accelerator: "<Control><Shift>Z";
title: _("Redo");
}
}

ShortcutsGroup {
title: _("Console");

Expand Down
27 changes: 18 additions & 9 deletions src/widgets/CodeFind.blp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ template $CodeFind: Revealer {
Separator {}

Box {
spacing: 8;
styles [
"toolbar"
]

halign: center;
margin-start: 8;
margin-end: 8;
margin-top: 8;
margin-bottom: 8;

Box {
valign: center;
Expand Down Expand Up @@ -43,22 +42,32 @@ template $CodeFind: Revealer {
Box {
valign: center;

styles [
"linked"
]

Button button_previous {
icon-name: "up";
tooltip-text: _("Move to previous match (Ctrl+Shift+G)");
sensitive: false;
clicked => $onSearchPrevious();
}

Button button_next {
icon-name: "down";
tooltip-text: _("Move to next match (Ctrl+G)");
sensitive: false;
clicked => $onSearchNext();
}
}

Button {
tooltip-text: _("Close Search");
icon-name: "window-close-symbolic";

styles [
"circular",
"small"
]

clicked => $onClose();
}
}
}
}
17 changes: 9 additions & 8 deletions src/widgets/CodeFind.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class Search extends Gtk.Revealer {

this.#initSearch();
this.#trackOccurrences();
this.#connectButtons();
this.#addControllers();
}

Expand Down Expand Up @@ -64,14 +63,16 @@ class Search extends Gtk.Revealer {
});
}

#connectButtons() {
this._button_previous.connect("clicked", () => {
this.#search(false);
});
onSearchPrevious() {
this.#search(false);
}

this._button_next.connect("clicked", () => {
this.#search(true);
});
onSearchNext() {
this.#search(true);
}

onClose() {
this.reveal_child = false;
}

#addControllers() {
Expand Down
6 changes: 6 additions & 0 deletions src/widgets/CodeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ class CodeView extends Gtk.Widget {
// https://github.com/workbenchdev/Workbench/pull/853/files#r1443560736
this._code_find.transition_type = Gtk.RevealerTransitionType.SLIDE_UP;

this._code_find.connect("notify::reveal-child", () => {
if (this._code_find.reveal_child === false) {
this.source_view.grab_focus();
}
});

try {
this.language = language_manager.get_language(language_id);
this.buffer.set_language(this.language);
Expand Down

0 comments on commit 4c2944e

Please sign in to comment.