mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
* view.c: Added four functions view_get_top(), view_get_left(),
view_get_bottom(), view_get_right() to mark the bounds of the rectangle that can be used for displaying data. Expressed view_get_datalines() and view_get_datacolumns() in terms of these four functions.
This commit is contained in:
parent
46a8f2bdc5
commit
054e617e9b
@ -15,6 +15,9 @@
|
||||
* view.h (view): Rewrote the comment.
|
||||
* view.c: Eliminated some ?: operators.
|
||||
* view.c: Corrected some typos and indentation.
|
||||
* view.c: Added four functions view_get_top(), view_get_left(),
|
||||
view_get_bottom(), view_get_right() to mark the bounds of the
|
||||
rectangle that can be used for displaying data.
|
||||
|
||||
2005-04-16 Roland Illig <roland.illig@gmx.de>
|
||||
|
||||
|
45
src/view.c
45
src/view.c
@ -256,26 +256,55 @@ get_byte_indexed (WView *view, offset_type base, offset_type ofs)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int
|
||||
view_get_top (WView *view)
|
||||
{
|
||||
return view->dpy_frame_size + STATUS_LINES;
|
||||
}
|
||||
|
||||
static inline int
|
||||
view_get_left (WView *view)
|
||||
{
|
||||
return view->dpy_frame_size;
|
||||
}
|
||||
|
||||
static inline int
|
||||
view_get_bottom (WView *view)
|
||||
{
|
||||
if (view->widget.lines >= view->dpy_frame_size)
|
||||
return view->widget.lines - view->dpy_frame_size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
view_get_right (WView *view)
|
||||
{
|
||||
if (view->widget.cols >= view->dpy_frame_size)
|
||||
return view->widget.cols - view->dpy_frame_size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* the number of lines that can be used for displaying data */
|
||||
static inline int
|
||||
view_get_datalines (WView *view)
|
||||
{
|
||||
const int framelines = 2 * view->dpy_frame_size;
|
||||
const int statuslines = STATUS_LINES;
|
||||
const int top = view_get_top (view);
|
||||
const int bottom = view_get_bottom (view);
|
||||
|
||||
if (view->widget.lines < framelines + statuslines)
|
||||
return 0;
|
||||
return view->widget.lines - (framelines + statuslines);
|
||||
if (bottom >= top)
|
||||
return bottom - top;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* the number of columns that can be used for displaying data */
|
||||
static inline int
|
||||
view_get_datacolumns (WView *view)
|
||||
{
|
||||
const int framelines = 2 * view->dpy_frame_size;
|
||||
const int left = view_get_left (view);
|
||||
const int right = view_get_right (view);
|
||||
|
||||
if (framelines < view->widget.cols)
|
||||
return view->widget.cols - framelines;
|
||||
if (right >= left)
|
||||
return right - left;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user