Closed ghost closed 7 years ago
You mean the whole search dialogue or just the selection of directory and display of results?
In principle, both are possible. One could hijack Textadept's find_in_file
function like other overwritten functions.
As for the working drectory, not sure I understand the question, do you mean the directory Textadept was started from?
Maybe something like
keys.cj = function()
local working_dir = lfs.currentdir()
textredux.fs.snapopen(working_dir)
end
Either would be fine. I am not very proficient with lua so I thought I'd ask first before trying to break the code myself. A quick question about the save/save_as functions. These are not replaced when using require('textredux').hijack() correct? I tried using the replacements provided by TR but either I was using them wrong or something about them is broken.
Sorry about the confusion with the working directory thing. I was looking for a way to use quick_open in TR but after using the hijack option it works fine now.
It would of course be possible (but likely be a a lot of work) to have the full search box as a Textredux dialog, but if it's just about replacing the "find in files" it should be possible by something like (as a starting point):
ui.find.find_in_files = function(dir, filter)
local list = textredux.core.list.new(
'Searching: '..ui.find.find_entry_text, -- list title
{'one', 'two', 'three'}, -- list items
function (list, item) -- on selection callback
ui.statusbar_text = 'You selected ' .. item
end
)
--Show the list.
list:show()
ui.goto_view(_VIEWS[1])
end
But maybe it's easier to have a separate 'find in files' function written in Textredux, adapting it from Textadept's.
The save_as
is indeed broken (I think it's not possible to "save as" when there is a overlap with the current name) - that's why I removed it from hijack.
How would you start the search after selecting a different directory though? After changing the directory in the default "find in files" function you can only start it by actually clicking the "open" button. In order to make this completely keyboard driven you might need a shortcut to start the actual search.
That's true - but basically you can have any kind of keyboard interaction in a Textredux list you want. In the buffer selection list for example you can also close buffers ...
Yeah that's right, the ctrl+d functionality is pretty nice. Would you mind implementing a simple "find in files" function once you have some time to spare?
It's definitely something useful to have, also interfacing with tools like ack
or ag
could be an option ...
I'll keep this issue open as a feature request!
I cobbled together some code that accomplishes my goal (keyboard driven FIF search for TR), however it's quite shoddy and should probably not be merged. More like a POC to show it can be done.
I have improved my solution for this to a point where I am quite happy with it so I think this issue can be closed now.
Glas you found a solution and thanks for the request -- do you have a link, so others (and I) could try it?
Is it possible to have TR take over the find_in_files dialog?
Unrelated but how do you make the TR version of snapopen accept the current working dir as starting point?