refactor: move some anonymous enums back to non-defs headers (#26622)

It isn't really useful to put anonymous enums only used as arguments to
functions calls in _defs.h headers, as they will only be used by a file
that calls those functions, which requires including a non-defs header.

Also move os_msg() and os_errmsg() back to message.h, as on Windows they
are actual functions instead of macros.

Also remove gettext.h and globals.h from private/helpers.h.
This commit is contained in:
zeertzjq
2023-12-18 06:18:11 +08:00
committed by GitHub
parent 69bc519b53
commit d82a586a9e
12 changed files with 60 additions and 66 deletions

View File

@@ -1,13 +1,36 @@
#pragma once
#include <errno.h>
#include <stdbool.h>
#include <stddef.h> // IWYU pragma: keep
#include <stdio.h>
#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
#include "nvim/grid_defs.h"
#include "nvim/macros_defs.h"
#include "nvim/message_defs.h" // IWYU pragma: export
/// Types of dialogs passed to do_dialog().
enum {
VIM_GENERIC = 0,
VIM_ERROR = 1,
VIM_WARNING = 2,
VIM_INFO = 3,
VIM_QUESTION = 4,
VIM_LAST_TYPE = 4, ///< sentinel value
};
/// Return values for functions like vim_dialogyesno()
enum {
VIM_YES = 2,
VIM_NO = 3,
VIM_CANCEL = 4,
VIM_ALL = 5,
VIM_DISCARDALL = 6,
};
enum { MSG_HIST = 0x1000, }; ///< special attribute addition: Put message in history
/// First message
extern MessageHistoryEntry *first_msg_hist;
/// Last message
@@ -38,3 +61,14 @@ EXTERN int msg_listdo_overwrite INIT( = 0);
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "message.h.generated.h"
#endif
// Prefer using semsg(), because perror() may send the output to the wrong
// destination and mess up the screen.
#define PERROR(msg) (void)semsg("%s: %s", (msg), strerror(errno))
#ifndef MSWIN
/// Headless (no UI) error message handler.
# define os_errmsg(str) fprintf(stderr, "%s", (str))
/// Headless (no UI) message handler.
# define os_msg(str) printf("%s", (str))
#endif