NeoMutt  2025-12-11-911-gd8d604
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
extended.c
Go to the documentation of this file.
1
22
28
29#include "config.h"
30#include <stdbool.h>
31#include <strings.h>
32#include "mutt/lib.h"
33#include "core/lib.h"
34#include "gui/lib.h"
35#include "extended.h"
36#include "module_data.h"
37
41struct Extkey
42{
43 const char *name;
44 const char *sym;
45};
46
50static const struct Extkey ExtKeys[] = {
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};
85
95const char *ext_key_find(const char *key)
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}
104
116void ext_keys_init(struct Mapping *key_names)
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}
Convenience wrapper for the core headers.
const char * ext_key_find(const char *key)
Find the curses name for a key.
Definition extended.c:95
static const struct Extkey ExtKeys[]
Mapping between NeoMutt and Curses key names.
Definition extended.c:50
void ext_keys_init(struct Mapping *key_names)
Initialise map of ncurses extended keys.
Definition extended.c:116
Set up the extended keys.
Convenience wrapper for the gui headers.
Key private Module data.
Convenience wrapper for the library headers.
Map key names from NeoMutt's style to Curses style.
Definition extended.c:42
const char * sym
Curses key name.
Definition extended.c:44
const char * name
NeoMutt key name.
Definition extended.c:43
Mapping between user-readable string and a constant.
Definition mapping.h:33
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