mirror of https://github.com/helix-editor/helix
Compare commits
5 Commits
f34a3abe88
...
e23068e70d
Author | SHA1 | Date |
---|---|---|
|
e23068e70d | |
|
4281228da3 | |
|
395a71bf53 | |
|
1e4bf6704a | |
|
60898c2bb5 |
|
@ -47,6 +47,7 @@ use helix_core::{
|
||||||
use helix_view::{
|
use helix_view::{
|
||||||
editor::Action,
|
editor::Action,
|
||||||
graphics::{CursorKind, Margin, Modifier, Rect},
|
graphics::{CursorKind, Margin, Modifier, Rect},
|
||||||
|
input::{MouseButton, MouseEvent, MouseEventKind},
|
||||||
theme::Style,
|
theme::Style,
|
||||||
view::ViewPosition,
|
view::ViewPosition,
|
||||||
Document, DocumentId, Editor,
|
Document, DocumentId, Editor,
|
||||||
|
@ -247,6 +248,8 @@ pub struct Picker<T: 'static + Send + Sync, D: 'static> {
|
||||||
|
|
||||||
/// Current height of the completions box
|
/// Current height of the completions box
|
||||||
completion_height: u16,
|
completion_height: u16,
|
||||||
|
/// The area that contains the table's pickable items
|
||||||
|
picking_area: Rect,
|
||||||
|
|
||||||
cursor: u32,
|
cursor: u32,
|
||||||
prompt: Prompt,
|
prompt: Prompt,
|
||||||
|
@ -383,6 +386,7 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
|
||||||
show_preview: true,
|
show_preview: true,
|
||||||
callback_fn: Box::new(callback_fn),
|
callback_fn: Box::new(callback_fn),
|
||||||
completion_height: 0,
|
completion_height: 0,
|
||||||
|
picking_area: Rect::default(),
|
||||||
widths,
|
widths,
|
||||||
preview_cache: HashMap::new(),
|
preview_cache: HashMap::new(),
|
||||||
read_buffer: Vec::with_capacity(1024),
|
read_buffer: Vec::with_capacity(1024),
|
||||||
|
@ -565,6 +569,35 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn handle_mouse_event(&mut self, event: &MouseEvent) -> EventResult {
|
||||||
|
let MouseEvent {
|
||||||
|
kind, row, column, ..
|
||||||
|
} = *event;
|
||||||
|
|
||||||
|
// consume event if outside of the area with pickable items
|
||||||
|
if !self.picking_area.intersects(Rect::new(column, row, 1, 1)) {
|
||||||
|
return EventResult::Consumed(None);
|
||||||
|
}
|
||||||
|
|
||||||
|
match kind {
|
||||||
|
MouseEventKind::Down(MouseButton::Left) => {
|
||||||
|
// picking_area.height > 0 because the mouse position is inside the area
|
||||||
|
let offset = self.cursor - (self.cursor % self.picking_area.height as u32);
|
||||||
|
let new_cursor = offset + (row - self.picking_area.y) as u32;
|
||||||
|
|
||||||
|
// move if the new cursor is in bounds, on an item
|
||||||
|
if new_cursor < self.matcher.snapshot().matched_item_count() {
|
||||||
|
self.cursor = new_cursor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MouseEventKind::ScrollUp => self.page_up(),
|
||||||
|
MouseEventKind::ScrollDown => self.page_down(),
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
|
||||||
|
EventResult::Consumed(None)
|
||||||
|
}
|
||||||
|
|
||||||
/// Get (cached) preview for the currently selected item. If a document corresponding
|
/// Get (cached) preview for the currently selected item. If a document corresponding
|
||||||
/// to the path is already open in the editor, it is used instead.
|
/// to the path is already open in the editor, it is used instead.
|
||||||
fn get_preview<'picker, 'editor>(
|
fn get_preview<'picker, 'editor>(
|
||||||
|
@ -726,6 +759,7 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
|
||||||
// -- Render the contents:
|
// -- Render the contents:
|
||||||
// subtract area of prompt from top
|
// subtract area of prompt from top
|
||||||
let inner = inner.clip_top(2);
|
let inner = inner.clip_top(2);
|
||||||
|
self.picking_area = inner.clip_top(self.header_height());
|
||||||
let rows = inner.height.saturating_sub(self.header_height()) as u32;
|
let rows = inner.height.saturating_sub(self.header_height()) as u32;
|
||||||
let offset = self.cursor - (self.cursor % std::cmp::max(1, rows));
|
let offset = self.cursor - (self.cursor % std::cmp::max(1, rows));
|
||||||
let cursor = self.cursor.saturating_sub(offset);
|
let cursor = self.cursor.saturating_sub(offset);
|
||||||
|
@ -1023,6 +1057,7 @@ impl<I: 'static + Send + Sync, D: 'static + Send + Sync> Component for Picker<I,
|
||||||
Event::Key(event) => *event,
|
Event::Key(event) => *event,
|
||||||
Event::Paste(..) => return self.prompt_handle_event(event, ctx),
|
Event::Paste(..) => return self.prompt_handle_event(event, ctx),
|
||||||
Event::Resize(..) => return EventResult::Consumed(None),
|
Event::Resize(..) => return EventResult::Consumed(None),
|
||||||
|
Event::Mouse(event) => return self.handle_mouse_event(event),
|
||||||
_ => return EventResult::Ignored(None),
|
_ => return EventResult::Ignored(None),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1022,6 +1022,7 @@ shebangs = []
|
||||||
comment-token = "#"
|
comment-token = "#"
|
||||||
language-servers = [ "nil", "nixd" ]
|
language-servers = [ "nil", "nixd" ]
|
||||||
indent = { tab-width = 2, unit = " " }
|
indent = { tab-width = 2, unit = " " }
|
||||||
|
formatter = { command = "nixfmt" }
|
||||||
|
|
||||||
[[grammar]]
|
[[grammar]]
|
||||||
name = "nix"
|
name = "nix"
|
||||||
|
@ -4243,10 +4244,11 @@ comment-token = "#"
|
||||||
block-comment-tokens = ["#-", "-#"]
|
block-comment-tokens = ["#-", "-#"]
|
||||||
indent = { tab-width = 2, unit = " " }
|
indent = { tab-width = 2, unit = " " }
|
||||||
language-servers = ["koto-ls"]
|
language-servers = ["koto-ls"]
|
||||||
|
formatter = {command = "koto", args = ["--format"]}
|
||||||
|
|
||||||
[[grammar]]
|
[[grammar]]
|
||||||
name = "koto"
|
name = "koto"
|
||||||
source = { git = "https://github.com/koto-lang/tree-sitter-koto", rev = "b420f7922d0d74905fd0d771e5b83be9ee8a8a9a" }
|
source = { git = "https://github.com/koto-lang/tree-sitter-koto", rev = "2ffc77c14f0ac1674384ff629bfc207b9c57ed89" }
|
||||||
|
|
||||||
[[language]]
|
[[language]]
|
||||||
name = "gpr"
|
name = "gpr"
|
||||||
|
|
|
@ -5,11 +5,13 @@
|
||||||
"*"
|
"*"
|
||||||
"/"
|
"/"
|
||||||
"%"
|
"%"
|
||||||
|
"^"
|
||||||
"+="
|
"+="
|
||||||
"-="
|
"-="
|
||||||
"*="
|
"*="
|
||||||
"/="
|
"/="
|
||||||
"%="
|
"%="
|
||||||
|
"^="
|
||||||
"=="
|
"=="
|
||||||
"!="
|
"!="
|
||||||
"<"
|
"<"
|
||||||
|
@ -99,12 +101,18 @@
|
||||||
(export
|
(export
|
||||||
(identifier) @namespace)
|
(identifier) @namespace)
|
||||||
|
|
||||||
(call
|
(chain
|
||||||
function: (identifier) @function.method)
|
start: (identifier) @function)
|
||||||
|
|
||||||
(chain
|
(chain
|
||||||
lookup: (identifier) @variable.other.member)
|
lookup: (identifier) @variable.other.member)
|
||||||
|
|
||||||
|
(call
|
||||||
|
function: (identifier)) @function
|
||||||
|
|
||||||
|
(call_arg
|
||||||
|
(identifier) @variable.other.member)
|
||||||
|
|
||||||
[
|
[
|
||||||
(true)
|
(true)
|
||||||
(false)
|
(false)
|
||||||
|
@ -139,13 +147,10 @@
|
||||||
|
|
||||||
(self) @variable.builtin
|
(self) @variable.builtin
|
||||||
|
|
||||||
(variable
|
(type
|
||||||
type: (identifier) @type)
|
_ @type)
|
||||||
|
|
||||||
(arg
|
(arg
|
||||||
(_ (identifier) @variable.parameter))
|
(_ (identifier) @variable.parameter))
|
||||||
|
|
||||||
(ellipsis) @variable.parameter
|
(ellipsis) @variable.parameter
|
||||||
|
|
||||||
(function
|
|
||||||
output_type: (identifier) @type)
|
|
||||||
|
|
|
@ -11,10 +11,6 @@
|
||||||
(call_args
|
(call_args
|
||||||
((call_arg) @parameter.inside . ","? @parameter.around) @parameter.around)
|
((call_arg) @parameter.inside . ","? @parameter.around) @parameter.around)
|
||||||
|
|
||||||
(chain
|
|
||||||
call: (tuple
|
|
||||||
((element) @parameter.inside . ","? @parameter.around) @parameter.around))
|
|
||||||
|
|
||||||
(map
|
(map
|
||||||
((entry_inline) @entry.inside . ","? @entry.around) @entry.around)
|
((entry_inline) @entry.inside . ","? @entry.around) @entry.around)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue