-
Notifications
You must be signed in to change notification settings - Fork 179
Issue #381 clickable autocomplete #383
base: master
Are you sure you want to change the base?
Changes from 3 commits
dec82ff
6048afa
db715af
b1cae98
5e4f7cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,6 +106,7 @@ public class FinalTerm : Gtk.Application { | |
| im_context.preedit_end.connect(on_preedit_end); | ||
| main_window.key_press_event.connect(on_key_press_event); | ||
| main_window.key_release_event.connect(on_key_release_event); | ||
| autocompletion.run_command.connect(on_autocomplete_run_command); | ||
| } | ||
|
|
||
| protected override void activate() { | ||
|
|
@@ -243,6 +244,10 @@ public class FinalTerm : Gtk.Application { | |
| return true; | ||
| } | ||
|
|
||
| private void on_autocomplete_run_command(string command) { | ||
| active_terminal_widget.run_shell_command(command); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not entirely sure what the expected behavior really is here. Maybe on a simple click, the system should actually just put the command in the prompt without executing it.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel that left click should do the same as pressing enter. But maybe we can put the command in prompt on right click.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think right click should either provide a menu or do nothing at all. Single click should copy the command in the prompt, double click should run the command. I quite sure about the double click though. Mouse usage is not supposed to be fast anyway.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't find any reference to double click event in Clutter. Is there one?
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's a very good question. I spent quite a while looking, and indeed I found that the However, the docs have something weird to say about this: "The clicks do not have to occur on the same actor: providing they occur within the double click distance and time, they are counted as part of the same click sequence." Still, this is obviously intended to provide double-click support so we should probably just use it.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also agree with @arkocal's proposal: Single click should copy the command into the prompt, double click should run it, and right/middle/etc. clicks should do nothing. |
||
| } | ||
|
|
||
| private bool on_key_release_event(Gdk.EventKey event) { | ||
| return im_context.filter_keypress(event); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,6 +54,8 @@ public class ScrollableListView<T, E> : Clutter.Actor { | |
| list_view.add_attribute(item_property_name, 0); | ||
|
|
||
| scroll_view.add(list_view); | ||
| scroll_view.motion_event.connect(on_motion_event); | ||
| scroll_view.button_press_event.connect(on_button_press_event);; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doubled semicolons |
||
|
|
||
| // Synchronize model with list | ||
| foreach (var item in list) { | ||
|
|
@@ -143,11 +145,45 @@ public class ScrollableListView<T, E> : Clutter.Actor { | |
| scroll_view.ensure_visible(geometry); | ||
| } | ||
|
|
||
| public int get_item_by_y(int y) { | ||
| var index = -1; | ||
| var height = 0; | ||
| for (int i = 0; i < get_number_of_items(); i++) { | ||
| var allocation_box = get_item_view(i).get_allocation_box(); | ||
| height += (int)allocation_box.get_height(); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spacing issues
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is still an extra space after the operator here |
||
| if ((int)y < height) { | ||
| index = i; | ||
| break; | ||
| } | ||
| } | ||
| return index; | ||
| } | ||
|
|
||
| private void on_settings_changed(string? key) { | ||
| scroll_view.style = Settings.get_default().theme.style; | ||
| list_view.style = Settings.get_default().theme.style; | ||
| } | ||
|
|
||
| private bool on_motion_event(Clutter.MotionEvent event) { | ||
| var index = get_item_by_y((int)event.y); | ||
| if (index >= 0) { | ||
| item_hovered(index); | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| private bool on_button_press_event(Clutter.ButtonEvent event) { | ||
| var index = get_item_by_y((int)event.y); | ||
| if (index >= 0) { | ||
| item_clicked(index); | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| public signal void item_hovered(int index); | ||
| public signal void item_clicked(int index); | ||
|
|
||
| private class ItemViewFactory<G> : Object, Mx.ItemFactory { | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the weirdest construct I have ever seen in Vala. I am completely unfamiliar with such syntax. How does this compile?!? Can you enlighten me?
It's not a method (no parentheses, unless the ones around
selected_textare somehow counted), it's not a property (no get/set blocks), so what is it?