NeoMutt  2025-12-11-435-g4ac674
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
extended.c File Reference

Set up the extended keys. More...

#include "config.h"
#include <stdbool.h>
#include <strings.h>
#include "mutt/lib.h"
#include "gui/lib.h"
#include "extended.h"
#include "keymap.h"
+ Include dependency graph for extended.c:

Go to the source code of this file.

Data Structures

struct  Extkey
 Map key names from NeoMutt's style to Curses style. More...
 

Functions

const char * ext_key_find (const char *key)
 Find the curses name for a key.
 
void ext_keys_init (void)
 Initialise map of ncurses extended keys.
 

Variables

static const struct Extkey ExtKeys []
 Mapping between NeoMutt and Curses key names.
 

Detailed Description

Set up the extended keys.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file extended.c.

Function Documentation

◆ ext_key_find()

const char * ext_key_find ( const char * key)

Find the curses name for a key.

Parameters
keyKey name
Return values
ptrCurses name

Look up NeoMutt's name for a key and find the ncurses extended name for it.

Note
This returns a static string.

Definition at line 94 of file extended.c.

95{
96 for (int i = 0; ExtKeys[i].name; i++)
97 {
98 if (strcasecmp(key, ExtKeys[i].name) == 0)
99 return ExtKeys[i].sym;
100 }
101 return 0;
102}
static const struct Extkey ExtKeys[]
Mapping between NeoMutt and Curses key names.
Definition extended.c:49
+ Here is the caller graph for this function:

◆ ext_keys_init()

void ext_keys_init ( void )

Initialise map of ncurses extended keys.

Determine the keycodes for ncurses extended keys and fill in the KeyNames array.

This function must be called after initscr(), or mutt_tigetstr() fails. This creates a bit of a chicken-and-egg problem because km_init() is called prior to start_curses(). This means that the default keybindings can't include any of the extended keys because they won't be defined until later.

Definition at line 114 of file extended.c.

115{
116 use_extended_names(true);
117
118 for (int i = 0; KeyNames[i].name; i++)
119 {
120 if (KeyNames[i].value == -1)
121 {
122 const char *keyname = ext_key_find(KeyNames[i].name);
123
124 if (keyname)
125 {
126 const char *s = mutt_tigetstr((char *) keyname);
127 if (s && ((long) (s) != -1))
128 {
129 int code = key_defined(s);
130 if (code > 0)
131 KeyNames[i].value = code;
132 }
133 }
134 }
135 }
136}
const char * ext_key_find(const char *key)
Find the curses name for a key.
Definition extended.c:94
struct Mapping KeyNames[]
Key name lookup table.
Definition keymap.c:42
const char * mutt_tigetstr(const char *name)
Get terminal capabilities.
Definition terminal.c:68
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ ExtKeys

const struct Extkey ExtKeys[]
static

Mapping between NeoMutt and Curses key names.

Definition at line 49 of file extended.c.

49 {
50 { "<c-up>", "kUP5" },
51 { "<s-up>", "kUP" },
52 { "<a-up>", "kUP3" },
53
54 { "<s-down>", "kDN" },
55 { "<a-down>", "kDN3" },
56 { "<c-down>", "kDN5" },
57
58 { "<c-right>", "kRIT5" },
59 { "<s-right>", "kRIT" },
60 { "<a-right>", "kRIT3" },
61
62 { "<s-left>", "kLFT" },
63 { "<a-left>", "kLFT3" },
64 { "<c-left>", "kLFT5" },
65
66 { "<s-home>", "kHOM" },
67 { "<a-home>", "kHOM3" },
68 { "<c-home>", "kHOM5" },
69
70 { "<s-end>", "kEND" },
71 { "<a-end>", "kEND3" },
72 { "<c-end>", "kEND5" },
73
74 { "<s-next>", "kNXT" },
75 { "<a-next>", "kNXT3" },
76 { "<c-next>", "kNXT5" },
77
78 { "<s-prev>", "kPRV" },
79 { "<a-prev>", "kPRV3" },
80 { "<c-prev>", "kPRV5" },
81
82 { 0, 0 },
83};