mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
(DOZ): new macro: difference or zero.
Use DOZ where appropriate. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
d35df9ad60
commit
91b7101e06
@ -54,6 +54,9 @@
|
||||
*/
|
||||
#define _GL_CMP(n1, n2) (((n1) > (n2)) - ((n1) < (n2)))
|
||||
|
||||
/* Difference of zero */
|
||||
#define DOZ(a, b) ((a) > (b) ? (a) - (b) : 0)
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/* Pathname canonicalization */
|
||||
|
@ -639,8 +639,8 @@ listbox_select_last (WListbox * l)
|
||||
|
||||
length = listbox_get_length (l);
|
||||
|
||||
l->pos = length > 0 ? length - 1 : 0;
|
||||
l->top = length > lines ? length - lines : 0;
|
||||
l->pos = DOZ (length, 1);
|
||||
l->top = DOZ (length, lines);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -1038,7 +1038,7 @@ mcview_ascii_moveto_eol (WView * view)
|
||||
/* Get the width of the topmost paragraph. */
|
||||
mcview_state_machine_init (&state, view->dpy_start);
|
||||
mcview_display_line (view, &state, -1, NULL, &linewidth);
|
||||
view->dpy_text_column = mcview_offset_doz (linewidth, (off_t) view->data_area.width);
|
||||
view->dpy_text_column = DOZ (linewidth, (off_t) view->data_area.width);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,8 +268,8 @@ mcview_compute_areas (WView * view)
|
||||
|
||||
view_area.top = view->dpy_frame_size;
|
||||
view_area.left = view->dpy_frame_size;
|
||||
view_area.height = mcview_dimen_doz (WIDGET (view)->lines, 2 * view->dpy_frame_size);
|
||||
view_area.width = mcview_dimen_doz (WIDGET (view)->cols, 2 * view->dpy_frame_size);
|
||||
view_area.height = DOZ ((screen_dimen) WIDGET (view)->lines, 2 * view->dpy_frame_size);
|
||||
view_area.width = DOZ ((screen_dimen) WIDGET (view)->cols, 2 * view->dpy_frame_size);
|
||||
|
||||
/* Most coordinates of the areas equal those of the whole viewer */
|
||||
view->status_area = view_area;
|
||||
|
@ -18,15 +18,6 @@
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
/* difference or zero */
|
||||
static inline off_t
|
||||
mcview_offset_doz (off_t a, off_t b)
|
||||
{
|
||||
return (a >= b) ? a - b : 0;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static inline off_t
|
||||
mcview_offset_rounddown (off_t a, off_t b)
|
||||
{
|
||||
@ -36,15 +27,6 @@ mcview_offset_rounddown (off_t a, off_t b)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* difference or zero */
|
||||
static inline screen_dimen
|
||||
mcview_dimen_doz (screen_dimen a, screen_dimen b)
|
||||
{
|
||||
return (a >= b) ? a - b : 0;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* {{{ Simple Primitive Functions for WView }}} */
|
||||
static inline gboolean
|
||||
mcview_is_in_panel (WView * view)
|
||||
|
@ -118,7 +118,7 @@ mcview_move_up (WView * view, off_t lines)
|
||||
view->hex_cursor -= bytes;
|
||||
if (view->hex_cursor < view->dpy_start)
|
||||
{
|
||||
view->dpy_start = mcview_offset_doz (view->dpy_start, bytes);
|
||||
view->dpy_start = DOZ (view->dpy_start, bytes);
|
||||
view->dpy_paragraph_skip_lines = 0;
|
||||
view->dpy_wrap_dirty = TRUE;
|
||||
}
|
||||
@ -148,7 +148,7 @@ mcview_move_down (WView * view, off_t lines)
|
||||
{
|
||||
off_t i, limit;
|
||||
|
||||
limit = mcview_offset_doz (last_byte, (off_t) view->bytes_per_line);
|
||||
limit = DOZ (last_byte, (off_t) view->bytes_per_line);
|
||||
|
||||
for (i = 0; i < lines && view->hex_cursor < limit; i++)
|
||||
{
|
||||
@ -189,7 +189,7 @@ mcview_move_left (WView * view, off_t columns)
|
||||
view->hexedit_lownibble = !view->hexedit_lownibble;
|
||||
}
|
||||
else if (!view->mode_flags.wrap)
|
||||
view->dpy_text_column = mcview_offset_doz (view->dpy_text_column, columns);
|
||||
view->dpy_text_column = DOZ (view->dpy_text_column, columns);
|
||||
mcview_movement_fixups (view, FALSE);
|
||||
}
|
||||
|
||||
@ -203,7 +203,8 @@ mcview_move_right (WView * view, off_t columns)
|
||||
off_t last_byte;
|
||||
off_t old_cursor = view->hex_cursor;
|
||||
|
||||
last_byte = mcview_offset_doz (mcview_get_filesize (view), 1);
|
||||
last_byte = mcview_get_filesize (view);
|
||||
last_byte = DOZ (last_byte, 1);
|
||||
|
||||
g_assert (columns == 1);
|
||||
|
||||
@ -252,7 +253,7 @@ mcview_moveto_bottom (WView * view)
|
||||
|
||||
if (view->mode_flags.hex)
|
||||
{
|
||||
view->hex_cursor = mcview_offset_doz (filesize, 1);
|
||||
view->hex_cursor = DOZ (filesize, 1);
|
||||
mcview_movement_fixups (view, TRUE);
|
||||
}
|
||||
else
|
||||
@ -302,7 +303,7 @@ mcview_moveto_eol (WView * view)
|
||||
else
|
||||
{
|
||||
filesize = mcview_get_filesize (view);
|
||||
view->hex_cursor = mcview_offset_doz (filesize, 1);
|
||||
view->hex_cursor = DOZ (filesize, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user