Remove unnecessary conditional operators
This commit is contained in:
parent
b7a5c064c2
commit
85ed5c1515
@ -52,8 +52,8 @@ on_text_input(unsigned int codepoint, int mods) {
|
|||||||
|
|
||||||
if (w != NULL) {
|
if (w != NULL) {
|
||||||
Screen *screen = w->render_data.screen;
|
Screen *screen = w->render_data.screen;
|
||||||
bool in_alt_mods = !screen->modes.mEXTENDED_KEYBOARD && (mods == GLFW_MOD_ALT || mods == (GLFW_MOD_ALT | GLFW_MOD_SHIFT)) ? true : false;
|
bool in_alt_mods = !screen->modes.mEXTENDED_KEYBOARD && (mods == GLFW_MOD_ALT || mods == (GLFW_MOD_ALT | GLFW_MOD_SHIFT));
|
||||||
bool is_text = mods <= GLFW_MOD_SHIFT ? true : false;
|
bool is_text = mods <= GLFW_MOD_SHIFT;
|
||||||
if (in_alt_mods) {
|
if (in_alt_mods) {
|
||||||
sz = encode_utf8(codepoint, buf + 1);
|
sz = encode_utf8(codepoint, buf + 1);
|
||||||
if (sz) {
|
if (sz) {
|
||||||
@ -162,7 +162,7 @@ on_key_input(int key, int scancode, int action, int mods) {
|
|||||||
PyObject *ret = PyObject_CallMethod(global_state.boss, "dispatch_special_key", "iiii", lkey, scancode, action, mods);
|
PyObject *ret = PyObject_CallMethod(global_state.boss, "dispatch_special_key", "iiii", lkey, scancode, action, mods);
|
||||||
if (ret == NULL) { PyErr_Print(); }
|
if (ret == NULL) { PyErr_Print(); }
|
||||||
else {
|
else {
|
||||||
bool consumed = ret == Py_True ? true : false;
|
bool consumed = ret == Py_True;
|
||||||
Py_DECREF(ret);
|
Py_DECREF(ret);
|
||||||
if (consumed) return;
|
if (consumed) return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -94,7 +94,7 @@ prefix_matches(Line *self, index_type at, const char* prefix, index_type prefix_
|
|||||||
for (p = at - prefix_len, i = 0; i < prefix_len && p < self->xnum; i++, p++) {
|
for (p = at - prefix_len, i = 0; i < prefix_len && p < self->xnum; i++, p++) {
|
||||||
if ((self->cells[p].ch & CHAR_MASK) != (unsigned char)prefix[i]) return false;
|
if ((self->cells[p].ch & CHAR_MASK) != (unsigned char)prefix[i]) return false;
|
||||||
}
|
}
|
||||||
return i == prefix_len ? true : false;
|
return i == prefix_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
|
|||||||
@ -87,7 +87,7 @@ static inline bool
|
|||||||
contains_mouse(Window *w) {
|
contains_mouse(Window *w) {
|
||||||
WindowGeometry *g = &w->geometry;
|
WindowGeometry *g = &w->geometry;
|
||||||
double x = global_state.mouse_x, y = global_state.mouse_y;
|
double x = global_state.mouse_x, y = global_state.mouse_y;
|
||||||
return (w->visible && g->left <= x && x <= g->right && g->top <= y && y <= g->bottom) ? true : false;
|
return (w->visible && g->left <= x && x <= g->right && g->top <= y && y <= g->bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
@ -124,7 +124,7 @@ drag_scroll(Window *w) {
|
|||||||
double x = global_state.mouse_x, y = global_state.mouse_y;
|
double x = global_state.mouse_x, y = global_state.mouse_y;
|
||||||
if (y < w->geometry.top || y > w->geometry.bottom) return false;
|
if (y < w->geometry.top || y > w->geometry.bottom) return false;
|
||||||
if (x < w->geometry.left || x > w->geometry.right) return false;
|
if (x < w->geometry.left || x > w->geometry.right) return false;
|
||||||
bool upwards = y <= w->geometry.top + margin ? true : false;
|
bool upwards = y <= (w->geometry.top + margin);
|
||||||
if (upwards || y >= w->geometry.bottom - margin) {
|
if (upwards || y >= w->geometry.bottom - margin) {
|
||||||
Screen *screen = w->render_data.screen;
|
Screen *screen = w->render_data.screen;
|
||||||
if (screen->linebuf == screen->main_linebuf) {
|
if (screen->linebuf == screen->main_linebuf) {
|
||||||
@ -150,7 +150,7 @@ detect_url(Window *w, Screen *screen, unsigned int x, unsigned int y) {
|
|||||||
if (line) {
|
if (line) {
|
||||||
url_start = line_url_start_at(line, x);
|
url_start = line_url_start_at(line, x);
|
||||||
if (url_start < line->xnum) url_end = line_url_end_at(line, x);
|
if (url_start < line->xnum) url_end = line_url_end_at(line, x);
|
||||||
has_url = url_end > url_start ? true : false;
|
has_url = url_end > url_start;
|
||||||
}
|
}
|
||||||
if (has_url) {
|
if (has_url) {
|
||||||
mouse_cursor_shape = HAND;
|
mouse_cursor_shape = HAND;
|
||||||
@ -167,7 +167,7 @@ HANDLER(handle_move_event) {
|
|||||||
if (!cell_for_pos(w, &x, &y)) return;
|
if (!cell_for_pos(w, &x, &y)) return;
|
||||||
Screen *screen = w->render_data.screen;
|
Screen *screen = w->render_data.screen;
|
||||||
detect_url(w, screen, x, y);
|
detect_url(w, screen, x, y);
|
||||||
bool mouse_cell_changed = x != w->mouse_cell_x || y != w->mouse_cell_y ? true : false;
|
bool mouse_cell_changed = x != w->mouse_cell_x || y != w->mouse_cell_y;
|
||||||
w->mouse_cell_x = x; w->mouse_cell_y = y;
|
w->mouse_cell_x = x; w->mouse_cell_y = y;
|
||||||
bool handle_in_kitty = (
|
bool handle_in_kitty = (
|
||||||
(screen->modes.mouse_tracking_mode == ANY_MODE ||
|
(screen->modes.mouse_tracking_mode == ANY_MODE ||
|
||||||
@ -255,7 +255,7 @@ HANDLER(handle_button_event) {
|
|||||||
screen->modes.mouse_tracking_mode == 0 ||
|
screen->modes.mouse_tracking_mode == 0 ||
|
||||||
button == GLFW_MOUSE_BUTTON_MIDDLE ||
|
button == GLFW_MOUSE_BUTTON_MIDDLE ||
|
||||||
(modifiers == (int)OPT(open_url_modifiers) && button == GLFW_MOUSE_BUTTON_LEFT)
|
(modifiers == (int)OPT(open_url_modifiers) && button == GLFW_MOUSE_BUTTON_LEFT)
|
||||||
) ? true : false;
|
);
|
||||||
if (handle_in_kitty) {
|
if (handle_in_kitty) {
|
||||||
switch(button) {
|
switch(button) {
|
||||||
case GLFW_MOUSE_BUTTON_LEFT:
|
case GLFW_MOUSE_BUTTON_LEFT:
|
||||||
@ -304,7 +304,7 @@ handle_tab_bar_mouse(int button, int UNUSED modifiers) {
|
|||||||
|
|
||||||
static inline Window*
|
static inline Window*
|
||||||
window_for_event(unsigned int *window_idx, bool *in_tab_bar) {
|
window_for_event(unsigned int *window_idx, bool *in_tab_bar) {
|
||||||
*in_tab_bar = global_state.num_tabs > 1 && global_state.mouse_y >= global_state.viewport_height - global_state.cell_height ? true : false;
|
*in_tab_bar = global_state.num_tabs > 1 && global_state.mouse_y >= global_state.viewport_height - global_state.cell_height;
|
||||||
if (!*in_tab_bar) {
|
if (!*in_tab_bar) {
|
||||||
Tab *t = global_state.tabs + global_state.active_tab;
|
Tab *t = global_state.tabs + global_state.active_tab;
|
||||||
for (unsigned int i = 0; i < t->num_windows; i++) {
|
for (unsigned int i = 0; i < t->num_windows; i++) {
|
||||||
@ -338,7 +338,7 @@ void
|
|||||||
scroll_event(double UNUSED xoffset, double yoffset) {
|
scroll_event(double UNUSED xoffset, double yoffset) {
|
||||||
int s = (int) round(yoffset * OPT(wheel_scroll_multiplier));
|
int s = (int) round(yoffset * OPT(wheel_scroll_multiplier));
|
||||||
if (s == 0) return;
|
if (s == 0) return;
|
||||||
bool upwards = s > 0 ? true : false;
|
bool upwards = s > 0;
|
||||||
bool in_tab_bar;
|
bool in_tab_bar;
|
||||||
unsigned int window_idx;
|
unsigned int window_idx;
|
||||||
Window *w = window_for_event(&window_idx, &in_tab_bar);
|
Window *w = window_for_event(&window_idx, &in_tab_bar);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user