aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/term/term.h
diff options
context:
space:
mode:
Diffstat (limited to 'sys/cmd/term/term.h')
-rw-r--r--sys/cmd/term/term.h316
1 files changed, 0 insertions, 316 deletions
diff --git a/sys/cmd/term/term.h b/sys/cmd/term/term.h
deleted file mode 100644
index 6784974..0000000
--- a/sys/cmd/term/term.h
+++ /dev/null
@@ -1,316 +0,0 @@
-/* See LICENSE for license details. */
-#pragma once
-
-#include <u.h>
-#include <base.h>
-#include <libutf.h>
-
-#include <signal.h>
-#include <sys/ioctl.h>
-#include <sys/select.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-#include <harfbuzz/hb.h>
-
-// -----------------------------------------------------------------------
-// macros
-
-#define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b))
-#define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d))
-#define DEFAULT(a, b) (a) = (a) ? (a) : (b)
-#define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x)
-#define GLYPHCMP(a, b) (((a).mode & (~Gwrap) & (~Gliga)) != ((b).mode & (~Gwrap) & (~Gliga)) || \
- (a).fg != (b).fg || (a).bg != (b).bg)
-#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + (t1.tv_nsec-t2.tv_nsec)/1E6)
-#define MODBIT(x, set, bit) ((set) ? ((x) |= (bit)) : ((x) &= ~(bit)))
-#define TRUECOLOR(r,g,b) (1 << 24 | (r) << 16 | (g) << 8 | (b))
-#define IS_TRUECOL(x) (1 << 24 & (x))
-
-#define iota(x) 1 << (x)
-
-/* arbitrary sizes */
-#define ESC_BUF_SIZ (128*UTFmax)
-#define ESC_ARG_SIZ 16
-#define STR_BUF_SIZ ESC_BUF_SIZ
-#define STR_ARG_SIZ ESC_ARG_SIZ
-
-// -----------------------------------------------------------------------
-// constants
-
-enum {
- Gnil,
- Gbold = iota(0),
- Gfaint = iota(1),
- Gitalic = iota(2),
- Gunline = iota(3),
- Gblink = iota(4),
- Greverse = iota(5),
- Ginvisible = iota(6),
- Gstruck = iota(7),
- Gwrap = iota(8),
- Gwide = iota(9),
- Gwdummy = iota(10),
- Gliga = iota(11),
- Gboldfaint = Gbold | Gfaint,
-};
-
-enum {
- SelIdle = 0,
- SelEmpty = 1,
- SelReady = 2
-};
-
-enum {
- SelRegular = 1,
- SelRectangular = 2
-};
-
-enum {
- SnapWord = 1,
- SnapLine = 2
-};
-
-/* cursor state */
-enum {
- CursorSave,
- CursorLoad
-};
-
-/* cursor mode */
-enum {
- CursorDefault = 0,
- CursorWrap = 1,
- CursorOrigin = 2
-};
-
-/* character set */
-enum {
- CSgfx0,
- CSgfx1,
- CSuk,
- CSusa,
- CSmulti,
- CSger,
- CSfin,
-};
-
-/* escape sequences */
-enum {
- Xstart = 1,
- Xcsi = 2,
- Xstr = 4, /* OSC, PM, APC */
- Xaltcs = 8,
- Xstrend = 16, /* a final string was encountered */
- Xtest = 32, /* Enter in test mode */
- Xutf8 = 64,
- Xdcs =128,
-};
-
-/* terminal mode */
-enum {
- Twrap = iota(0),
- Tinsert = iota(1),
- Taltscreen = iota(2),
- Tcrlf = iota(3),
- Techo = iota(4),
- Tprint = iota(5),
- Tutf8 = iota(6),
- Tsixel = iota(7),
-};
-
-/* window mode */
-enum {
- Wvisible = iota(0),
- Wfocused = iota(1),
- Wappkeypad = iota(2),
- Wmousebtn = iota(3),
- Wmousemotion = iota(4),
- Wreverse = iota(5),
- Wkbdblock = iota(6),
- Whide = iota(7),
- Wappcursor = iota(8),
- Wmousesgr = iota(9),
- W8bit = iota(10),
- Wblink = iota(11),
- Wbflink = iota(12),
- Wfocus = iota(13),
- Wmousex10 = iota(14),
- Wmousemany = iota(15),
- Wbrcktpaste = iota(16),
- Wnumlock = iota(17),
- Wmouse = Wmousebtn|Wmousemotion|Wmousex10|Wmousemany,
-};
-
-
-// -----------------------------------------------------------------------
-// types
-
-/* term.c */
-typedef struct Letter Letter;
-typedef struct Dot Dot;
-typedef struct Selection Selection;
-typedef struct Terminal Terminal;
-
-typedef union Arg Arg;
-
-struct Letter {
- rune u; /* character code */
- ushort mode; /* attribute flags */
- uint32 fg; /* foreground */
- uint32 bg; /* background */
-};
-
-struct Dot {
- Letter attr; /* current char attributes */
- int x;
- int y;
- char state;
-};
-
-struct Selection {
- int mode;
- int type;
- int snap;
- /*
- * Selection variables:
- * nb – normalized coordinates of the beginning of the selection
- * ne – normalized coordinates of the end of the selection
- * ob – original coordinates of the beginning of the selection
- * oe – original coordinates of the end of the selection
- */
- struct {
- int x, y;
- } nb, ne, ob, oe;
-
- int alt;
-};
-
-/* Internal representation of the screen */
-struct Terminal {
- int row; /* nb row */
- int col; /* nb col */
- Letter **line; /* screen */
- Letter **alt; /* alternate screen */
- int *dirty; /* dirtyness of lines */
- Dot c; /* cursor */
- int ocx; /* old cursor col */
- int ocy; /* old cursor row */
- int top; /* top scroll limit */
- int bot; /* bottom scroll limit */
- int mode; /* terminal mode flags */
- int esc; /* escape state flags */
- char trantbl[4];/* charset table translation */
- int charset; /* current charset */
- int icharset; /* selected charset for sequence */
- int *tabs;
- rune lastc; /* last printed char outside of sequence, 0 if control */
-};
-
-/* CSI Escape sequence structs */
-/* ESC '[' [[ [<priv>] <arg> [;]] <mode> [<mode>]] */
-typedef struct {
- char buf[ESC_BUF_SIZ]; /* raw string */
- ulong len; /* raw string length */
- char priv;
- int arg[ESC_ARG_SIZ];
- int narg; /* nb of args */
- char mode[2];
-} CSIEscape;
-
-/* STR Escape sequence structs */
-/* ESC type [[ [<priv>] <arg> [;]] <mode>] ESC '\' */
-typedef struct {
- char type; /* ESC type ... */
- char *buf; /* allocated raw string */
- size_t siz; /* allocation size */
- size_t len; /* raw string length */
- char *args[STR_ARG_SIZ];
- int narg; /* nb of args */
-} STREscape;
-
-/* x.c */
-typedef struct TermWindow TermWindow;
-
-struct TermWindow {
- int tw, th; /* tty width and height */
- int w, h; /* window width and height */
- int hb, vb; /* horizontal and vertical border (in pix) */
- int ch; /* char height */
- int cw; /* char width */
- int mode; /* window state/mode flags */
- int cursor; /* cursor style */
-};
-
-/* used for user hooks */
-union Arg {
- int i;
- uint ui;
- float f;
- void *v;
- char *s;
-};
-
-// -----------------------------------------------------------------------
-// x.c (backend functions)
-
-void xbell(void);
-void xclipcopy(void);
-void xdrawcursor(int, int, Letter, int, int, Letter, Letter*, int);
-void xdrawline(Letter*, int, int, int);
-void xfinishdraw(void);
-void xloadcols(void);
-int xsetcolorname(int, char *);
-void xsettitle(char *);
-int xsetcursor(int);
-void xsetmode(int, uint);
-void xsetpointermotion(int);
-void xsetsel(char *);
-int xstartdraw(void);
-void xximspot(int, int);
-
-void fatal( char *, ...);
-void redraw(void);
-void draw(void);
-
-void printscreen(Arg *);
-void printsel(Arg *);
-void sendbreak(Arg *);
-void toggleprinter(Arg *);
-
-int tattrset(int);
-void tnew(int, int);
-void tresize(int, int);
-void tsetdirtattr(int);
-void ttyhangup(void);
-int ttynew(char *, char *, char *, char **);
-ulong ttyread(void);
-void ttyresize(int, int);
-void ttywrite( char *, size_t, int);
-
-void resettitle(void);
-
-void selclear(void);
-void selinit(void);
-void selstart(int, int, int);
-void selextend(int, int, int, int);
-int selected(int, int);
-char *getsel(void);
-
-void *xmalloc(size_t);
-void *xrealloc(void *, size_t);
-char *xstrdup(char *);
-
-/* config.h globals */
-extern char *utmp;
-extern char *scroll;
-extern char *stty_args;
-extern char *vtiden;
-extern wchar *worddelimiters;
-extern int allowaltscreen;
-extern int allowwindowops;
-extern char *termname;
-extern uint tabspaces;
-extern uint defaultfg;
-extern uint defaultbg;
-extern float alpha;