aboutsummaryrefslogtreecommitdiffstats
path: root/com32/cmenu/libmenu/tui.h
blob: 5cf5dd7a0d24b4bf338082247e98d45644eb9e13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/* -*- c -*- ------------------------------------------------------------- *
 *
 *   Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
 *   Boston MA 02111-1307, USA; either version 2 of the License, or
 *   (at your option) any later version; incorporated herein by reference.
 *
 * ----------------------------------------------------------------------- */

#ifndef __TUI_H__
#define __TUI_H__

#include <com32.h>
#include "syslnx.h"
#include "com32io.h"
#include "scancodes.h"

#ifndef NULL
#define NULL ((void *)0)
#endif

#define SO '\016'
#define SI '\017'

#define TOP_LEFT_CORNER_BORDER '\154'
#define TOP_BORDER '\161'
#define TOP_RIGHT_CORNER_BORDER '\153'
#define BOTTOM_LEFT_CORNER_BORDER '\155'
#define BOTTOM_BORDER '\161'
#define BOTTOM_RIGHT_CORNER_BORDER '\152'
#define LEFT_BORDER '\170'
#define RIGHT_BORDER '\170'

#define BELL 0x07
// CHRELATTR = ^N, CHABSATTR = ^O
#define CHABSATTR 15
#define CHRELATTR 14

void clearwindow(char top, char left, char bot, char right,
		 char page, char fillchar, char fillattr);

/*
 * Clears the entire screen
 *
 * Note: when initializing xterm, one has to specify that
 * G1 points to the alternate character set (this is not true
 * by default). Without the initial printf "\033)0", line drawing
 * characters won't be displayed.
 */
static inline void cls(void)
{
	return fputs("\033e\033%@\033)0\033(B\1#0\033[?25l\033[2J", stdout);
}


// Generic user input,
// password = 0 iff chars echoed on screen
// showoldvalue <> 0 iff current displayed for editing
void getuserinput(char *str, unsigned int size,
		  unsigned int password, unsigned int showoldvalue);

static inline void getstring(char *str, unsigned int size)
{
    getuserinput(str, size, 0, 0);
}

static inline void editstring(char *str, unsigned int size)
{
    getuserinput(str, size, 0, 1);
}

static inline void getpwd(char *str, unsigned int size)
{
    getuserinput(str, size, 1, 0);
}

// Box drawing Chars offsets into array
#define BOX_TOPLEFT  0x0
#define BOX_BOTLEFT  0x1
#define BOX_TOPRIGHT 0x2
#define BOX_BOTRIGHT 0x3
#define BOX_TOP      0x4	// TOP = BOT = HORIZ
#define BOX_BOT      0x4
#define BOX_HORIZ    0x4
#define BOX_LEFT     0x5
#define BOX_RIGHT    0x5
#define BOX_VERT     0x5	// LEFT=RIGHT=VERT
#define BOX_LTRT     0x6
#define BOX_RTLT     0x7
#define BOX_TOPBOT   0x8
#define BOX_BOTTOP   0x9
#define BOX_MIDDLE   0xA

typedef enum { BOX_SINSIN, BOX_DBLDBL, BOX_SINDBL, BOX_DBLSIN } boxtype;

unsigned char *getboxchars(boxtype bt);

void drawbox(char top, char left, char bot, char right,
	     char page, char attr, boxtype bt);

// Draw a horizontal line
// dumb == 1, means just draw the line
// dumb == 0 means check the first and last positions and depending on what is
//    currently on the screen make it a LTRT and/or RTLT appropriately.
void drawhorizline(char top, char left, char right, char page, char attr,
		   boxtype bt, char dumb);

#endif