iPXE
Functions
edging.c File Reference

MuCurses edging functions. More...

#include <curses.h>
#include "mucurses.h"
#include "cursor.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
int box (WINDOW *win, chtype verch, chtype horch)
 Draw borders from single-byte characters and renditions around a window. More...
 
int wborder (WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br)
 Draw borders from single-byte characters and renditions around a window. More...
 
int whline (WINDOW *win, chtype ch, int n)
 Create a horizontal line in a window. More...
 
int wvline (WINDOW *win, chtype ch, int n)
 Create a vertical line in a window. More...
 

Detailed Description

MuCurses edging functions.

Definition in file edging.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ box()

int box ( WINDOW win,
chtype  verch,
chtype  horch 
)

Draw borders from single-byte characters and renditions around a window.

Parameters
*winwindow to be bordered
verchvertical chtype
horchhorizontal chtype
Return values
rcreturn status code

Definition at line 22 of file edging.c.

22  {
23  chtype corner = '+' | win->attrs; /* default corner character */
24  return wborder( win, verch, verch, horch, horch,
25  corner, corner, corner, corner );
26 }
int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br)
Draw borders from single-byte characters and renditions around a window.
Definition: edging.c:43
attr_t attrs
window attributes
Definition: curses.h:93
uint32_t chtype
Definition: curses.h:29

References _curses_window::attrs, and wborder().

Referenced by draw_editbox(), edit_editbox(), and init_editbox().

◆ wborder()

int wborder ( WINDOW win,
chtype  ls,
chtype  rs,
chtype  ts,
chtype  bs,
chtype  tl,
chtype  tr,
chtype  bl,
chtype  br 
)

Draw borders from single-byte characters and renditions around a window.

Parameters
*winwindow to be bordered
lsleft side
rsright side
tstop
bsbottom
tltop left corner
trtop right corner
blbottom left corner
brbottom right corner
Return values
rcreturn status code

Definition at line 43 of file edging.c.

45  {
46  struct cursor_pos pos;
47 
48  _store_curs_pos( win, &pos );
49  wmove(win,0,0);
50 
51  _wputch(win,tl,WRAP);
52  while ( ( win->width - 1 ) - win->curs_x ) {
53  _wputch(win,ts,WRAP);
54  }
55  _wputch(win,tr,WRAP);
56 
57  while ( ( win->height - 1 ) - win->curs_y ) {
58  _wputch(win,ls,WRAP);
59  wmove(win,win->curs_y,(win->width)-1);
60  _wputch(win,rs,WRAP);
61  }
62 
63  _wputch(win,bl,WRAP);
64  while ( ( win->width -1 ) - win->curs_x ) {
65  _wputch(win,bs,WRAP);
66  }
67  _wputch(win,br,NOWRAP); /* do not wrap last char to leave
68  cursor in last position */
69  _restore_curs_pos( win, &pos );
70 
71  return OK;
72 }
int wmove(WINDOW *win, int y, int x) __nonnull
Move a window's cursor to the specified position.
Definition: mucurses.c:135
unsigned int curs_y
Definition: curses.h:97
uint8_t bl
Definition: registers.h:78
unsigned int height
Definition: curses.h:99
unsigned int width
window dimensions
Definition: curses.h:99
Definition: sis900.h:208
#define NOWRAP
Definition: mucurses.h:13
void _wputch(WINDOW *win, chtype ch, int wrap) __nonnull
Write a single character rendition to a window.
Definition: mucurses.c:50
static void _restore_curs_pos(WINDOW *win, struct cursor_pos *pos)
Restore cursor position from encoded backup variable.
Definition: cursor.h:22
static void _store_curs_pos(WINDOW *win, struct cursor_pos *pos)
Store cursor position for later restoration.
Definition: cursor.h:32
#define WRAP
Definition: mucurses.h:12
unsigned int curs_x
window cursor position
Definition: curses.h:97

References _restore_curs_pos(), _store_curs_pos(), _wputch(), bl, _curses_window::curs_x, _curses_window::curs_y, _curses_window::height, NOWRAP, OK, _curses_window::width, wmove(), and WRAP.

Referenced by border(), and box().

◆ whline()

int whline ( WINDOW win,
chtype  ch,
int  n 
)

Create a horizontal line in a window.

Parameters
*winsubject window
chrendition and character
nmax number of chars (wide) to render
Return values
rcreturn status code

Definition at line 82 of file edging.c.

82  {
83  struct cursor_pos pos;
84 
85  _store_curs_pos ( win, &pos );
86  while ( ( win->curs_x - win->width ) && n-- ) {
87  _wputch ( win, ch, NOWRAP );
88  }
89  _restore_curs_pos ( win, &pos );
90 
91  return OK;
92 }
unsigned int width
window dimensions
Definition: curses.h:99
Definition: sis900.h:208
uint8_t ch
Definition: registers.h:83
#define NOWRAP
Definition: mucurses.h:13
void _wputch(WINDOW *win, chtype ch, int wrap) __nonnull
Write a single character rendition to a window.
Definition: mucurses.c:50
unsigned int n
Definition: entropy.h:159
static void _restore_curs_pos(WINDOW *win, struct cursor_pos *pos)
Restore cursor position from encoded backup variable.
Definition: cursor.h:22
static void _store_curs_pos(WINDOW *win, struct cursor_pos *pos)
Store cursor position for later restoration.
Definition: cursor.h:32
unsigned int curs_x
window cursor position
Definition: curses.h:97

References _restore_curs_pos(), _store_curs_pos(), _wputch(), ch, _curses_window::curs_x, n, NOWRAP, OK, and _curses_window::width.

Referenced by hline(), mvhline(), and mvwhline().

◆ wvline()

int wvline ( WINDOW win,
chtype  ch,
int  n 
)

Create a vertical line in a window.

Parameters
*winsubject window
chrendition and character
nmax number of chars (high) to render
Return values
rcreturn status code

Definition at line 102 of file edging.c.

102  {
103  struct cursor_pos pos;
104 
105  _store_curs_pos ( win, &pos );
106  while ( ( win->curs_y - win->height ) && n-- ) {
107  _wputch ( win, ch, NOWRAP );
108  wmove( win, ++(win->curs_y), pos.x);
109  }
110  _restore_curs_pos ( win, &pos );
111 
112  return OK;
113 }
int wmove(WINDOW *win, int y, int x) __nonnull
Move a window's cursor to the specified position.
Definition: mucurses.c:135
unsigned int curs_y
Definition: curses.h:97
unsigned int height
Definition: curses.h:99
Definition: sis900.h:208
uint8_t ch
Definition: registers.h:83
#define NOWRAP
Definition: mucurses.h:13
void _wputch(WINDOW *win, chtype ch, int wrap) __nonnull
Write a single character rendition to a window.
Definition: mucurses.c:50
unsigned int n
Definition: entropy.h:159
static void _restore_curs_pos(WINDOW *win, struct cursor_pos *pos)
Restore cursor position from encoded backup variable.
Definition: cursor.h:22
static void _store_curs_pos(WINDOW *win, struct cursor_pos *pos)
Store cursor position for later restoration.
Definition: cursor.h:32

References _restore_curs_pos(), _store_curs_pos(), _wputch(), ch, _curses_window::curs_y, _curses_window::height, n, NOWRAP, OK, wmove(), and cursor_pos::x.

Referenced by mvvline(), mvwvline(), and vline().