mirror of
https://github.com/zoriya/telescope.nvim.git
synced 2026-08-16 02:45:09 +00:00
feat(fps): Add refresh style display for telescope
This commit is contained in:
@@ -155,35 +155,19 @@ end
|
||||
actions.select_all = function(prompt_bufnr)
|
||||
local current_picker = action_state.get_current_picker(prompt_bufnr)
|
||||
action_utils.map_entries(prompt_bufnr, function(entry, _, row)
|
||||
if not current_picker._multi:is_selected(entry) then
|
||||
current_picker._multi:add(entry)
|
||||
if current_picker:can_select_row(row) then
|
||||
local caret = current_picker:update_prefix(entry, row)
|
||||
if current_picker._selection_entry == entry and current_picker._selection_row == row then
|
||||
current_picker.highlighter:hi_selection(row, caret:match "(.*%S)")
|
||||
end
|
||||
current_picker.highlighter:hi_multiselect(row, current_picker._multi:is_selected(entry))
|
||||
end
|
||||
end
|
||||
current_picker._multi:add(entry)
|
||||
end)
|
||||
current_picker:get_status_updater(current_picker.prompt_win, current_picker.prompt_bufnr)()
|
||||
current_picker:_redraw(true)
|
||||
end
|
||||
|
||||
--- Drop all entries from the current multi selection.
|
||||
---@param prompt_bufnr number: The prompt bufnr
|
||||
actions.drop_all = function(prompt_bufnr)
|
||||
local current_picker = action_state.get_current_picker(prompt_bufnr)
|
||||
action_utils.map_entries(prompt_bufnr, function(entry, _, row)
|
||||
action_utils.map_entries(prompt_bufnr, function(entry)
|
||||
current_picker._multi:drop(entry)
|
||||
if current_picker:can_select_row(row) then
|
||||
local caret = current_picker:update_prefix(entry, row)
|
||||
if current_picker._selection_entry == entry and current_picker._selection_row == row then
|
||||
current_picker.highlighter:hi_selection(row, caret:match "(.*%S)")
|
||||
end
|
||||
current_picker.highlighter:hi_multiselect(row, current_picker._multi:is_selected(entry))
|
||||
end
|
||||
end)
|
||||
current_picker:get_status_updater(current_picker.prompt_win, current_picker.prompt_bufnr)()
|
||||
current_picker:_redraw(true)
|
||||
end
|
||||
|
||||
--- Toggle multi selection for all entries.
|
||||
@@ -191,17 +175,10 @@ end
|
||||
---@param prompt_bufnr number: The prompt bufnr
|
||||
actions.toggle_all = function(prompt_bufnr)
|
||||
local current_picker = action_state.get_current_picker(prompt_bufnr)
|
||||
action_utils.map_entries(prompt_bufnr, function(entry, _, row)
|
||||
action_utils.map_entries(prompt_bufnr, function(entry)
|
||||
current_picker._multi:toggle(entry)
|
||||
if current_picker:can_select_row(row) then
|
||||
local caret = current_picker:update_prefix(entry, row)
|
||||
if current_picker._selection_entry == entry and current_picker._selection_row == row then
|
||||
current_picker.highlighter:hi_selection(row, caret:match "(.*%S)")
|
||||
end
|
||||
current_picker.highlighter:hi_multiselect(row, current_picker._multi:is_selected(entry))
|
||||
end
|
||||
end)
|
||||
current_picker:get_status_updater(current_picker.prompt_win, current_picker.prompt_bufnr)()
|
||||
current_picker:_redraw(true)
|
||||
end
|
||||
|
||||
--- Scroll the preview window up
|
||||
|
||||
@@ -193,23 +193,16 @@ action_set.scroll_previewer = function(prompt_bufnr, direction)
|
||||
end
|
||||
|
||||
--- Scrolls the results up or down.
|
||||
--- Defaults to a half page scroll, but can be overridden using the `scroll_speed`
|
||||
--- option in `layout_config`. See |telescope.layout| for more details.
|
||||
--- Moves `count` movements.
|
||||
---@param prompt_bufnr number: The prompt bufnr
|
||||
---@param direction number: The direction of the scrolling
|
||||
-- Valid directions include: "1", "-1"
|
||||
action_set.scroll_results = function(prompt_bufnr, direction)
|
||||
local status = state.get_status(prompt_bufnr)
|
||||
local default_speed = vim.api.nvim_win_get_height(status.results_win) / 2
|
||||
local speed = status.picker.layout_config.scroll_speed or default_speed
|
||||
local count = vim.v.count
|
||||
count = count == 0 and 1 or count
|
||||
count = a.nvim_get_mode().mode == "n" and count or 1
|
||||
|
||||
local input = direction > 0 and [[]] or [[]]
|
||||
|
||||
vim.api.nvim_win_call(status.results_win, function()
|
||||
vim.cmd([[normal! ]] .. math.floor(speed) .. input)
|
||||
end)
|
||||
|
||||
action_set.shift_selection(prompt_bufnr, math.floor(speed) * direction)
|
||||
action_state.get_current_picker(prompt_bufnr):shift_offset(count * direction)
|
||||
end
|
||||
|
||||
-- ==================================================
|
||||
|
||||
Reference in New Issue
Block a user