NeoMutt  2025-09-05-43-g177ed6
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 "lib.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

static const char * find_ext_name (const char *key)
 Find the curses name for a key.
 
void init_extended_keys (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

◆ find_ext_name()

static const char * find_ext_name ( const char * key)
static

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 j = 0; ExtKeys[j].name; j++)
96 {
97 if (strcasecmp(key, ExtKeys[j].name) == 0)
98 return ExtKeys[j].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:

◆ init_extended_keys()

void init_extended_keys ( 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 113 of file extended.c.

114{
115 use_extended_names(true);
116
117 for (int j = 0; KeyNames[j].name; j++)
118 {
119 if (KeyNames[j].value == -1)
120 {
121 const char *keyname = find_ext_name(KeyNames[j].name);
122
123 if (keyname)
124 {
125 const char *s = mutt_tigetstr((char *) keyname);
126 if (s && ((long) (s) != -1))
127 {
128 int code = key_defined(s);
129 if (code > 0)
130 KeyNames[j].value = code;
131 }
132 }
133 }
134 }
135}
static const char * find_ext_name(const char *key)
Find the curses name for a key.
Definition extended.c:93
struct Mapping KeyNames[]
Key name lookup table.
Definition lib.c:59
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 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};