Fixed clang-format; updated cmakelists

split-selection
Jef Roosens 2020-12-26 11:26:08 +01:00
parent 39fd726a51
commit 8d792bbc50
17 changed files with 1858 additions and 1685 deletions

View File

@ -1 +1,149 @@
IndentWidth: 4
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: true
AlignConsecutiveAssignments: true
AlignConsecutiveBitFields: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 79
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
- Regex: '.*'
Priority: 1
SortPriority: 0
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentCaseLabels: false
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: Latest
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 4
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
...

View File

@ -0,0 +1,3 @@
#!/usr/bin/env sh
make format

View File

@ -1,5 +1,5 @@
# Upcoming
## v0.1
## v1.0
* Switched build to CMake
* Completely overhauled code structure
* Separate code into logical blocks
@ -7,7 +7,7 @@
* Add a desktop entry when installing
based on [desktopentry](https://st.suckless.org/patches/desktopentry/)
## v0.2
## v1.1
* Configurable transparency (focused and unfocused)
based on [alpha](https://st.suckless.org/patches/alpha/) and
[alpha focus highlight](https://st.suckless.org/patches/alpha_focus_highlight/)
@ -16,7 +16,7 @@
* Copy to clipboard on selection
based on [one clipboard](https://st.suckless.org/patches/clipboard/)
## v0.3
## v1.2
* Add better/gapless rendering of lines/blocks
based on [boxdraw](https://st.suckless.org/patches/boxdraw/)
* Add support for multiple fonts
@ -24,7 +24,7 @@
* Hide cursor when working in the terminal
based on [hidecursor](https://st.suckless.org/patches/hidecursor/)
## v0.4
## v2.0
* Add ligature support
based on [ligature support](https://st.suckless.org/patches/ligatures/)
* Support for multiple color pallets

View File

@ -10,6 +10,9 @@ PREFIX := /usr/local
MANPREFIX := $(PREFIX)/share/man
SHELL := $(shell which sh)
all: debug
.PHONY: all
@ -90,4 +93,4 @@ clean-debug:
# =====FORMAT CODE=====
format:
@ clang-format -i --style=file src/**/*.c src/**/*.h
@ clang-format -i --style=file src/**/*.c src/**/*.h src/*.c src/*.h

View File

@ -19,7 +19,7 @@ add_definitions(-DVERSION="${CMAKE_PROJECT_VERSION}" -D_XOPEN_SOURCE=600)
# =====BUILD TYPES=====
# Debug
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -Wall -O0 -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -O0 -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address -pedantic")
# Arch doesn't use static libraries
@ -43,8 +43,6 @@ add_executable(stj x.c "${st_SRC}" "${main_SRC}")
find_package(Freetype 2 REQUIRED)
target_include_directories(stj PRIVATE "${FREETYPE_INCLUDE_DIRS}")
target_link_libraries(stj PRIVATE "${FREETYPE_LIBRARIES}")
target_link_libraries(stj PRIVATE Xft)
target_link_libraries(stj PRIVATE Xrender)
find_package(Fontconfig 2 REQUIRED)
target_include_directories(stj PRIVATE "${Fontconfig_INCLUDE_DIRS}")
@ -53,6 +51,9 @@ target_link_libraries(stj PRIVATE "${Fontconfig_LIBRARIES}")
find_package(X11 REQUIRED)
target_include_directories(stj PRIVATE "${X11_INCLUDE_DIR}")
target_link_libraries(stj PRIVATE "${X11_LIBRARIES}")
# TODO Find out if these are included in the above statement or not
# target_link_libraries(stj PRIVATE Xft)
# target_link_libraries(stj PRIVATE Xrender)
# Normally provided with clang
target_link_libraries(stj PRIVATE m)

View File

@ -9,40 +9,40 @@
extern char *argv0;
/* use main(int argc, char *argv[]) */
#define ARGBEGIN \
for (argv0 = *argv, argv++, argc--; \
argv[0] && argv[0][0] == '-' && argv[0][1]; argc--, argv++) { \
char argc_; \
char **argv_; \
int brk_; \
if (argv[0][1] == '-' && argv[0][2] == '\0') { \
argv++; \
argc--; \
break; \
} \
int i_; \
for (i_ = 1, brk_ = 0, argv_ = argv; argv[0][i_] && !brk_; i_++) { \
if (argv_ != argv) \
break; \
argc_ = argv[0][i_]; \
switch (argc_)
#define ARGBEGIN \
for (argv0 = *argv, argv++, argc--; \
argv[0] && argv[0][0] == '-' && argv[0][1]; argc--, argv++) { \
char argc_; \
char **argv_; \
int brk_; \
if (argv[0][1] == '-' && argv[0][2] == '\0') { \
argv++; \
argc--; \
break; \
} \
int i_; \
for (i_ = 1, brk_ = 0, argv_ = argv; argv[0][i_] && !brk_; i_++) { \
if (argv_ != argv) \
break; \
argc_ = argv[0][i_]; \
switch (argc_)
#define ARGEND \
} \
}
#define ARGEND \
} \
}
#define ARGC() argc_
#define EARGF(x) \
((argv[0][i_ + 1] == '\0' && argv[1] == NULL) \
? ((x), abort(), (char *)0) \
: (brk_ = 1, (argv[0][i_ + 1] != '\0') ? (&argv[0][i_ + 1]) \
: (argc--, argv++, argv[0])))
#define EARGF(x) \
((argv[0][i_ + 1] == '\0' && argv[1] == NULL) \
? ((x), abort(), (char *)0) \
: (brk_ = 1, (argv[0][i_ + 1] != '\0') ? (&argv[0][i_ + 1]) \
: (argc--, argv++, argv[0])))
#define ARGF() \
((argv[0][i_ + 1] == '\0' && argv[1] == NULL) \
? (char *)0 \
: (brk_ = 1, (argv[0][i_ + 1] != '\0') ? (&argv[0][i_ + 1]) \
: (argc--, argv++, argv[0])))
#define ARGF() \
((argv[0][i_ + 1] == '\0' && argv[1] == NULL) \
? (char *)0 \
: (brk_ = 1, (argv[0][i_ + 1] != '\0') ? (&argv[0][i_ + 1]) \
: (argc--, argv++, argv[0])))
#endif

View File

@ -5,7 +5,8 @@
*
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
*/
static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true";
static char *font =
"Liberation Mono:pixelsize=12:antialias=true:autohint=true";
static int borderpx = 2;
/*
@ -17,9 +18,9 @@ static int borderpx = 2;
* 5: value of shell in config.h
*/
static char *shell = "/bin/sh";
char *utmp = NULL;
char * utmp = NULL;
/* scroll program: to enable use a string like "scroll" */
char *scroll = NULL;
char *scroll = NULL;
char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
/* identification sequence returned in DA and DECID */
@ -126,9 +127,9 @@ static const char *colorname[] = {
* Default colors (colorname index)
* foreground, background, cursor, reverse cursor
*/
unsigned int defaultfg = 7;
unsigned int defaultbg = 0;
static unsigned int defaultcs = 256;
unsigned int defaultfg = 7;
unsigned int defaultbg = 0;
static unsigned int defaultcs = 256;
static unsigned int defaultrcs = 257;
/*
@ -151,8 +152,8 @@ static unsigned int rows = 24;
* Default colour and shape of the mouse cursor
*/
static unsigned int mouseshape = XC_xterm;
static unsigned int mousefg = 7;
static unsigned int mousebg = 0;
static unsigned int mousefg = 7;
static unsigned int mousebg = 0;
/*
* Color used to display font attributes when fontconfig selected a font which
@ -181,7 +182,7 @@ static MouseShortcut mshortcuts[] = {
};
/* Internal keyboard shortcuts. */
#define MODKEY Mod1Mask
#define MODKEY Mod1Mask
#define TERMMOD (ControlMask | ShiftMask)
static Shortcut shortcuts[] = {

View File

@ -5,7 +5,8 @@
*
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
*/
static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true";
static char *font =
"Liberation Mono:pixelsize=12:antialias=true:autohint=true";
static int borderpx = 2;
/*
@ -17,9 +18,9 @@ static int borderpx = 2;
* 5: value of shell in config.h
*/
static char *shell = "/bin/sh";
char *utmp = NULL;
char * utmp = NULL;
/* scroll program: to enable use a string like "scroll" */
char *scroll = NULL;
char *scroll = NULL;
char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
/* identification sequence returned in DA and DECID */
@ -126,9 +127,9 @@ static const char *colorname[] = {
* Default colors (colorname index)
* foreground, background, cursor, reverse cursor
*/
unsigned int defaultfg = 7;
unsigned int defaultbg = 0;
static unsigned int defaultcs = 256;
unsigned int defaultfg = 7;
unsigned int defaultbg = 0;
static unsigned int defaultcs = 256;
static unsigned int defaultrcs = 257;
/*
@ -151,8 +152,8 @@ static unsigned int rows = 24;
* Default colour and shape of the mouse cursor
*/
static unsigned int mouseshape = XC_xterm;
static unsigned int mousefg = 7;
static unsigned int mousebg = 0;
static unsigned int mousefg = 7;
static unsigned int mousebg = 0;
/*
* Color used to display font attributes when fontconfig selected a font which
@ -181,7 +182,7 @@ static MouseShortcut mshortcuts[] = {
};
/* Internal keyboard shortcuts. */
#define MODKEY Mod1Mask
#define MODKEY Mod1Mask
#define TERMMOD (ControlMask | ShiftMask)
static Shortcut shortcuts[] = {

View File

@ -1,20 +1,20 @@
#ifndef MACROS_H
#define MACROS_H
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) < (b) ? (b) : (a))
#define LEN(a) (sizeof(a) / sizeof(a)[0])
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) < (b) ? (b) : (a))
#define LEN(a) (sizeof(a) / sizeof(a)[0])
#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 ATTRCMP(a, 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 ATTRCMP(a, b) \
((a).mode != (b).mode || (a).fg != (b).fg || (a).bg != (b).bg)
#define TIMEDIFF(t1, t2) \
#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 IS_TRUECOL(x) (1 << 24 & (x))
#endif

View File

@ -43,8 +43,8 @@ void selscroll(int orig, int n) {
sel.ob.y += n;
sel.oe.y += n;
if (sel.ob.y < term.top || sel.ob.y > term.bot || sel.oe.y < term.top ||
sel.oe.y > term.bot) {
if (sel.ob.y < term.top || sel.ob.y > term.bot ||
sel.oe.y < term.top || sel.oe.y > term.bot) {
selclear();
} else {

View File

@ -38,28 +38,28 @@
#define STR_ARG_SIZ ESC_ARG_SIZ
/* macros */
#define IS_SET(flag) ((term.mode & (flag)) != 0)
#define IS_SET(flag) ((term.mode & (flag)) != 0)
#define ISCONTROLC0(c) (BETWEEN(c, 0, 0x1f) || (c) == 0x7f)
#define ISCONTROLC1(c) (BETWEEN(c, 0x80, 0x9f))
#define ISCONTROL(c) (ISCONTROLC0(c) || ISCONTROLC1(c))
#define ISDELIM(u) (u && wcschr(worddelimiters, u))
#define ISCONTROL(c) (ISCONTROLC0(c) || ISCONTROLC1(c))
#define ISDELIM(u) (u && wcschr(worddelimiters, u))
enum term_mode {
MODE_WRAP = 1 << 0,
MODE_INSERT = 1 << 1,
MODE_WRAP = 1 << 0,
MODE_INSERT = 1 << 1,
MODE_ALTSCREEN = 1 << 2,
MODE_CRLF = 1 << 3,
MODE_ECHO = 1 << 4,
MODE_PRINT = 1 << 5,
MODE_UTF8 = 1 << 6,
MODE_CRLF = 1 << 3,
MODE_ECHO = 1 << 4,
MODE_PRINT = 1 << 5,
MODE_UTF8 = 1 << 6,
};
enum cursor_movement { CURSOR_SAVE, CURSOR_LOAD };
enum cursor_state {
CURSOR_DEFAULT = 0,
CURSOR_DEFAULT = 0,
CURSOR_WRAPNEXT = 1,
CURSOR_ORIGIN = 2
CURSOR_ORIGIN = 2
};
enum charset {
@ -73,63 +73,63 @@ enum charset {
};
enum escape_state {
ESC_START = 1,
ESC_CSI = 2,
ESC_STR = 4, /* DCS, OSC, PM, APC */
ESC_START = 1,
ESC_CSI = 2,
ESC_STR = 4, /* DCS, OSC, PM, APC */
ESC_ALTCHARSET = 8,
ESC_STR_END = 16, /* a final string was encountered */
ESC_TEST = 32, /* Enter in test mode */
ESC_UTF8 = 64,
ESC_STR_END = 16, /* a final string was encountered */
ESC_TEST = 32, /* Enter in test mode */
ESC_UTF8 = 64,
};
typedef struct {
Glyph attr; /* current char attributes */
int x;
int y;
char state;
int x;
int y;
char state;
} TCursor;
/* Internal representation of the screen */
typedef struct {
int row; /* nb row */
int col; /* nb col */
Line *line; /* screen */
Line *alt; /* alternate screen */
int *dirty; /* dirtyness of lines */
TCursor 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 */
int row; /* nb row */
int col; /* nb col */
Line * line; /* screen */
Line * alt; /* alternate screen */
int * dirty; /* dirtyness of lines */
TCursor 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 */
} Term;
/* CSI Escape sequence structs */
/* ESC '[' [[ [<priv>] <arg> [;]] <mode> [<mode>]] */
typedef struct {
char buf[ESC_BUF_SIZ]; /* raw string */
size_t len; /* raw string length */
char priv;
int arg[ESC_ARG_SIZ];
int narg; /* nb of args */
char mode[2];
char buf[ESC_BUF_SIZ]; /* raw string */
size_t 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 */
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;
static void execsh(char *, char **);
@ -141,60 +141,60 @@ static void csidump(void);
static void csihandle(void);
static void csiparse(void);
static void csireset(void);
static int eschandle(uchar);
static int eschandle(uchar);
static void strdump(void);
static void strhandle(void);
static void strparse(void);
static void strreset(void);
static void tprinter(char *, size_t);
static void tdumpsel(void);
static void tdumpline(int);
static void tdump(void);
static void tclearregion(int, int, int, int);
static void tcursor(int);
static void tdeletechar(int);
static void tdeleteline(int);
static void tinsertblank(int);
static void tinsertblankline(int);
static int tlinelen(int);
static void tmoveto(int, int);
static void tmoveato(int, int);
static void tnewline(int);
static void tputtab(int);
static void tputc(Rune);
static void treset(void);
static void tscrollup(int, int);
static void tscrolldown(int, int);
static void tsetattr(int *, int);
static void tsetchar(Rune, Glyph *, int, int);
static void tsetdirt(int, int);
static void tsetscroll(int, int);
static void tswapscreen(void);
static void tsetmode(int, int, int *, int);
static int twrite(const char *, int, int);
static void tfulldirt(void);
static void tcontrolcode(uchar);
static void tdectest(char);
static void tdefutf8(char);
static void tprinter(char *, size_t);
static void tdumpsel(void);
static void tdumpline(int);
static void tdump(void);
static void tclearregion(int, int, int, int);
static void tcursor(int);
static void tdeletechar(int);
static void tdeleteline(int);
static void tinsertblank(int);
static void tinsertblankline(int);
static int tlinelen(int);
static void tmoveto(int, int);
static void tmoveato(int, int);
static void tnewline(int);
static void tputtab(int);
static void tputc(Rune);
static void treset(void);
static void tscrollup(int, int);
static void tscrolldown(int, int);
static void tsetattr(int *, int);
static void tsetchar(Rune, Glyph *, int, int);
static void tsetdirt(int, int);
static void tsetscroll(int, int);
static void tswapscreen(void);
static void tsetmode(int, int, int *, int);
static int twrite(const char *, int, int);
static void tfulldirt(void);
static void tcontrolcode(uchar);
static void tdectest(char);
static void tdefutf8(char);
static int32_t tdefcolor(int *, int *, int);
static void tdeftran(char);
static void tstrsequence(uchar);
static void tdeftran(char);
static void tstrsequence(uchar);
static void drawregion(int, int, int, int);
static char *base64dec(const char *);
static char base64dec_getc(const char **);
static char base64dec_getc(const char **);
static ssize_t xwrite(int, const char *, size_t);
/* Globals */
static Term term;
static Term term;
static CSIEscape csiescseq;
static STREscape strescseq;
static int iofd = 1;
static int cmdfd;
static pid_t pid;
static int iofd = 1;
static int cmdfd;
static pid_t pid;
/**
* Same as write, but ensures that all bytes are written to the descriptor
@ -203,11 +203,11 @@ static pid_t pid;
* @param p_file_desc file descriptor to write to; same logic as write
* @param p_str char array to write to the file descriptor
* @param p_nbytes amount of bytes to write
* @return p_nbytes if the write was successful, otherwise return negative error
* value of write
* @return p_nbytes if the write was successful, otherwise return negative
* error value of write
*/
ssize_t xwrite(int p_file_desc, const char *p_str, size_t p_nbytes) {
size_t aux = p_nbytes;
size_t aux = p_nbytes;
ssize_t result;
while (p_nbytes > 0) {
@ -290,7 +290,7 @@ char base64dec_getc(const char **src) {
char *base64dec(const char *src) {
size_t in_len = strlen(src);
char *result, *dst;
char * result, *dst;
if (in_len % 4)
in_len += 4 - (in_len % 4);
@ -333,7 +333,7 @@ void selstart(int col, int row, int snap) {
selclear();
sel.mode = SEL_EMPTY;
sel.type = SEL_REGULAR;
sel.alt = IS_SET(MODE_ALTSCREEN);
sel.alt = IS_SET(MODE_ALTSCREEN);
sel.snap = snap;
sel.oe.x = sel.ob.x = col;
sel.oe.y = sel.ob.y = row;
@ -354,10 +354,10 @@ void selextend(int col, int row, int type, int done) {
return;
}
oldey = sel.oe.y;
oldex = sel.oe.x;
oldsby = sel.nb.y;
oldsey = sel.ne.y;
oldey = sel.oe.y;
oldex = sel.oe.x;
oldsby = sel.nb.y;
oldsey = sel.ne.y;
oldtype = sel.type;
sel.oe.x = col;
@ -378,15 +378,17 @@ int selected(int x, int y) {
return 0;
if (sel.type == SEL_RECTANGULAR)
return BETWEEN(y, sel.nb.y, sel.ne.y) && BETWEEN(x, sel.nb.x, sel.ne.x);
return BETWEEN(y, sel.nb.y, sel.ne.y) &&
BETWEEN(x, sel.nb.x, sel.ne.x);
return BETWEEN(y, sel.nb.y, sel.ne.y) && (y != sel.nb.y || x >= sel.nb.x) &&
return BETWEEN(y, sel.nb.y, sel.ne.y) &&
(y != sel.nb.y || x >= sel.nb.x) &&
(y != sel.ne.y || x <= sel.ne.x);
}
void selsnap(int *x, int *y, int direction) {
int newx, newy, xt, yt;
int delim, prevdelim;
int newx, newy, xt, yt;
int delim, prevdelim;
Glyph *gp, *prevgp;
switch (sel.snap) {
@ -395,7 +397,7 @@ void selsnap(int *x, int *y, int direction) {
* Snap around if the word wraps around at the end or
* beginning of a line.
*/
prevgp = &term.line[*y][*x];
prevgp = &term.line[*y][*x];
prevdelim = ISDELIM(prevgp->u);
for (;;) {
newx = *x + direction;
@ -417,15 +419,15 @@ void selsnap(int *x, int *y, int direction) {
if (newx >= tlinelen(newy))
break;
gp = &term.line[newy][newx];
gp = &term.line[newy][newx];
delim = ISDELIM(gp->u);
if (!(gp->mode & ATTR_WDUMMY) &&
(delim != prevdelim || (delim && gp->u != prevgp->u)))
break;
*x = newx;
*y = newy;
prevgp = gp;
*x = newx;
*y = newy;
prevgp = gp;
prevdelim = delim;
}
break;
@ -454,8 +456,8 @@ void selsnap(int *x, int *y, int direction) {
}
char *getsel(void) {
char *str, *ptr;
int y, bufsize, lastx, linelen;
char * str, *ptr;
int y, bufsize, lastx, linelen;
Glyph *gp, *last;
if (sel.ob.x == -1)
@ -472,10 +474,10 @@ char *getsel(void) {
}
if (sel.type == SEL_RECTANGULAR) {
gp = &term.line[y][sel.nb.x];
gp = &term.line[y][sel.nb.x];
lastx = sel.ne.x;
} else {
gp = &term.line[y][sel.nb.y == y ? sel.nb.x : 0];
gp = &term.line[y][sel.nb.y == y ? sel.nb.x : 0];
lastx = (sel.ne.y == y) ? sel.ne.x : term.col - 1;
}
last = &term.line[y][MIN(lastx, linelen - 1)];
@ -516,7 +518,7 @@ void die(const char *errstr, ...) {
}
void execsh(char *cmd, char **args) {
char *sh, *prog, *arg;
char * sh, *prog, *arg;
const struct passwd *pw;
errno = 0;
@ -532,16 +534,16 @@ void execsh(char *cmd, char **args) {
if (args) {
prog = args[0];
arg = NULL;
arg = NULL;
} else if (scroll) {
prog = scroll;
arg = utmp ? utmp : sh;
arg = utmp ? utmp : sh;
} else if (utmp) {
prog = utmp;
arg = NULL;
arg = NULL;
} else {
prog = sh;
arg = NULL;
arg = NULL;
}
DEFAULT(args, ((char *[]){prog, arg, NULL}));
@ -566,7 +568,7 @@ void execsh(char *cmd, char **args) {
}
void sigchld(int a) {
int stat;
int stat;
pid_t p;
if ((p = waitpid(pid, &stat, WNOHANG)) < 0)
@ -583,13 +585,13 @@ void sigchld(int a) {
}
void stty(char **args) {
char cmd[_POSIX_ARG_MAX], **p, *q, *s;
char cmd[_POSIX_ARG_MAX], **p, *q, *s;
size_t n, siz;
if ((n = strlen(stty_args)) > sizeof(cmd) - 1)
die("incorrect stty parameters\n");
memcpy(cmd, stty_args, n);
q = cmd + n;
q = cmd + n;
siz = sizeof(cmd) - n;
for (p = args; p && (s = *p); ++p) {
if ((n = strlen(s)) > siz - 1)
@ -662,8 +664,8 @@ int ttynew(char *line, char *cmd, char *out, char **args) {
size_t ttyread(void) {
static char buf[BUFSIZ];
static int buflen = 0;
int ret, written;
static int buflen = 0;
int ret, written;
/* append read bytes to unprocessed bytes */
ret = read(cmdfd, buf + buflen, LEN(buf) - buflen);
@ -711,9 +713,9 @@ void ttywrite(const char *s, size_t n, int may_echo) {
}
void ttywriteraw(const char *s, size_t n) {
fd_set wfd, rfd;
fd_set wfd, rfd;
ssize_t r;
size_t lim = 256;
size_t lim = 256;
/*
* Remember that we are using a pty, which might be a modem line.
@ -768,8 +770,8 @@ write_error:
void ttyresize(int tw, int th) {
struct winsize w;
w.ws_row = term.row;
w.ws_col = term.col;
w.ws_row = term.row;
w.ws_col = term.col;
w.ws_xpixel = tw;
w.ws_ypixel = th;
if (ioctl(cmdfd, TIOCSWINSZ, &w) < 0)
@ -821,7 +823,7 @@ void tfulldirt(void) { tsetdirt(0, term.row - 1); }
void tcursor(int mode) {
static TCursor c[2];
int alt = IS_SET(MODE_ALTSCREEN);
int alt = IS_SET(MODE_ALTSCREEN);
if (mode == CURSOR_SAVE) {
c[alt] = term.c;
@ -835,15 +837,15 @@ void treset(void) {
uint i;
term.c = (TCursor){{.mode = ATTR_NULL, .fg = defaultfg, .bg = defaultbg},
.x = 0,
.y = 0,
.x = 0,
.y = 0,
.state = CURSOR_DEFAULT};
memset(term.tabs, 0, term.col * sizeof(*term.tabs));
for (i = tabspaces; i < term.col; i += tabspaces)
term.tabs[i] = 1;
term.top = 0;
term.bot = term.row - 1;
term.top = 0;
term.bot = term.row - 1;
term.mode = MODE_WRAP | MODE_UTF8;
memset(term.trantbl, CS_USA, sizeof(term.trantbl));
term.charset = 0;
@ -866,13 +868,13 @@ void tswapscreen(void) {
Line *tmp = term.line;
term.line = term.alt;
term.alt = tmp;
term.alt = tmp;
term.mode ^= MODE_ALTSCREEN;
tfulldirt();
}
void tscrolldown(int orig, int n) {
int i;
int i;
Line temp;
LIMIT(n, 0, term.bot - orig + 1);
@ -881,8 +883,8 @@ void tscrolldown(int orig, int n) {
tclearregion(0, term.bot - n + 1, term.col - 1, term.bot);
for (i = term.bot; i >= orig + n; i--) {
temp = term.line[i];
term.line[i] = term.line[i - n];
temp = term.line[i];
term.line[i] = term.line[i - n];
term.line[i - n] = temp;
}
@ -890,7 +892,7 @@ void tscrolldown(int orig, int n) {
}
void tscrollup(int orig, int n) {
int i;
int i;
Line temp;
LIMIT(n, 0, term.bot - orig + 1);
@ -899,8 +901,8 @@ void tscrollup(int orig, int n) {
tsetdirt(orig + n, term.bot);
for (i = orig; i <= term.bot - n; i++) {
temp = term.line[i];
term.line[i] = term.line[i + n];
temp = term.line[i];
term.line[i] = term.line[i + n];
term.line[i + n] = temp;
}
@ -919,7 +921,7 @@ void tnewline(int first_col) {
}
void csiparse(void) {
char *p = csiescseq.buf, *np;
char * p = csiescseq.buf, *np;
long int v;
csiescseq.narg = 0;
@ -931,13 +933,13 @@ void csiparse(void) {
csiescseq.buf[csiescseq.len] = '\0';
while (p < csiescseq.buf + csiescseq.len) {
np = NULL;
v = strtol(p, &np, 10);
v = strtol(p, &np, 10);
if (np == p)
v = 0;
if (v == LONG_MAX || v == LONG_MIN)
v = -1;
csiescseq.arg[csiescseq.narg++] = v;
p = np;
p = np;
if (*p != ';' || csiescseq.narg == ESC_ARG_SIZ)
break;
p++;
@ -996,13 +998,13 @@ void tsetchar(Rune u, Glyph *attr, int x, int y) {
term.line[y][x - 1].mode &= ~ATTR_WIDE;
}
term.dirty[y] = 1;
term.line[y][x] = *attr;
term.dirty[y] = 1;
term.line[y][x] = *attr;
term.line[y][x].u = u;
}
void tclearregion(int x1, int y1, int x2, int y2) {
int x, y, temp;
int x, y, temp;
Glyph *gp;
if (x1 > x2)
@ -1021,22 +1023,22 @@ void tclearregion(int x1, int y1, int x2, int y2) {
gp = &term.line[y][x];
if (selected(x, y))
selclear();
gp->fg = term.c.attr.fg;
gp->bg = term.c.attr.bg;
gp->fg = term.c.attr.fg;
gp->bg = term.c.attr.bg;
gp->mode = 0;
gp->u = ' ';
gp->u = ' ';
}
}
}
void tdeletechar(int n) {
int dst, src, size;
int dst, src, size;
Glyph *line;
LIMIT(n, 0, term.col - term.c.x);
dst = term.c.x;
src = term.c.x + n;
dst = term.c.x;
src = term.c.x + n;
size = term.col - src;
line = term.line[term.c.y];
@ -1045,13 +1047,13 @@ void tdeletechar(int n) {
}
void tinsertblank(int n) {
int dst, src, size;
int dst, src, size;
Glyph *line;
LIMIT(n, 0, term.col - term.c.x);
dst = term.c.x + n;
src = term.c.x;
dst = term.c.x + n;
src = term.c.x;
size = term.col - dst;
line = term.line[term.c.y];
@ -1071,12 +1073,13 @@ void tdeleteline(int n) {
int32_t tdefcolor(int *attr, int *npar, int l) {
int32_t idx = -1;
uint r, g, b;
uint r, g, b;
switch (attr[*npar + 1]) {
case 2: /* direct color in RGB space */
if (*npar + 4 >= l) {
fprintf(stderr, "erresc(38): Incorrect number of parameters (%d)\n",
fprintf(stderr,
"erresc(38): Incorrect number of parameters (%d)\n",
*npar);
break;
}
@ -1091,7 +1094,8 @@ int32_t tdefcolor(int *attr, int *npar, int l) {
break;
case 5: /* indexed color */
if (*npar + 2 >= l) {
fprintf(stderr, "erresc(38): Incorrect number of parameters (%d)\n",
fprintf(stderr,
"erresc(38): Incorrect number of parameters (%d)\n",
*npar);
break;
}
@ -1114,7 +1118,7 @@ int32_t tdefcolor(int *attr, int *npar, int l) {
}
void tsetattr(int *attr, int l) {
int i;
int i;
int32_t idx;
for (i = 0; i < l; i++) {
@ -1213,8 +1217,8 @@ void tsetscroll(int t, int b) {
LIMIT(b, 0, term.row - 1);
if (t > b) {
temp = t;
t = b;
b = temp;
t = b;
b = temp;
}
term.top = t;
term.bot = b;
@ -1346,7 +1350,7 @@ void tsetmode(int priv, int set, int *args, int narg) {
void csihandle(void) {
char buf[40];
int len;
int len;
switch (csiescseq.mode[0]) {
default:
@ -1554,7 +1558,7 @@ void csihandle(void) {
void csidump(void) {
size_t i;
uint c;
uint c;
fprintf(stderr, "ESC[");
for (i = 0; i < csiescseq.len; i++) {
@ -1578,7 +1582,7 @@ void csireset(void) { memset(&csiescseq, 0, sizeof(csiescseq)); }
void strhandle(void) {
char *p = NULL, *dec;
int j, narg, par;
int j, narg, par;
term.esc &= ~(ESC_STR_END | ESC_STR);
strparse();
@ -1648,10 +1652,10 @@ void strhandle(void) {
}
void strparse(void) {
int c;
int c;
char *p = strescseq.buf;
strescseq.narg = 0;
strescseq.narg = 0;
strescseq.buf[strescseq.len] = '\0';
if (*p == '\0')
@ -1669,7 +1673,7 @@ void strparse(void) {
void strdump(void) {
size_t i;
uint c;
uint c;
fprintf(stderr, "ESC%c", strescseq.type);
for (i = 0; i < strescseq.len; i++) {
@ -1728,10 +1732,10 @@ void tdumpsel(void) {
}
void tdumpline(int n) {
char buf[UTF_SIZE];
char buf[UTF_SIZE];
Glyph *bp, *end;
bp = &term.line[n][0];
bp = &term.line[n][0];
end = &bp[MIN(tlinelen(n), term.col) - 1];
if (bp != end || bp->u != ' ') {
for (; bp <= end; ++bp)
@ -1770,9 +1774,9 @@ void tdefutf8(char ascii) {
}
void tdeftran(char ascii) {
static char cs[] = "0B";
static int vcs[] = {CS_GRAPHIC0, CS_USA};
char *p;
static char cs[] = "0B";
static int vcs[] = {CS_GRAPHIC0, CS_USA};
char * p;
if ((p = strchr(cs, ascii)) == NULL) {
fprintf(stderr, "esc unhandled charset: ESC ( %c\n", ascii);
@ -1993,14 +1997,14 @@ int eschandle(uchar ascii) {
}
void tputc(Rune u) {
char c[UTF_SIZE];
int control;
int width, len;
char c[UTF_SIZE];
int control;
int width, len;
Glyph *gp;
control = ISCONTROL(u);
if (u < 127 || !IS_SET(MODE_UTF8)) {
c[0] = u;
c[0] = u;
width = len = 1;
} else {
len = utf8encode(u, c);
@ -2115,7 +2119,7 @@ check_control_code:
if (width == 2) {
gp->mode |= ATTR_WIDE;
if (term.c.x + 1 < term.col) {
gp[1].u = '\0';
gp[1].u = '\0';
gp[1].mode = ATTR_WDUMMY;
}
}
@ -2127,9 +2131,9 @@ check_control_code:
}
int twrite(const char *buf, int buflen, int show_ctrl) {
int charsize;
int charsize;
Rune u;
int n;
int n;
for (n = 0; n < buflen; n += charsize) {
if (IS_SET(MODE_UTF8)) {
@ -2138,7 +2142,7 @@ int twrite(const char *buf, int buflen, int show_ctrl) {
if (charsize == 0)
break;
} else {
u = buf[n] & 0xFF;
u = buf[n] & 0xFF;
charsize = 1;
}
if (show_ctrl && ISCONTROL(u)) {
@ -2157,10 +2161,10 @@ int twrite(const char *buf, int buflen, int show_ctrl) {
}
void tresize(int col, int row) {
int i;
int minrow = MIN(row, term.row);
int mincol = MIN(col, term.col);
int *bp;
int i;
int minrow = MIN(row, term.row);
int mincol = MIN(col, term.col);
int * bp;
TCursor c;
if (col < 1 || row < 1) {
@ -2188,21 +2192,21 @@ void tresize(int col, int row) {
}
/* resize to new height */
term.line = safe_realloc(term.line, row * sizeof(Line));
term.alt = safe_realloc(term.alt, row * sizeof(Line));
term.line = safe_realloc(term.line, row * sizeof(Line));
term.alt = safe_realloc(term.alt, row * sizeof(Line));
term.dirty = safe_realloc(term.dirty, row * sizeof(*term.dirty));
term.tabs = safe_realloc(term.tabs, col * sizeof(*term.tabs));
term.tabs = safe_realloc(term.tabs, col * sizeof(*term.tabs));
/* resize each row to new width, zero-pad if needed */
for (i = 0; i < minrow; i++) {
term.line[i] = safe_realloc(term.line[i], col * sizeof(Glyph));
term.alt[i] = safe_realloc(term.alt[i], col * sizeof(Glyph));
term.alt[i] = safe_realloc(term.alt[i], col * sizeof(Glyph));
}
/* allocate any new rows */
for (/* i = minrow */; i < row; i++) {
term.line[i] = safe_malloc(col * sizeof(Glyph));
term.alt[i] = safe_malloc(col * sizeof(Glyph));
term.alt[i] = safe_malloc(col * sizeof(Glyph));
}
if (col > term.col) {
bp = term.tabs + term.col;

View File

@ -11,35 +11,35 @@
#include "utf8.h"
enum glyph_attribute {
ATTR_NULL = 0,
ATTR_BOLD = 1 << 0,
ATTR_FAINT = 1 << 1,
ATTR_ITALIC = 1 << 2,
ATTR_UNDERLINE = 1 << 3,
ATTR_BLINK = 1 << 4,
ATTR_REVERSE = 1 << 5,
ATTR_INVISIBLE = 1 << 6,
ATTR_STRUCK = 1 << 7,
ATTR_WRAP = 1 << 8,
ATTR_WIDE = 1 << 9,
ATTR_WDUMMY = 1 << 10,
ATTR_NULL = 0,
ATTR_BOLD = 1 << 0,
ATTR_FAINT = 1 << 1,
ATTR_ITALIC = 1 << 2,
ATTR_UNDERLINE = 1 << 3,
ATTR_BLINK = 1 << 4,
ATTR_REVERSE = 1 << 5,
ATTR_INVISIBLE = 1 << 6,
ATTR_STRUCK = 1 << 7,
ATTR_WRAP = 1 << 8,
ATTR_WIDE = 1 << 9,
ATTR_WDUMMY = 1 << 10,
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
};
#define Glyph Glyph_
typedef struct {
Rune u; /* character code */
ushort mode; /* attribute flags */
uint32_t fg; /* foreground */
uint32_t bg; /* background */
Rune u; /* character code */
ushort mode; /* attribute flags */
uint32_t fg; /* foreground */
uint32_t bg; /* background */
} Glyph;
typedef Glyph *Line;
typedef union {
int i;
uint ui;
float f;
int i;
uint ui;
float f;
const void *v;
const char *s;
} Arg;
@ -53,23 +53,23 @@ void printsel(const Arg *);
void sendbreak(const Arg *);
void toggleprinter(const Arg *);
int tattrset(int);
void tnew(int, int);
void tresize(int, int);
void tsetdirtattr(int);
void ttyhangup(void);
int ttynew(char *, char *, char *, char **);
int tattrset(int);
void tnew(int, int);
void tresize(int, int);
void tsetdirtattr(int);
void ttyhangup(void);
int ttynew(char *, char *, char *, char **);
size_t ttyread(void);
void ttyresize(int, int);
void ttywrite(const char *, size_t, int);
void ttyresize(int, int);
void ttywrite(const 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);
void selclear(void);
void selinit(void);
void selstart(int, int, int);
void selextend(int, int, int, int);
int selected(int, int);
char *getsel(void);
size_t utf8encode(Rune, char *);
@ -79,14 +79,14 @@ void *safe_realloc(void *, size_t);
char *safe_strdup(char *);
/* config.h globals */
extern char *utmp;
extern char *scroll;
extern char *stty_args;
extern char *vtiden;
extern wchar_t *worddelimiters;
extern int allowaltscreen;
extern int allowwindowops;
extern char *termname;
extern char * utmp;
extern char * scroll;
extern char * stty_args;
extern char * vtiden;
extern wchar_t * worddelimiters;
extern int allowaltscreen;
extern int allowwindowops;
extern char * termname;
extern unsigned int tabspaces;
extern unsigned int defaultfg;
extern unsigned int defaultbg;

View File

@ -1,9 +1,9 @@
#ifndef TYPES_H
#define TYPES_H
typedef unsigned char uchar;
typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned char uchar;
typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned short ushort;
#endif

View File

@ -4,8 +4,8 @@
static uchar utfbyte[UTF_SIZE + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
static uchar utfmask[UTF_SIZE + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
static Rune utfmin[UTF_SIZE + 1] = {0, 0, 0x80, 0x800, 0x10000};
static Rune utfmax[UTF_SIZE + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
static Rune utfmin[UTF_SIZE + 1] = {0, 0, 0x80, 0x800, 0x10000};
static Rune utfmax[UTF_SIZE + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
/**
* Decode a given char array into a utf8 Rune
@ -17,7 +17,7 @@ static Rune utfmax[UTF_SIZE + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
*/
size_t utf8decode(const char *p_char, Rune *p_rune, size_t p_char_len) {
size_t decoded_len, type, i;
Rune decoded_rune;
Rune decoded_rune;
*p_rune = UTF_INVALID;
if (!p_char_len) // p_char_len is 0, so just return 0
@ -82,7 +82,9 @@ size_t utf8encode(Rune p_rune, char *p_char) {
return len;
}
char utf8encodebyte(Rune u, size_t i) { return utfbyte[i] | (u & ~utfmask[i]); }
char utf8encodebyte(Rune u, size_t i) {
return utfbyte[i] | (u & ~utfmask[i]);
}
/**
* Check if a given rune is a valid UTF-8 rune

View File

@ -5,13 +5,13 @@
#include <stdlib.h>
#define UTF_INVALID 0xFFFD
#define UTF_SIZE 4
#define UTF_SIZE 4
typedef uint_least32_t Rune;
size_t utf8decode(const char *, Rune *, size_t);
Rune utf8decodebyte(char, size_t *);
char utf8encodebyte(Rune, size_t);
Rune utf8decodebyte(char, size_t *);
char utf8encodebyte(Rune, size_t);
size_t utf8validate(Rune *, size_t);
#endif

View File

@ -6,26 +6,26 @@
#include "st/st.h"
enum win_mode {
MODE_VISIBLE = 1 << 0,
MODE_FOCUSED = 1 << 1,
MODE_APPKEYPAD = 1 << 2,
MODE_MOUSEBTN = 1 << 3,
MODE_MOUSEMOTION = 1 << 4,
MODE_REVERSE = 1 << 5,
MODE_KBDLOCK = 1 << 6,
MODE_HIDE = 1 << 7,
MODE_APPCURSOR = 1 << 8,
MODE_MOUSESGR = 1 << 9,
MODE_8BIT = 1 << 10,
MODE_BLINK = 1 << 11,
MODE_FBLINK = 1 << 12,
MODE_FOCUS = 1 << 13,
MODE_MOUSEX10 = 1 << 14,
MODE_MOUSEMANY = 1 << 15,
MODE_BRCKTPASTE = 1 << 16,
MODE_NUMLOCK = 1 << 17,
MODE_MOUSE =
MODE_MOUSEBTN | MODE_MOUSEMOTION | MODE_MOUSEX10 | MODE_MOUSEMANY,
MODE_VISIBLE = 1 << 0,
MODE_FOCUSED = 1 << 1,
MODE_APPKEYPAD = 1 << 2,
MODE_MOUSEBTN = 1 << 3,
MODE_MOUSEMOTION = 1 << 4,
MODE_REVERSE = 1 << 5,
MODE_KBDLOCK = 1 << 6,
MODE_HIDE = 1 << 7,
MODE_APPCURSOR = 1 << 8,
MODE_MOUSESGR = 1 << 9,
MODE_8BIT = 1 << 10,
MODE_BLINK = 1 << 11,
MODE_FBLINK = 1 << 12,
MODE_FOCUS = 1 << 13,
MODE_MOUSEX10 = 1 << 14,
MODE_MOUSEMANY = 1 << 15,
MODE_BRCKTPASTE = 1 << 16,
MODE_NUMLOCK = 1 << 17,
MODE_MOUSE =
MODE_MOUSEBTN | MODE_MOUSEMOTION | MODE_MOUSEX10 | MODE_MOUSEMANY,
};
void xbell(void);
@ -34,14 +34,14 @@ void xdrawcursor(int, int, Glyph, int, int, Glyph);
void xdrawline(Line, int, int, int);
void xfinishdraw(void);
void xloadcols(void);
int xsetcolorname(int, const char *);
int xsetcolorname(int, const char *);
void xseticontitle(char *);
void xsettitle(char *);
int xsetcursor(int);
int xsetcursor(int);
void xsetmode(int, unsigned int);
void xsetpointermotion(int);
void xsetsel(char *);
int xstartdraw(void);
int xstartdraw(void);
void xximspot(int, int);
#endif

2730
src/x.c

File diff suppressed because it is too large Load Diff