Skip to content

Commit

Permalink
core: add incremental search in commands history (issue #2040)
Browse files Browse the repository at this point in the history
Changes:

- move key ctrl+r to ctrl+s
- add key ctrl+r to search in commands history
- add option `search_history` in command `/input`
- add key context "histsearch"
- add option weechat.look.buffer_search_history
- add buffer variables "text_search_direction", "text_search_history" and "text_search_ptr_history"
  • Loading branch information
flashcode committed Nov 11, 2023
1 parent b2ce312 commit b83b428
Show file tree
Hide file tree
Showing 38 changed files with 1,312 additions and 387 deletions.
1 change: 1 addition & 0 deletions ChangeLog.adoc
Expand Up @@ -15,6 +15,7 @@ For a list of important changes that require manual actions, please look at rele

New features::

* core: move key kbd:[Ctrl+r] to kbd:[Ctrl+s], add key kbd:[Ctrl+r] to search in commands history, add option `search_history` in command `/input`, add key context "histsearch", add option weechat.look.buffer_search_history, add buffer variables "text_search_direction", "text_search_history" and "text_search_ptr_history" (issue #2040)
* core: display only version with command `/version`, add options `-o` and `-ol` in command `/upgrade`
* core: add number of processes in command `/sys waitpid`
* core, alias, trigger: allow wildcard in commands `/bar`, `/item`, `/proxy`, `/alias` and `/trigger` (issue #1956)
Expand Down
75 changes: 68 additions & 7 deletions doc/de/weechat_user.de.adoc
Expand Up @@ -920,11 +920,37 @@ In der _input_ Bar lautet die Standardeinstellung:
| Item | Beispiel | Beschreibung
| input_prompt | `[@Flashy(i)]` | Input prompt, für irc: Nick und Modi (Modus "+i" bedeutet auf libera, unsichtbar).
| away | `(away)` | Abwesenheitsanzeige.
| input_search | `[Search (~ str,msg)]` | Suchindikatoren ("`~`": Groß-und Kleinschreibung ignorieren, "`==`": Groß-und Kleinschreibung berücksichtigen, "`str`": einfache Textsuche, "`regex`": suche mit regulären Ausdrücken, "`msg`": Suche in Nachrichten, "`pre`": Suche in Präfix, "`pre\|msg`": Suche in Präfix und Nachrichten).
// TRANSLATION MISSING
| input_search | `[Search lines (~ str,msg)]` | Suchindikatoren ("`~`": Groß-und Kleinschreibung ignorieren, "`==`": Groß-und Kleinschreibung berücksichtigen, "`str`": einfache Textsuche, "`regex`": suche mit regulären Ausdrücken, "`msg`": Suche in Nachrichten, "`pre`": Suche in Präfix, "`pre\|msg`": Suche in Präfix und Nachrichten).
// TRANSLATION MISSING
| input_paste | `[Paste 7 lines ? [ctrl-y] Ja [ctrl-n] Nein]` | Nachfrage ob sieben Zeilen eingefügt werden sollen.
| input_text | `hi peter!` | Text der eingegeben wird.
|===

// TRANSLATION MISSING
There are two search modes:

// TRANSLATION MISSING
* search in lines, for example `[Search lines (~ str,msg)]`, with the following info:
** `~`: Groß-und Kleinschreibung ignorieren
** `==`: Groß-und Kleinschreibung berücksichtigen
** `str`: einfache Textsuche
** `regex`: suche mit regulären Ausdrücken
** `msg`: Suche in Nachrichten
** `pre`: Suche in Präfix
** `pre\|msg`: Suche in Präfix und Nachrichten
// TRANSLATION MISSING
* search in commands history, for example `[Search command (~ str,local)]`,
with the following info:
** `~`: Groß-und Kleinschreibung ignorieren
** `==`: Groß-und Kleinschreibung berücksichtigen
** `str`: einfache Textsuche
** `regex`: suche mit regulären Ausdrücken
// TRANSLATION MISSING
** `local`: search in buffer local history
// TRANSLATION MISSING
** `global`: search in global history.

In der _nicklist_ Bar lautet die Standardeinstellung:

[width="100%",cols="^3,^3,9",options="header"]
Expand Down Expand Up @@ -1630,7 +1656,10 @@ Sie können mit dem Befehl <<command_weechat_key,/key>> geändert und neue hinzu
[width="100%",cols="^.^3,.^8,.^5",options="header"]
|===
| Taste | Beschreibung | Befehl
| kbd:[Ctrl+r] | Textsuche im Verlaufsspeicher des Buffers (siehe <<key_bindings_search_context,Tasten für Such-Kontext>>). | `+/input search_text_here+`
// TRANSLATION MISSING
| kbd:[Ctrl+r] | Search for text in commands history (see <<key_bindings_histsearch_context,keys for context "histsearch">>). | `+/input search_history+`
// TRANSLATION MISSING
| kbd:[Ctrl+s] | Search for text in buffer lines (see <<key_bindings_search_context,keys for context "search">>). | `+/input search_text_here+`
| kbd:[Ctrl+s], kbd:[Ctrl+u] | setzt für alle Buffer die Markierung für ungelesene Nachrichten. | `+/allbuf /buffer set unread+`
| kbd:[Ctrl+x] | Wechseln Sie den aktuellen Buffer, wenn diese zusammengefügt worden sind, z.B. zwischen IRC-Serverbuffer wechseln. | `+/buffer switch+`
| kbd:[Alt+x] | Zoom eines zusammengefügten Buffers (kbd:[Alt+x] ein zweites mal: alle zusammengefügten Buffer werden angezeigt). | `+/buffer zoom+`
Expand Down Expand Up @@ -1733,23 +1762,55 @@ Sie können mit dem Befehl <<command_weechat_key,/key>> geändert und neue hinzu
[[key_bindings_search_context]]
=== Suchkontext

Diese Tasten werden im Kontext "search" verwendet (wenn kbd:[Ctrl+r] genutzt wird um
in einem Buffer nach einem Text zu suchen).
// TRANSLATION MISSING
These keys are used in context "search" (when kbd:[Ctrl+s] is pressed to search
text in buffer lines).

[width="100%",cols="^.^3,.^8,.^5",options="header"]
|===
| Taste | Beschreibung | Befehl
| kbd:[Ctrl+r] | Wechsel des Suchmodus: einfache Textsuche (Standard), reguläre Ausdrücke. | `+/input search_switch_regex+`
| kbd:[Ctrl+x] | Wechsel des Suchmodus: einfache Textsuche (Standard), reguläre Ausdrücke. | `+/input search_switch_regex+`
| kbd:[Alt+c] | auf Groß-/Kleinschreibung umschalten. | `+/input search_switch_case+`
| kbd:[Tab] | wechselt Suche in: Nachricht (Standard), im Präfix, Präfix + Nachricht. | `+/input search_switch_where+`
| kbd:[↑] | sucht vorheriger Zeile. | `+/input search_previous+`
| kbd:[↓] | sucht nächste Zeile . | `+/input search_next+`
| kbd:[Ctrl+r] +
kbd:[↑] | sucht vorheriger Zeile. | `+/input search_previous+`
| kbd:[Ctrl+s] +
kbd:[↓] | sucht nächste Zeile . | `+/input search_next+`
| kbd:[Enter] +
kbd:[Ctrl+j] +
kbd:[Ctrl+m] | beendet Suche ab aktueller Position. | `+/input search_stop_here+`
| kbd:[Ctrl+q] | Suche wird abgebrochen und der Bildlauf wird auf die Vortextsuche zurückgesetzt. | `+/input search_stop+`
|===

// TRANSLATION MISSING
[[key_bindings_histsearch_context]]
=== History search context

// TRANSLATION MISSING
These keys are used in context "histsearch" (when kbd:[Ctrl+r] is pressed to
search text in commands history).

[width="100%",cols="^.^3,.^8,.^5",options="header"]
|===
| Taste | Beschreibung | Befehl
| kbd:[Ctrl+x] | Wechsel des Suchmodus: einfache Textsuche (Standard), reguläre Ausdrücke. | `+/input search_switch_regex+`
| kbd:[Alt+c] | auf Groß-/Kleinschreibung umschalten. | `+/input search_switch_case+`
// TRANSLATION MISSING
| kbd:[Tab] | Switch search in: buffer local history (default), global history. | `+/input search_switch_where+`
// TRANSLATION MISSING
| kbd:[Ctrl+r] +
kbd:[↑] | Search in previous (older) history entries. | `+/input search_previous+`
// TRANSLATION MISSING
| kbd:[Ctrl+s] +
kbd:[↓] | Search in next (newer) history entries. | `+/input search_next+`
// TRANSLATION MISSING
| kbd:[Enter] +
kbd:[Ctrl+j] +
kbd:[Ctrl+m] | Stop search and use matching input. | `+/input search_stop_here+`
// TRANSLATION MISSING
| kbd:[Ctrl+q] | Stop search and restore input to its initial value. | `+/input search_stop+`
|===

[[key_bindings_cursor_context]]
=== Cursor-Kontext

Expand Down
19 changes: 17 additions & 2 deletions doc/en/weechat_plugin_api.en.adoc
Expand Up @@ -14120,9 +14120,22 @@ Arguments:
** _num_history_: number of commands in history
** _text_search_: text search type:
*** 0: no search at this moment
*** 1: backward search (direction: oldest messages)
*** 2: forward search (direction: newest messages)
*** 1: search in buffer lines
*** 2: search in commands history
** _text_search_direction_: direction for search:
*** 0: backward search (direction: oldest messages/commands)
*** 1: forward search (direction: newest messages/commands)
** _text_search_exact_: 1 if text search is case sensitive
** _text_search_regex_: 1 if searching with a regular expression
** _text_search_where_:
*** 0: no search at this moment
*** 1: search in message
*** 2: search in prefix
*** 3: search in prefix and message
** _text_search_history_:
*** 0: no search at this moment
*** 1: search in buffer local history
*** 2: search in global history
** _text_search_found_: 1 if text found, otherwise 0

Return value:
Expand Down Expand Up @@ -14227,6 +14240,8 @@ Arguments:
* _property_: property name:
** _plugin_: pointer to plugin which created this buffer (NULL for WeeChat main
buffer)
** _text_search_regex_compiled_: compiled regular expression
** _text_search_ptr_history_: history found
** _highlight_disable_regex_compiled_: regular expression _highlight_disable_regex_ compiled
** _highlight_regex_compiled_: regular expression _highlight_regex_ compiled

Expand Down
3 changes: 3 additions & 0 deletions doc/en/weechat_relay_protocol.en.adoc
Expand Up @@ -712,11 +712,14 @@ inl:
input_buffer_1st_display: 0
num_history: 0
text_search: 0
text_search_direction: 0
text_search_exact: 0
text_search_regex: 0
text_search_regex_compiled: '0x0'
text_search_where: 0
text_search_history: 0
text_search_found: 0
text_search_ptr_history: '0x0'
text_search_input: None
highlight_words: None
highlight_disable_regex: None
Expand Down
58 changes: 51 additions & 7 deletions doc/en/weechat_user.en.adoc
Expand Up @@ -914,11 +914,30 @@ Bar _input_ has following default items:
| Item | Example | Description
| input_prompt | `[@Flashy(i)]` | Input prompt, for irc: nick and modes (mode "+i" means invisible on libera).
| away | `(away)` | Away indicator.
| input_search | `[Search (~ str,msg)]` | Search indicator ("`~`": case insensitive, "`==`": case sensitive, "`str`": search string, "`regex`": search regular expression, "`msg`": search in messages, "`pre`": search in prefixes, "`pre\|msg`": search in prefixes and messages).
| input_search | `[Search lines (~ str,msg)]` | Search indicator (see below)
| input_paste | `[Paste 7 lines ? [ctrl-y] Yes [ctrl-n] No]` | Question to user for pasting lines.
| input_text | `hi peter!` | Input text.
|===

There are two search modes:

* search in lines, for example `[Search lines (~ str,msg)]`, with the following info:
** `~`: case insensitive
** `==`: case sensitive
** `str`: search string
** `regex`: search regular expression
** `msg`: search in messages
** `pre`: search in prefixes
** `pre\|msg`: search in prefixes and messages.
* search in commands history, for example `[Search command (~ str,local)]`,
with the following info:
** `~`: case insensitive
** `==`: case sensitive
** `str`: search string
** `regex`: search regular expression
** `local`: search in buffer local history
** `global`: search in global history.

Bar _nicklist_ has following default items:

[width="100%",cols="^3,^3,9",options="header"]
Expand Down Expand Up @@ -1613,7 +1632,8 @@ They can be changed and new ones can be added with the <<command_weechat_key,/ke
[width="100%",cols="^.^3,.^8,.^5",options="header"]
|===
| Key | Description | Command
| kbd:[Ctrl+r] | Search for text in buffer history (see <<key_bindings_search_context,keys for search context>>). | `+/input search_text_here+`
| kbd:[Ctrl+r] | Search for text in commands history (see <<key_bindings_histsearch_context,keys for context "histsearch">>). | `+/input search_history+`
| kbd:[Ctrl+s] | Search for text in buffer lines (see <<key_bindings_search_context,keys for context "search">>). | `+/input search_text_here+`
| kbd:[Ctrl+s], kbd:[Ctrl+u] | Set unread marker on all buffers. | `+/allbuf /buffer set unread+`
| kbd:[Ctrl+x] | Switch current buffer if buffers are merged with same number, for example switch to another IRC server buffer. | `+/buffer switch+`
| kbd:[Alt+x] | Zoom on merged buffer (kbd:[Alt+x] again: display all merged buffers). | `+/buffer zoom+`
Expand Down Expand Up @@ -1716,23 +1736,47 @@ They can be changed and new ones can be added with the <<command_weechat_key,/ke
[[key_bindings_search_context]]
=== Search context

These keys are used in context "search" (when kbd:[Ctrl+r] is pressed to search
text in buffer).
These keys are used in context "search" (when kbd:[Ctrl+s] is pressed to search
text in buffer lines).

[width="100%",cols="^.^3,.^8,.^5",options="header"]
|===
| Key | Description | Command
| kbd:[Ctrl+r] | Switch search type: string (default), regular expression. | `+/input search_switch_regex+`
| kbd:[Ctrl+x] | Switch search type: string (default), regular expression. | `+/input search_switch_regex+`
| kbd:[Alt+c] | Switch exact case for search. | `+/input search_switch_case+`
| kbd:[Tab] | Switch search in: messages (default), prefixes, prefixes + messages. | `+/input search_switch_where+`
| kbd:[↑] | Search previous line. | `+/input search_previous+`
| kbd:[↓] | Search next line. | `+/input search_next+`
| kbd:[Ctrl+r] +
kbd:[↑] | Search previous line. | `+/input search_previous+`
| kbd:[Ctrl+s] +
kbd:[↓] | Search next line. | `+/input search_next+`
| kbd:[Enter] +
kbd:[Ctrl+j] +
kbd:[Ctrl+m] | Stop search at current position. | `+/input search_stop_here+`
| kbd:[Ctrl+q] | Stop search and reset scroll to pre-text search state. | `+/input search_stop+`
|===

[[key_bindings_histsearch_context]]
=== History search context

These keys are used in context "histsearch" (when kbd:[Ctrl+r] is pressed to
search text in commands history).

[width="100%",cols="^.^3,.^8,.^5",options="header"]
|===
| Key | Description | Command
| kbd:[Ctrl+x] | Switch search type: string (default), regular expression. | `+/input search_switch_regex+`
| kbd:[Alt+c] | Switch exact case for search. | `+/input search_switch_case+`
| kbd:[Tab] | Switch search in: buffer local history (default), global history. | `+/input search_switch_where+`
| kbd:[Ctrl+r] +
kbd:[↑] | Search in previous (older) history entries. | `+/input search_previous+`
| kbd:[Ctrl+s] +
kbd:[↓] | Search in next (newer) history entries. | `+/input search_next+`
| kbd:[Enter] +
kbd:[Ctrl+j] +
kbd:[Ctrl+m] | Stop search and use matching input. | `+/input search_stop_here+`
| kbd:[Ctrl+q] | Stop search and restore input to its initial value. | `+/input search_stop+`
|===

[[key_bindings_cursor_context]]
=== Cursor context

Expand Down
19 changes: 17 additions & 2 deletions doc/fr/weechat_plugin_api.fr.adoc
Expand Up @@ -14427,9 +14427,22 @@ Paramètres :
** _num_history_ : nombre de commandes dans l'historique
** _text_search_ : type de recherche de texte :
*** 0 : pas de recherche en cours
*** 1 : recherche arrière (vers les messages les plus anciens)
*** 2 : recherche avant (vers les messages les plus récents)
*** 1 : recherche dans les lignes du tampon
*** 2 : recherche dans l'historique de commandes
** _text_search_direction_ : direction pour la recherche :
*** 0 : recherche arrière (vers les messages/commandes plus anciens)
*** 1 : recherche avant (vers les messages/commandes plus récents)
** _text_search_exact_ : 1 si la recherche de texte est sensible à la casse
** _text_search_regex_ : 1 si la recherche est avec une expression régulière
** _text_search_where_ :
*** 0 : pas de recherche en cours
*** 1 : recherche dans le message
*** 2 : recherche dans le préfixe
*** 3 : recherche dans le préfixe et le message
** _text_search_history_:
*** 0 : pas de recherche en cours
*** 1 : recherche dans l'historique local du tampon
*** 2 : recherche dans l'historique global
** _text_search_found_ : 1 si du texte a été trouvé, sinon 0

Valeur de retour :
Expand Down Expand Up @@ -14538,6 +14551,8 @@ Paramètres :
* _property_ : nom de la propriété :
** _plugin_ : pointeur vers l'extension qui a créé le tampon (NULL pour le
tampon principal WeeChat)
** _text_search_regex_compiled_ : expression régulière compilée
** _text_search_ptr_history_ : entrée d'historique trouvée
** _highlight_disable_regex_compiled_ : expression régulière _highlight_disable_regex_ compilée
** _highlight_regex_compiled_ : expression régulière _highlight_regex_ compilée

Expand Down
3 changes: 3 additions & 0 deletions doc/fr/weechat_relay_protocol.fr.adoc
Expand Up @@ -728,11 +728,14 @@ inl:
input_buffer_1st_display: 0
num_history: 0
text_search: 0
text_search_direction: 0
text_search_exact: 0
text_search_regex: 0
text_search_regex_compiled: '0x0'
text_search_where: 0
text_search_history: 0
text_search_found: 0
text_search_ptr_history: '0x0'
text_search_input: None
highlight_words: None
highlight_disable_regex: None
Expand Down

0 comments on commit b83b428

Please sign in to comment.