scroll file open from grep panel into view
parent
34d56eb47c
commit
22a7d40d30
|
@ -137,8 +137,8 @@ open_file_buffer_in_new_panel :: proc(state: ^core.State, file_path: string, lin
|
||||||
|
|
||||||
buffer.cursor.line = line
|
buffer.cursor.line = line
|
||||||
buffer.cursor.col = col
|
buffer.cursor.col = col
|
||||||
|
buffer.top_line = buffer.cursor.line
|
||||||
core.update_file_buffer_index_from_cursor(&buffer)
|
core.update_file_buffer_index_from_cursor(&buffer)
|
||||||
core.update_file_buffer_scroll(&buffer)
|
|
||||||
|
|
||||||
buffer_index = len(state.buffers)
|
buffer_index = len(state.buffers)
|
||||||
runtime.append(&state.buffers, buffer);
|
runtime.append(&state.buffers, buffer);
|
||||||
|
@ -417,12 +417,19 @@ make_grep_panel :: proc(state: ^core.State) -> core.Panel {
|
||||||
{
|
{
|
||||||
if panel_state.query_results != nil {
|
if panel_state.query_results != nil {
|
||||||
// query results
|
// query results
|
||||||
ui.open_element(s, nil, {
|
query_result_container := ui.open_element(s, nil, {
|
||||||
dir = .TopToBottom,
|
dir = .TopToBottom,
|
||||||
kind = {ui.Grow{}, ui.Grow{}}
|
kind = {ui.Grow{}, ui.Grow{}}
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
|
container_height := query_result_container.layout.size.y
|
||||||
|
max_results := container_height / 16
|
||||||
|
|
||||||
for result, i in panel_state.query_results {
|
for result, i in panel_state.query_results {
|
||||||
|
if i > max_results {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
ui.open_element(s, nil, {
|
ui.open_element(s, nil, {
|
||||||
dir = .LeftToRight,
|
dir = .LeftToRight,
|
||||||
kind = {ui.Fit{}, ui.Fit{}},
|
kind = {ui.Fit{}, ui.Fit{}},
|
||||||
|
@ -448,6 +455,12 @@ make_grep_panel :: proc(state: ^core.State) -> core.Panel {
|
||||||
|
|
||||||
// file contents
|
// file contents
|
||||||
selected_result := &panel_state.query_results[panel_state.selected_result]
|
selected_result := &panel_state.query_results[panel_state.selected_result]
|
||||||
|
|
||||||
|
core.update_glyph_buffer_from_bytes(
|
||||||
|
&panel_state.glyphs,
|
||||||
|
transmute([]u8)selected_result.file_context,
|
||||||
|
selected_result.line,
|
||||||
|
)
|
||||||
render_glyph_buffer(state, s, &panel_state.glyphs)
|
render_glyph_buffer(state, s, &panel_state.glyphs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ UI_Direction :: enum {
|
||||||
BottomToTop,
|
BottomToTop,
|
||||||
}
|
}
|
||||||
|
|
||||||
open_element :: proc(state: ^State, kind: UI_Element_Kind, layout: UI_Layout) {
|
open_element :: proc(state: ^State, kind: UI_Element_Kind, layout: UI_Layout) -> UI_Element {
|
||||||
e := UI_Element {
|
e := UI_Element {
|
||||||
kind = kind,
|
kind = kind,
|
||||||
layout = layout,
|
layout = layout,
|
||||||
|
@ -93,6 +93,8 @@ open_element :: proc(state: ^State, kind: UI_Element_Kind, layout: UI_Layout) {
|
||||||
state.curr_elements[state.num_curr] = e
|
state.curr_elements[state.num_curr] = e
|
||||||
state.current_open_element = state.num_curr
|
state.current_open_element = state.num_curr
|
||||||
state.num_curr += 1
|
state.num_curr += 1
|
||||||
|
|
||||||
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
close_element :: proc(state: ^State, loc := #caller_location) -> UI_Layout {
|
close_element :: proc(state: ^State, loc := #caller_location) -> UI_Layout {
|
||||||
|
|
10
todo.md
10
todo.md
|
@ -5,6 +5,8 @@
|
||||||
- Closing the only panel crashes
|
- Closing the only panel crashes
|
||||||
|
|
||||||
# Planned Features
|
# Planned Features
|
||||||
|
- [ ] Highlight which panel is currently active
|
||||||
|
- [ ] Persist end of line cursor position
|
||||||
- Testing Harness
|
- Testing Harness
|
||||||
- [x] Replay user inputs and assert buffer contents/changes
|
- [x] Replay user inputs and assert buffer contents/changes
|
||||||
- [ ] Finish writing tests for all current user actions
|
- [ ] Finish writing tests for all current user actions
|
||||||
|
@ -31,7 +33,10 @@
|
||||||
- [x] Query across project
|
- [x] Query across project
|
||||||
- [x] Open file in new buffer
|
- [x] Open file in new buffer
|
||||||
- [x] Open file in new buffer at found location
|
- [x] Open file in new buffer at found location
|
||||||
- [ ] Preview file with context (instead of just the single matched line)
|
- [ ] Preview file with context
|
||||||
|
- [x] Show Context
|
||||||
|
- [ ] Properly show lines numbers
|
||||||
|
- [ ] Don't overlap result list with file preview
|
||||||
- [ ] Open Buffer Search
|
- [ ] Open Buffer Search
|
||||||
- Re-write the UI (again)
|
- Re-write the UI (again)
|
||||||
- [x] New UI
|
- [x] New UI
|
||||||
|
@ -45,7 +50,7 @@
|
||||||
- [x] Yank
|
- [x] Yank
|
||||||
- [x] Delete
|
- [x] Delete
|
||||||
- [ ] Change
|
- [ ] Change
|
||||||
- [ ] Change
|
- [x] Change
|
||||||
- [ ] Change word
|
- [ ] Change word
|
||||||
- [ ] Change inside delimiter
|
- [ ] Change inside delimiter
|
||||||
- Virtual Whitespace
|
- Virtual Whitespace
|
||||||
|
@ -53,4 +58,3 @@
|
||||||
- Command Search and Execution
|
- Command Search and Execution
|
||||||
- Refactor to remove generics added specifically for plugins
|
- Refactor to remove generics added specifically for plugins
|
||||||
- Palette based UI?
|
- Palette based UI?
|
||||||
- Persist end of line cursor position
|
|
Loading…
Reference in New Issue