diff options
author | Nicholas Noll <nbnoll@eml.cc> | 2020-06-08 15:07:04 -0700 |
---|---|---|
committer | Nicholas Noll <nbnoll@eml.cc> | 2020-06-08 15:07:04 -0700 |
commit | ede65127cb813cd1efc8c8237c69c4308a761b33 (patch) | |
tree | f9540a6f5556bb924698656f5410a3062667cf6b /sys/cmd/dvtm/dvtm.h | |
parent | ac78d59c80b627a5332ac64a7d4359389c4251fa (diff) |
feat: added dvtm underneath source tree
Diffstat (limited to 'sys/cmd/dvtm/dvtm.h')
-rw-r--r-- | sys/cmd/dvtm/dvtm.h | 245 |
1 files changed, 245 insertions, 0 deletions
diff --git a/sys/cmd/dvtm/dvtm.h b/sys/cmd/dvtm/dvtm.h new file mode 100644 index 0000000..18669fb --- /dev/null +++ b/sys/cmd/dvtm/dvtm.h @@ -0,0 +1,245 @@ +#pragma once + +/* + * The initial "port" of dwm to curses was done by + * + * © 2007-2016 Marc André Tanner <mat at brain-dump dot org> + * © 2020-???? Nicholas Noll <nbnoll at eml.cc> + * + * It is highly inspired by the original X11 dwm and + * reuses some code of it which is mostly + * + * © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com> + * + * See LICENSE for details. + */ + +#include <u.h> + +#include <stdlib.h> +#include <unistd.h> +#include <stdint.h> +#include <wchar.h> +#include <limits.h> +#include <libgen.h> +#include <sys/select.h> +#include <sys/stat.h> +#include <sys/ioctl.h> +#include <sys/wait.h> +#include <sys/time.h> +#include <sys/types.h> +#include <fcntl.h> +#include <curses.h> +#include <stdio.h> +#include <stdarg.h> +#include <signal.h> +#include <locale.h> +#include <string.h> +#include <unistd.h> +#include <stdbool.h> +#include <errno.h> +#include <pwd.h> +#include <termios.h> + +#include "vt.h" + +#ifdef PDCURSES +int ESCDELAY; +#endif + +#ifndef NCURSES_REENTRANT +# define set_escdelay(d) (ESCDELAY = (d)) +#endif + +typedef struct { + float mfact; + unsigned int nmaster; + int history; + int w; + int h; + volatile sig_atomic_t need_resize; +} Screen; + +typedef struct { + const char *symbol; + void (*arrange)(void); +} Layout; + +typedef struct Client Client; +struct Client { + WINDOW *window; + Vt *term; + Vt *editor, *app; + int editor_fds[2]; + volatile sig_atomic_t editor_died; + const char *cmd; + char title[255]; + int order; + pid_t pid; + ushort id; + ushort x; + ushort y; + ushort w; + ushort h; + bool has_title_line; + bool minimized; + bool urgent; + volatile sig_atomic_t died; + Client *next; + Client *prev; + Client *snext; + unsigned int tags; +}; + +typedef struct { + short fg; + short bg; + short fg256; + short bg256; + short pair; +} Color; + +typedef struct { + const char *title; + attr_t attrs; + Color *color; +} ColorRule; + +#define ALT(k) ((k) + (161 - 'a')) +#if defined CTRL && defined _AIX + #undef CTRL +#endif +#ifndef CTRL + #define CTRL(k) ((k) & 0x1F) +#endif +#define CTRL_ALT(k) ((k) + (129 - 'a')) + +#define MAX_ARGS 8 + +typedef struct { + void (*cmd)(const char *args[]); + const char *args[3]; +} Action; + +#define MAX_KEYS 3 + +typedef unsigned int KeyCombo[MAX_KEYS]; + +typedef struct { + KeyCombo keys; + Action action; +} KeyBinding; + +typedef struct { + mmask_t mask; + Action action; +} Button; + +typedef struct { + const char *name; + Action action; +} Cmd; + +enum { BAR_TOP, BAR_BOTTOM, BAR_OFF }; + +typedef struct { + int fd; + int pos, lastpos; + bool autohide; + ushort h; + ushort y; + char text[512]; + const char *file; +} StatusBar; + +typedef struct { + int fd; + const char *file; + ushort id; +} CmdFifo; + +typedef struct { + char *data; + size_t len; + size_t size; +} Register; + +typedef struct { + char *name; + const char *argv[4]; + bool filter; + bool color; +} Editor; + +#define TAGMASK ((1 << arrlen(tags)) - 1) + +#ifdef NDEBUG + #define debug(format, args...) +#else + #define debug eprint +#endif + +/* commands for use by keybindings */ +void create(const char *args[]); +void copymode(const char *args[]); +void focusn(const char *args[]); +void focusid(const char *args[]); +void focusnext(const char *args[]); +void focusnextnm(const char *args[]); +void focusprev(const char *args[]); +void focusprevnm(const char *args[]); +void focuslast(const char *args[]); +void focusup(const char *args[]); +void focusdown(const char *args[]); +void focusleft(const char *args[]); +void focusright(const char *args[]); +void killclient(const char *args[]); +void paste(const char *args[]); +void quit(const char *args[]); +void redraw(const char *args[]); +void scrollback(const char *args[]); +void send(const char *args[]); +void setlayout(const char *args[]); +void incnmaster(const char *args[]); +void setmfact(const char *args[]); +void startup(const char *args[]); +void tag(const char *args[]); +void tagid(const char *args[]); +void togglebar(const char *args[]); +void togglebarpos(const char *args[]); +void toggleminimize(const char *args[]); +void togglemouse(const char *args[]); +void togglerunall(const char *args[]); +void toggletag(const char *args[]); +void toggleview(const char *args[]); +void viewprevtag(const char *args[]); +void view(const char *args[]); +void zoom(const char *args[]); + +/* commands for use by mouse bindings */ +void mouse_focus(const char *args[]); +void mouse_fullscreen(const char *args[]); +void mouse_minimize(const char *args[]); +void mouse_zoom(const char *args[]); + +/* functions and variables available to layouts via config.h */ +Client* nextvisible(Client *c); +void focus(Client *c); +void resize(Client *c, int x, int y, int w, int h); + +extern Screen screen; +extern unsigned int waw, wah, wax, way; +extern Client *clients; +extern char *title; + +void fibonacci(int s); +void spiral(void); +void dwindle(void); +void fullscreen(void); +void grid(void); +void tile(void); +void tstack(void); +void bstack(void); +void vstack(void); + +#include "config.h" |