iPXE
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.
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.
int whline (WINDOW *win, chtype ch, int n)
 Create a horizontal line in a window.
int wvline (WINDOW *win, chtype ch, int n)
 Create a vertical line in a window.

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}
uint32_t chtype
Definition curses.h:30
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:94

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}
#define OK
Definition curses.h:25
static void _store_curs_pos(WINDOW *win, struct cursor_pos *pos)
Store cursor position for later restoration.
Definition cursor.h:33
static void _restore_curs_pos(WINDOW *win, struct cursor_pos *pos)
Restore cursor position from encoded backup variable.
Definition cursor.h:23
int wmove(WINDOW *win, int y, int x) __nonnull
Move a window's cursor to the specified position.
Definition mucurses.c:136
void _wputch(WINDOW *win, chtype ch, int wrap) __nonnull
Write a single character rendition to a window.
Definition mucurses.c:51
#define WRAP
Definition mucurses.h:13
#define NOWRAP
Definition mucurses.h:14
uint8_t bl
Definition registers.h:0
unsigned int curs_x
window cursor position
Definition curses.h:98
unsigned int width
window dimensions
Definition curses.h:100
unsigned int height
Definition curses.h:100
unsigned int curs_y
Definition curses.h:98

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}
uint8_t ch
Definition registers.h:1

References _restore_curs_pos(), _store_curs_pos(), _wputch(), ch, _curses_window::curs_x, 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}

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

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