NeoMutt  2025-12-11-911-gd8d604
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 "core/lib.h"
#include "gui/lib.h"
#include "extended.h"
#include "module_data.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 95 of file extended.c.

96{
97 for (int i = 0; ExtKeys[i].name; i++)
98 {
99 if (strcasecmp(key, ExtKeys[i].name) == 0)
100 return ExtKeys[i].sym;
101 }
102 return 0;
103}
static const struct Extkey ExtKeys[]
Mapping between NeoMutt and Curses key names.
Definition extended.c:50
+ 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 116 of file extended.c.

117{
118 use_extended_names(true);
119
120 for (int i = 0; key_names[i].name; i++)
121 {
122 if (key_names[i].value == -1)
123 {
124 const char *keyname = ext_key_find(key_names[i].name);
125
126 if (keyname)
127 {
128 const char *s = mutt_tigetstr((char *) keyname);
129 if (s && ((long) (s) != -1))
130 {
131 int code = key_defined(s);
132 if (code > 0)
133 key_names[i].value = code;
134 }
135 }
136 }
137 }
138}
const char * ext_key_find(const char *key)
Find the curses name for a key.
Definition extended.c:95
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 50 of file extended.c.

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