turn_on_face (struct frame *f, int face_id)
{
struct face *face = FACE_FROM_ID (f, face_id);
- long fg = face->foreground;
- long bg = face->background;
+ unsigned long fg = face->foreground;
+ unsigned long bg = face->background;
struct tty_display_info *tty = FRAME_TTY (f);
- /* Do this first because TS_end_standout_mode may be the same
+ /* Use reverse video if the face specifies that.
+ Do this first because TS_end_standout_mode may be the same
as TS_exit_attribute_mode, which turns all appearances off. */
- if (MAY_USE_WITH_COLORS_P (tty, NC_REVERSE))
- {
- if (tty->TN_max_colors > 0)
- {
- if (fg >= 0 && bg >= 0)
- {
- /* If the terminal supports colors, we can set them
- below without using reverse video. The face's fg
- and bg colors are set as they should appear on
- the screen, i.e. they take the inverse-video'ness
- of the face already into account. */
- }
- else if (inverse_video)
- {
- if (fg == FACE_TTY_DEFAULT_FG_COLOR
- || bg == FACE_TTY_DEFAULT_BG_COLOR)
- tty_toggle_highlight (tty);
- }
- else
- {
- if (fg == FACE_TTY_DEFAULT_BG_COLOR
- || bg == FACE_TTY_DEFAULT_FG_COLOR)
- tty_toggle_highlight (tty);
- }
- }
- else
- {
- /* If we can't display colors, use reverse video
- if the face specifies that. */
- if (inverse_video)
- {
- if (fg == FACE_TTY_DEFAULT_FG_COLOR
- || bg == FACE_TTY_DEFAULT_BG_COLOR)
- tty_toggle_highlight (tty);
- }
- else
- {
- if (fg == FACE_TTY_DEFAULT_BG_COLOR
- || bg == FACE_TTY_DEFAULT_FG_COLOR)
- tty_toggle_highlight (tty);
- }
- }
- }
+ if (MAY_USE_WITH_COLORS_P (tty, NC_REVERSE)
+ && (inverse_video
+ ? fg == FACE_TTY_DEFAULT_FG_COLOR || bg == FACE_TTY_DEFAULT_BG_COLOR
+ : fg == FACE_TTY_DEFAULT_BG_COLOR || bg == FACE_TTY_DEFAULT_FG_COLOR))
+ tty_toggle_highlight (tty);
if (face->tty_bold_p && MAY_USE_WITH_COLORS_P (tty, NC_BOLD))
OUTPUT1_IF (tty, tty->TS_enter_bold_mode);
char *p;
ts = tty->standout_mode ? tty->TS_set_background : tty->TS_set_foreground;
- if (fg >= 0 && ts)
+ if (face_tty_specified_color (fg) && ts)
{
p = tparam (ts, NULL, 0, fg, 0, 0, 0);
OUTPUT (tty, p);
}
ts = tty->standout_mode ? tty->TS_set_foreground : tty->TS_set_background;
- if (bg >= 0 && ts)
+ if (face_tty_specified_color (bg) && ts)
{
p = tparam (ts, NULL, 0, bg, 0, 0, 0);
OUTPUT (tty, p);
/* Return true if the terminal on frame F supports all of the
- capabilities in CAPS simultaneously, with foreground and background
- colors FG and BG. */
+ capabilities in CAPS simultaneously. */
bool
-tty_capable_p (struct tty_display_info *tty, unsigned int caps,
- unsigned long fg, unsigned long bg)
+tty_capable_p (struct tty_display_info *tty, unsigned int caps)
{
#define TTY_CAPABLE_P_TRY(tty, cap, TS, NC_bit) \
if ((caps & (cap)) && (!(TS) || !MAY_USE_WITH_COLORS_P(tty, NC_bit))) \
{
if (pane == menu->panenumber[i])
return menu->submenu[i];
- if ((try = tty_menu_search_pane (menu->submenu[i], pane)))
+ try = tty_menu_search_pane (menu->submenu[i], pane);
+ if (try)
return try;
}
return (tty_menu *) 0;
static void
tty_menu_display (tty_menu *menu, int x, int y, int pn, int *faces,
- int mx, int my, int first_item, int disp_help)
+ int mx, int my, int first_item, bool disp_help)
{
int i, face, width, enabled, mousehere, row, col;
struct frame *sf = SELECTED_FRAME ();
/* Create a new item in a menu pane. */
-static int
+static bool
tty_menu_add_selection (tty_menu *menu, int pane,
- char *txt, int enable, char const *help_text)
+ char *txt, bool enable, char const *help_text)
{
int len;
unsigned char *p;
if (pane)
- if (!(menu = tty_menu_search_pane (menu, pane)))
- return TTYM_FAILURE;
+ {
+ menu = tty_menu_search_pane (menu, pane);
+ if (! menu)
+ return 0;
+ }
tty_menu_make_room (menu);
menu->submenu[menu->count] = (tty_menu *) 0;
menu->text[menu->count] = txt;
if (len > menu->width)
menu->width = len;
- return TTYM_SUCCESS;
+ return 1;
}
/* Decide where the menu would be placed if requested at (X,Y). */
else
{
Lisp_Object cmd;
- int usable_input = 1;
+ bool usable_input = 1;
mi_result st = MI_CONTINUE;
struct tty_display_info *tty = FRAME_TTY (sf);
Lisp_Object saved_mouse_tracking = do_mouse_tracking;
tty_menu_activate (tty_menu *menu, int *pane, int *selidx,
int x0, int y0, char **txt,
void (*help_callback)(char const *, int, int),
- int kbd_navigation)
+ bool kbd_navigation)
{
struct tty_menu_state *state;
- int statecount, x, y, i, leave, onepane;
+ int statecount, x, y, i;
+ bool leave, onepane;
int result IF_LINT (= 0);
int title_faces[4]; /* face to display the menu title */
int faces[4], buffers_num_deleted = 0;
tty_hide_cursor (tty);
if (buffers_num_deleted)
menu->text[0][7] = ' ';
- if ((onepane = menu->count == 1 && menu->submenu[0]))
+ onepane = menu->count == 1 && menu->submenu[0];
+ if (onepane)
{
menu->width = menu->submenu[0]->width;
state[0].menu = menu->submenu[0];
}
Lisp_Object
-tty_menu_show (struct frame *f, int x, int y, int for_click, int keymaps,
- Lisp_Object title, int kbd_navigation, const char **error_name)
+tty_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
+ Lisp_Object title, bool kbd_navigation, const char **error_name)
{
tty_menu *menu;
int pane, selidx, lpane, status;
item_data = SSDATA (item_name);
if (lpane == TTYM_FAILURE
- || (tty_menu_add_selection (menu, lpane, item_data,
- !NILP (enable), help_string)
- == TTYM_FAILURE))
+ || (! tty_menu_add_selection (menu, lpane, item_data,
+ !NILP (enable), help_string)))
{
tty_menu_destroy (menu);
*error_name = "Can't add selection to menu";
#ifdef HAVE_WINDOW_SYSTEM
-/* Return non-zero if all the face attributes in ATTRS are supported
+/* Return true if all the face attributes in ATTRS are supported
on the window-system frame F.
The definition of `supported' is somewhat heuristic, but basically means
\(1) different in appearance than the default face, and
\(2) `close in spirit' to what the attributes specify, if not exact. */
-static int
+static bool
x_supports_face_attributes_p (struct frame *f,
Lisp_Object attrs[LFACE_VECTOR_SIZE],
struct face *def_face)
#endif /* HAVE_WINDOW_SYSTEM */
-/* Return non-zero if all the face attributes in ATTRS are supported
+/* Return true if all the face attributes in ATTRS are supported
on the tty frame F.
The definition of `supported' is somewhat heuristic, but basically means
will _not_ be satisfied by the tty display code's automatic
substitution of a `dim' face for italic. */
-static int
+static bool
tty_supports_face_attributes_p (struct frame *f,
Lisp_Object attrs[LFACE_VECTOR_SIZE],
struct face *def_face)
/* Color testing. */
- /* Default the color indices in FG_TTY_COLOR and BG_TTY_COLOR, since
- we use them when calling `tty_capable_p' below, even if the face
- specifies no colors. */
- fg_tty_color.pixel = FACE_TTY_DEFAULT_FG_COLOR;
- bg_tty_color.pixel = FACE_TTY_DEFAULT_BG_COLOR;
-
/* Check if foreground color is close enough. */
fg = attrs[LFACE_FOREGROUND_INDEX];
if (STRINGP (fg))
/* See if the capabilities we selected above are supported, with the
given colors. */
- if (test_caps != 0 &&
- ! tty_capable_p (FRAME_TTY (f), test_caps, fg_tty_color.pixel,
- bg_tty_color.pixel))
- return 0;
-
-
- /* Hmmm, everything checks out, this terminal must support this face. */
- return 1;
+ return tty_capable_p (FRAME_TTY (f), test_caps);
}
face for italic. */)
(Lisp_Object attributes, Lisp_Object display)
{
- int supports = 0, i;
+ bool supports = 0;
+ int i;
Lisp_Object frame;
struct frame *f;
struct face *def_face;