1 | #ifndef NVIM_MESSAGE_H |
2 | #define NVIM_MESSAGE_H |
3 | |
4 | #include <stdbool.h> |
5 | #include <stdarg.h> |
6 | #include <stddef.h> |
7 | |
8 | #include "nvim/macros.h" |
9 | #include "nvim/types.h" |
10 | #include "nvim/grid_defs.h" |
11 | |
12 | /* |
13 | * Types of dialogs passed to do_dialog(). |
14 | */ |
15 | #define VIM_GENERIC 0 |
16 | #define VIM_ERROR 1 |
17 | #define VIM_WARNING 2 |
18 | #define VIM_INFO 3 |
19 | #define VIM_QUESTION 4 |
20 | #define VIM_LAST_TYPE 4 /* sentinel value */ |
21 | |
22 | /* |
23 | * Return values for functions like vim_dialogyesno() |
24 | */ |
25 | #define VIM_YES 2 |
26 | #define VIM_NO 3 |
27 | #define VIM_CANCEL 4 |
28 | #define VIM_ALL 5 |
29 | #define VIM_DISCARDALL 6 |
30 | |
31 | /// Show plain message |
32 | #define MSG(s) msg((char_u *)(s)) |
33 | |
34 | /// Show message highlighted according to the attr |
35 | #define MSG_ATTR(s, attr) msg_attr((const char *)(s), (attr)) |
36 | |
37 | /// Display error message |
38 | /// |
39 | /// Sets error flag in process, can be transformed into an exception. |
40 | #define EMSG(s) emsg((char_u *)(s)) |
41 | |
42 | /// Like #EMSG, but for messages with one "%s" inside |
43 | #define EMSG2(s, p) emsgf((const char *) (s), (p)) |
44 | |
45 | /// Like #EMSG, but for messages with two "%s" inside |
46 | #define EMSG3(s, p, q) emsgf((const char *) (s), (p), (q)) |
47 | |
48 | /// Like #EMSG, but for messages with one "%" PRId64 inside |
49 | #define EMSGN(s, n) emsgf((const char *) (s), (int64_t)(n)) |
50 | |
51 | /// Like #EMSG, but for messages with one "%" PRIu64 inside |
52 | #define EMSGU(s, n) emsgf((const char *) (s), (uint64_t)(n)) |
53 | |
54 | /// Like #EMSG, but for internal messages |
55 | #define IEMSG(s) iemsg((const char *)(s)) |
56 | |
57 | /// Like #EMSG2, but for internal messages |
58 | #define IEMSG2(s, p) iemsgf((const char *)(s), (p)) |
59 | |
60 | /// Like #EMSGN, but for internal messages |
61 | #define IEMSGN(s, n) iemsgf((const char *)(s), (int64_t)(n)) |
62 | |
63 | /// Display message at the recorded position |
64 | #define MSG_PUTS(s) msg_puts((const char *)(s)) |
65 | |
66 | /// Display message at the recorded position, highlighted |
67 | #define MSG_PUTS_ATTR(s, a) msg_puts_attr((const char *)(s), (a)) |
68 | |
69 | /// Like #MSG_PUTS, but highlight like title |
70 | #define MSG_PUTS_TITLE(s) msg_puts_title((const char *)(s)) |
71 | |
72 | /// Like #MSG_PUTS, but if middle part of too long messages it will be replaced |
73 | #define MSG_PUTS_LONG(s) msg_puts_long_attr((char_u *)(s), 0) |
74 | |
75 | /// Like #MSG_PUTS_ATTR, but if middle part of long messages will be replaced |
76 | #define MSG_PUTS_LONG_ATTR(s, a) msg_puts_long_attr((char_u *)(s), (a)) |
77 | |
78 | /// Message history for `:messages` |
79 | typedef struct msg_hist { |
80 | struct msg_hist *next; ///< Next message. |
81 | char_u *msg; ///< Message text. |
82 | const char *kind; ///< Message kind (for msg_ext) |
83 | int attr; ///< Message highlighting. |
84 | bool multiline; ///< Multiline message. |
85 | } MessageHistoryEntry; |
86 | |
87 | /// First message |
88 | extern MessageHistoryEntry *first_msg_hist; |
89 | /// Last message |
90 | extern MessageHistoryEntry *last_msg_hist; |
91 | |
92 | EXTERN bool msg_ext_need_clear INIT(= false); |
93 | |
94 | // allocated grid for messages. Used when display+=msgsep is set, or |
95 | // ext_multigrid is active. See also the description at msg_scroll_flush() |
96 | EXTERN ScreenGrid msg_grid INIT(= SCREEN_GRID_INIT); |
97 | EXTERN int msg_grid_pos INIT(= 0); |
98 | |
99 | // "adjusted" message grid. This grid accepts positions relative to |
100 | // default_grid. Internally it will be translated to a position on msg_grid |
101 | // relative to the start of the message area, or directly mapped to default_grid |
102 | // for legacy (display-=msgsep) message scroll behavior. |
103 | // // TODO(bfredl): refactor "internal" message logic, msg_row etc |
104 | // to use the correct positions already. |
105 | EXTERN ScreenGrid msg_grid_adj INIT(= SCREEN_GRID_INIT); |
106 | |
107 | // value of msg_scrolled at latest msg_scroll_flush. |
108 | EXTERN int msg_scrolled_at_flush INIT(= 0); |
109 | |
110 | |
111 | #ifdef INCLUDE_GENERATED_DECLARATIONS |
112 | # include "message.h.generated.h" |
113 | #endif |
114 | #endif // NVIM_MESSAGE_H |
115 | |