lanoxx / tilda

A Gtk based drop down terminal for Linux and Unix
GNU General Public License v2.0
1.28k stars 161 forks source link

Implement a search function to search through the terminal #159

Closed lanoxx closed 9 years ago

lanoxx commented 9 years ago

gnome-panel has this, we should have it too.

lanoxx commented 9 years ago

Should be activated with CTRL+SHIFT+F by default and keyboard shortcut should be configurable.

lanoxx commented 9 years ago

This is just an quick and dirty implementation to see whats necessary to get things working. I imagine the search bar should be hidden by default and be shown on CTRL+SHIFT+F. There should be the commonly used options to configure search:

Todos:

@pik Would you be interested to help me with this?

pik commented 9 years ago

I'd be happy to help but I don't think I will have time to look at it until this weekend.

lanoxx commented 9 years ago

No problem, I will probably not look at it before either. The patch from yesterday was just a quick hack to see how much work it would really be. If you do work on this just drop a message here, so we don't do something redundantly.

pik commented 9 years ago

Will do, btw how do you feel about the dialog-box style search vs. the docked-style search? I personally feel the docked style is much nicer in a text-editor, but I haven't tried either one much in a terminal.

lanoxx commented 9 years ago

I would prefer the docked style - if it works well. There are some issues that I can think of:

If these turn out to be no problem, then lets go with the docked style, otherwise we create a dialog. The problems I have with a dialog it that one always needs to ALT+TAB between the window and the dialog while searching. With the docked style we could just listen to ESC and then focus the terminal again and/or close the searchbar.

pik commented 9 years ago

Yeah Docked style sounds better - the minus is that it's hard to fit whole word check-boxes into a dock e.g. Wrap Around, Match CaseOnly etc. so probably we should use small-icons with tooltips (Sublime does this).

edit (I made a little bit of progress): https://github.com/pik/tilda/tree/wip/search

The checkboxes really need to be replaced by toggelable icons. Also I'm not sure we need a bar the size of the entire pane? For example I think the iterm2 search bar looks very nice (though it's missing regex and other search-options).

edit(2): Now that I'm thinking about it, what about back and forward buttons and just two toggles (regex, matchcase)? - wrap-around-search really should be default, search-backwards should be an action button (prev term, next term) and match only whole word / match start of word are easy enough to add in a regex pattern.

lanoxx commented 9 years ago

I added another commit to focus the search entry when the search bar is toggled on: 3c6223253fe267bea3125bd9746f9176727d2d8b

lanoxx commented 9 years ago

The showing/hiding of the label and the wrap around flag should work now too. I am still thinking if it makes sense to change the label message depending on whether the search hit the search direction.

I think that it should be possible to search by pressing enter when the GtkEntry has focus, but so far I was not able to get that working.

pik commented 9 years ago

@lanoxx It's looking good. Changing the warning and perhaps also an option to change bar placement (top/bottom of the terminal) would be good additions. Another might be to hide the warning if the search has hit bottom but entry-text has changed?

I'll add the Enter-key.

lanoxx commented 9 years ago

@pik, Good point. We might need to connect to the changed signal and reset the last search flag if the text has changed. Because we dont actually know if the new text might not give a result without wrapping around.

pik commented 9 years ago

edit: oh yes, actually no reason to check the text, just drop the warning on key-press event, it can be in the same-conditional as checking for return.

lanoxx commented 9 years ago

I just commited one patch to hide the label when the text changed. I used the GtkEditable::changed signal instead of key-press, as that also catches copy/paste changes.

lanoxx commented 9 years ago

See: c7c6b288739aa0814502b13d5b3427cdcc52bebd

lanoxx commented 9 years ago

I added commit 3fd33c3ca77096cffe5a58762b4c39a6fde83d47 to keep the tw->terms structure synchronized with the tab order. This fixes a problem that prevented the Terminal to gain focus after the search bar was hidden. I used your solution to lookup the VteTerminal pointer relative from the tab child, but that might break if the UI is changed. However I could not find a way to get the old position of the tab in the callback. Another solution might be to track the number of the currently active tab in the tw structure, since only active tabs can be dragged.

lanoxx commented 9 years ago

I actually found a better solution: efebf416244e97cf603dce5dd42614b16099cfdc

lanoxx commented 9 years ago

@pik I just cleanup the commits and rebased everything on master. I think this can be merged into master now. Do you have any final comments?

pik commented 9 years ago

@lanoxx So one minor comment is I think I was wrong about preferring the enums over booleans e.g. https://github.com/pik/tilda/commit/f10055487188c9d22116e11bc3a9103e948187e2 is definitely more terse.

Either way it looks good to me.

lanoxx commented 9 years ago

Ok, it took some time to rebase it, but I wanted to eliminate the enums from all commits, so this is really a clean series of commits.

I also added one more small feature, the search bar can now be hidden by using the escape key when the search entry has focus, that makes it easier to hide the search bar

Thanks a lot for helping with this feature. :+1: