forked from Shinonome/dots-hyprland
ags: sync
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const { Gtk } = imports.gi;
|
||||
const { Gdk, Gtk } = imports.gi;
|
||||
import App from 'resource:///com/github/Aylur/ags/app.js';
|
||||
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
||||
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
|
||||
@@ -76,7 +76,7 @@ export const SearchAndWindows = () => {
|
||||
child: Widget.Label({
|
||||
className: 'overview-search-prompt txt-small txt',
|
||||
label: 'Type to search'
|
||||
})
|
||||
}),
|
||||
});
|
||||
|
||||
const entryIconRevealer = Widget.Revealer({
|
||||
@@ -217,7 +217,10 @@ export const SearchAndWindows = () => {
|
||||
entry,
|
||||
Widget.Box({
|
||||
className: 'overview-search-icon-box',
|
||||
setup: box => box.pack_start(entryPromptRevealer, true, true, 0),
|
||||
setup: (box) => {
|
||||
box.pack_start(entryPromptRevealer, true, true, 0)
|
||||
// enableClickthrough(box);
|
||||
},
|
||||
}),
|
||||
entryIcon,
|
||||
]
|
||||
@@ -233,10 +236,31 @@ export const SearchAndWindows = () => {
|
||||
}
|
||||
})
|
||||
.on('key-press-event', (widget, event) => { // Typing
|
||||
if (event.get_keyval()[1] >= 32 && event.get_keyval()[1] <= 126 && widget != entry) {
|
||||
Utils.timeout(1, () => entry.grab_focus());
|
||||
entry.set_text(entry.text + String.fromCharCode(event.get_keyval()[1]));
|
||||
entry.set_position(-1);
|
||||
const keyval = event.get_keyval()[1];
|
||||
const modstate = event.get_state()[1];
|
||||
if (modstate & Gdk.ModifierType.CONTROL_MASK) { // Ctrl held
|
||||
if (keyval == Gdk.KEY_b)
|
||||
entry.set_position(Math.max(entry.get_position() - 1, 0));
|
||||
else if (keyval == Gdk.KEY_f)
|
||||
entry.set_position(Math.min(entry.get_position() + 1, entry.get_text().length));
|
||||
else if (keyval == Gdk.KEY_n) { // simulate Down arrow
|
||||
entry.get_root_window().simulate_key_press(Gdk.KEY_Down, Gdk.ModifierType.NONE);
|
||||
// entry.get_root_window().simulate_key_release(Gdk.KEY_Down, Gdk.ModifierType.NONE);
|
||||
}
|
||||
else if (keyval == Gdk.KEY_k) { // Delete to end
|
||||
const text = entry.get_text();
|
||||
const pos = entry.get_position();
|
||||
const newText = text.slice(0, pos);
|
||||
entry.set_text(newText);
|
||||
entry.set_position(newText.length);
|
||||
}
|
||||
}
|
||||
else { // Ctrl not held
|
||||
if (keyval >= 32 && keyval <= 126 && widget != entry) {
|
||||
Utils.timeout(1, () => entry.grab_focus());
|
||||
entry.set_text(entry.text + String.fromCharCode(keyval));
|
||||
entry.set_position(-1);
|
||||
}
|
||||
}
|
||||
})
|
||||
,
|
||||
|
||||
Reference in New Issue
Block a user