NeoMutt  2025-12-11-980-ge38c27
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 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 (struct Mapping *key_names)
 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 93 of file extended.c.

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

◆ ext_keys_init()

void ext_keys_init ( struct Mapping * key_names)

Initialise map of ncurses extended keys.

Parameters
key_namesArray of key name/value mappings to populate

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; key_names[i].name; i++)
119 {
120 if (key_names[i].value == -1)
121 {
122 const char *keyname = ext_key_find(key_names[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 key_names[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:93
int value
Integer value.
Definition mapping.h:35
const char * name
String value.
Definition mapping.h:34
const char * mutt_tigetstr(const char *name)
Get terminal capabilities.
Definition terminal.c:66
+ 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 48 of file extended.c.

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