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 @@
---
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

@ -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,7 +18,7 @@ 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 *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";

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,7 +18,7 @@ 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 *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";

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

@ -93,9 +93,9 @@ typedef struct {
typedef struct {
int row; /* nb row */
int col; /* nb col */
Line *line; /* screen */
Line *alt; /* alternate screen */
int *dirty; /* dirtyness of lines */
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 */
@ -106,7 +106,7 @@ typedef struct {
char trantbl[4]; /* charset table translation */
int charset; /* current charset */
int icharset; /* selected charset for sequence */
int *tabs;
int * tabs;
Rune lastc; /* last printed char outside of sequence, 0 if control */
} Term;
@ -125,10 +125,10 @@ typedef struct {
/* ESC type [[ [<priv>] <arg> [;]] <mode>] ESC '\' */
typedef struct {
char type; /* ESC type ... */
char *buf; /* allocated raw string */
char * buf; /* allocated raw string */
size_t siz; /* allocation size */
size_t len; /* raw string length */
char *args[STR_ARG_SIZ];
char * args[STR_ARG_SIZ];
int narg; /* nb of args */
} STREscape;
@ -203,8 +203,8 @@ 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;
@ -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);
@ -378,9 +378,11 @@ 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);
}
@ -454,7 +456,7 @@ void selsnap(int *x, int *y, int direction) {
}
char *getsel(void) {
char *str, *ptr;
char * str, *ptr;
int y, bufsize, lastx, linelen;
Glyph *gp, *last;
@ -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;
@ -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;
@ -1076,7 +1078,8 @@ int32_t tdefcolor(int *attr, int *npar, int l) {
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;
}
@ -1772,7 +1776,7 @@ void tdefutf8(char ascii) {
void tdeftran(char ascii) {
static char cs[] = "0B";
static int vcs[] = {CS_GRAPHIC0, CS_USA};
char *p;
char * p;
if ((p = strchr(cs, ascii)) == NULL) {
fprintf(stderr, "esc unhandled charset: ESC ( %c\n", ascii);
@ -2160,7 +2164,7 @@ void tresize(int col, int row) {
int i;
int minrow = MIN(row, term.row);
int mincol = MIN(col, term.col);
int *bp;
int * bp;
TCursor c;
if (col < 1 || row < 1) {

View File

@ -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 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 * termname;
extern unsigned int tabspaces;
extern unsigned int defaultfg;
extern unsigned int defaultbg;

View File

@ -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

112
src/x.c
View File

@ -40,7 +40,7 @@ typedef struct {
typedef struct {
KeySym k;
uint mask;
char *s;
char * s;
/* three-valued logic variables: 0 indifferent, 1 on, -1 off */
signed char appkey; /* application keypad */
signed char appcursor; /* application cursor */
@ -74,7 +74,7 @@ static void ttysend(const Arg *);
#define TRUEGREEN(x) (((x)&0xff00))
#define TRUEBLUE(x) (((x)&0xff) << 8)
typedef XftDraw *Draw;
typedef XftDraw * Draw;
typedef XftColor Color;
typedef XftGlyphFontSpec GlyphFontSpec;
@ -89,7 +89,7 @@ typedef struct {
} TermWindow;
typedef struct {
Display *dpy;
Display * dpy;
Colormap cmap;
Window win;
Drawable buf;
@ -102,7 +102,7 @@ typedef struct {
XVaNestedList spotlist;
} ime;
Draw draw;
Visual *vis;
Visual * vis;
XSetWindowAttributes attrs;
int scr;
int isfixed; /* is fixed geometry? */
@ -112,7 +112,7 @@ typedef struct {
typedef struct {
Atom xtarget;
char *primary, *clipboard;
char * primary, *clipboard;
struct timespec tclick1;
struct timespec tclick2;
} XSelection;
@ -128,7 +128,7 @@ typedef struct {
int badweight;
short lbearing;
short rbearing;
XftFont *match;
XftFont * match;
FcFontSet *set;
FcPattern *pattern;
} Font;
@ -144,7 +144,8 @@ typedef struct {
static inline ushort sixd_to_16bit(int);
static int xmakeglyphfontspecs(XftGlyphFontSpec *, const Glyph *, int, int,
int);
static void xdrawglyphfontspecs(const XftGlyphFontSpec *, Glyph, int, int, int);
static void xdrawglyphfontspecs(const XftGlyphFontSpec *, Glyph, int, int,
int);
static void xdrawglyph(Glyph, int, int);
static void xclear(int, int, int, int);
static int xgeommasktogravity(int);
@ -236,18 +237,18 @@ typedef struct {
static Fontcache *frc = NULL;
static int frclen = 0;
static int frccap = 0;
static char *usedfont = NULL;
static char * usedfont = NULL;
static double usedfontsize = 0;
static double defaultfontsize = 0;
static char *opt_class = NULL;
static char * opt_class = NULL;
static char **opt_cmd = NULL;
static char *opt_embed = NULL;
static char *opt_font = NULL;
static char *opt_io = NULL;
static char *opt_line = NULL;
static char *opt_name = NULL;
static char *opt_title = NULL;
static char * opt_embed = NULL;
static char * opt_font = NULL;
static char * opt_io = NULL;
static char * opt_line = NULL;
static char * opt_name = NULL;
static char * opt_title = NULL;
static int oldbutton = 3; /* button event on startup: 3 = release */
@ -374,16 +375,17 @@ void mousereport(XEvent *e) {
}
if (!IS_SET(MODE_MOUSEX10)) {
button += ((state & ShiftMask) ? 4 : 0) + ((state & Mod4Mask) ? 8 : 0) +
button += ((state & ShiftMask) ? 4 : 0) +
((state & Mod4Mask) ? 8 : 0) +
((state & ControlMask) ? 16 : 0);
}
if (IS_SET(MODE_MOUSESGR)) {
len = snprintf(buf, sizeof(buf), "\033[<%d;%d;%d%c", button, x + 1, y + 1,
e->xbutton.type == ButtonRelease ? 'm' : 'M');
len = snprintf(buf, sizeof(buf), "\033[<%d;%d;%d%c", button, x + 1,
y + 1, e->xbutton.type == ButtonRelease ? 'm' : 'M');
} else if (x < 223 && y < 223) {
len = snprintf(buf, sizeof(buf), "\033[M%c%c%c", 32 + button, 32 + x + 1,
32 + y + 1);
len = snprintf(buf, sizeof(buf), "\033[M%c%c%c", 32 + button,
32 + x + 1, 32 + y + 1);
} else {
return;
}
@ -479,9 +481,9 @@ void selnotify(XEvent *e) {
return;
do {
if (XGetWindowProperty(xw.dpy, xw.win, property, ofs, BUFSIZ / 4, False,
AnyPropertyType, &type, &format, &nitems, &rem,
&data)) {
if (XGetWindowProperty(xw.dpy, xw.win, property, ofs, BUFSIZ / 4,
False, AnyPropertyType, &type, &format, &nitems,
&rem, &data)) {
fprintf(stderr, "Clipboard allocation failed\n");
return;
}
@ -551,7 +553,7 @@ void selrequest(XEvent *e) {
XSelectionRequestEvent *xsre;
XSelectionEvent xev;
Atom xa_targets, string, clipboard;
char *seltext;
char * seltext;
xsre = (XSelectionRequestEvent *)e;
xev.type = SelectionNotify;
@ -569,8 +571,8 @@ void selrequest(XEvent *e) {
if (xsre->target == xa_targets) {
/* respond with the supported type */
string = xsel.xtarget;
XChangeProperty(xsre->display, xsre->requestor, xsre->property, XA_ATOM, 32,
PropModeReplace, (uchar *)&string, 1);
XChangeProperty(xsre->display, xsre->requestor, xsre->property,
XA_ATOM, 32, PropModeReplace, (uchar *)&string, 1);
xev.property = xsre->property;
} else if (xsre->target == xsel.xtarget || xsre->target == XA_STRING) {
/*
@ -583,7 +585,8 @@ void selrequest(XEvent *e) {
} else if (xsre->selection == clipboard) {
seltext = xsel.clipboard;
} else {
fprintf(stderr, "Unhandled clipboard selection 0x%lx\n", xsre->selection);
fprintf(stderr, "Unhandled clipboard selection 0x%lx\n",
xsre->selection);
return;
}
if (seltext != NULL) {
@ -657,8 +660,8 @@ void xresize(int col, int row) {
win.th = row * win.ch;
XFreePixmap(xw.dpy, xw.buf);
xw.buf =
XCreatePixmap(xw.dpy, xw.win, win.w, win.h, DefaultDepth(xw.dpy, xw.scr));
xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
DefaultDepth(xw.dpy, xw.scr));
XftDrawChange(xw.draw, xw.buf);
xclear(0, 0, win.w, win.h);
@ -692,7 +695,7 @@ int xloadcolor(int i, const char *name, Color *ncolor) {
void xloadcols(void) {
int i;
static int loaded;
Color *cp;
Color * cp;
if (loaded) {
for (cp = dc.col; cp < &dc.col[dc.collen]; ++cp)
@ -950,12 +953,13 @@ int ximopen(Display *dpy) {
fprintf(stderr, "XSetIMValues: "
"Could not set XNDestroyCallback.\n");
xw.ime.spotlist = XVaCreateNestedList(0, XNSpotLocation, &xw.ime.spot, NULL);
xw.ime.spotlist =
XVaCreateNestedList(0, XNSpotLocation, &xw.ime.spot, NULL);
if (xw.ime.xic == NULL) {
xw.ime.xic = XCreateIC(xw.ime.xim, XNInputStyle,
XIMPreeditNothing | XIMStatusNothing, XNClientWindow,
xw.win, XNDestroyCallback, &icdestroy, NULL);
xw.ime.xic = XCreateIC(
xw.ime.xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
XNClientWindow, xw.win, XNDestroyCallback, &icdestroy, NULL);
}
if (xw.ime.xic == NULL)
fprintf(stderr, "XCreateIC: Could not create input context.\n");
@ -965,8 +969,8 @@ int ximopen(Display *dpy) {
void ximinstantiate(Display *dpy, XPointer client, XPointer call) {
if (ximopen(dpy))
XUnregisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL, ximinstantiate,
NULL);
XUnregisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL,
ximinstantiate, NULL);
}
void ximdestroy(XIM xim, XPointer client, XPointer call) {
@ -1033,8 +1037,8 @@ void xinit(int cols, int rows) {
memset(&gcvalues, 0, sizeof(gcvalues));
gcvalues.graphics_exposures = False;
dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures, &gcvalues);
xw.buf =
XCreatePixmap(xw.dpy, xw.win, win.w, win.h, DefaultDepth(xw.dpy, xw.scr));
xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
DefaultDepth(xw.dpy, xw.scr));
XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h);
@ -1046,8 +1050,8 @@ void xinit(int cols, int rows) {
/* input methods */
if (!ximopen(xw.dpy)) {
XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL, ximinstantiate,
NULL);
XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL,
ximinstantiate, NULL);
}
/* white cursor, black outline */
@ -1075,8 +1079,8 @@ void xinit(int cols, int rows) {
XSetWMProtocols(xw.dpy, xw.win, &xw.wmdeletewin, 1);
xw.netwmpid = XInternAtom(xw.dpy, "_NET_WM_PID", False);
XChangeProperty(xw.dpy, xw.win, xw.netwmpid, XA_CARDINAL, 32, PropModeReplace,
(uchar *)&thispid, 1);
XChangeProperty(xw.dpy, xw.win, xw.netwmpid, XA_CARDINAL, 32,
PropModeReplace, (uchar *)&thispid, 1);
win.mode = MODE_NUMLOCK;
resettitle();
@ -1097,7 +1101,7 @@ int xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len,
int x, int y) {
float winx = borderpx + x * win.cw, winy = borderpx + y * win.ch, xp, yp;
ushort mode, prevmode = USHRT_MAX;
Font *font = &dc.font;
Font * font = &dc.font;
int frcflags = FRC_NORMAL;
float runewidth = win.cw;
Rune rune;
@ -1155,7 +1159,8 @@ int xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len,
if (glyphidx && frc[f].flags == frcflags)
break;
/* We got a default font for a not found glyph. */
if (!glyphidx && frc[f].flags == frcflags && frc[f].unicodep == rune) {
if (!glyphidx && frc[f].flags == frcflags &&
frc[f].unicodep == rune) {
break;
}
}
@ -1223,7 +1228,7 @@ void xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len,
int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1);
int winx = borderpx + x * win.cw, winy = borderpx + y * win.ch,
width = charlen * win.cw;
Color *fg, *bg, *temp, revfg, revbg, truefg, truebg;
Color * fg, *bg, *temp, revfg, revbg, truefg, truebg;
XRenderColor colfg, colbg;
XRectangle r;
@ -1310,10 +1315,12 @@ void xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len,
/* Intelligent cleaning up of the borders. */
if (x == 0) {
xclear(0, (y == 0) ? 0 : winy, borderpx,
winy + win.ch + ((winy + win.ch >= borderpx + win.th) ? win.h : 0));
winy + win.ch +
((winy + win.ch >= borderpx + win.th) ? win.h : 0));
}
if (winx + width >= borderpx + win.tw) {
xclear(winx + width, (y == 0) ? 0 : winy, win.w,
xclear(
winx + width, (y == 0) ? 0 : winy, win.w,
((winy + win.ch >= borderpx + win.th) ? win.h : (winy + win.ch)));
}
if (y == 0)
@ -1340,7 +1347,8 @@ void xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len,
}
if (base.mode & ATTR_STRUCK) {
XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent / 3, width, 1);
XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent / 3, width,
1);
}
/* Reset clip to none. */
@ -1369,7 +1377,8 @@ void xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) {
/*
* Select the right color for the right mode.
*/
g.mode &= ATTR_BOLD | ATTR_ITALIC | ATTR_UNDERLINE | ATTR_STRUCK | ATTR_WIDE;
g.mode &=
ATTR_BOLD | ATTR_ITALIC | ATTR_UNDERLINE | ATTR_STRUCK | ATTR_WIDE;
if (IS_SET(MODE_REVERSE)) {
g.mode |= ATTR_REVERSE;
@ -1613,7 +1622,7 @@ void kpress(XEvent *ev) {
int len;
Rune c;
Status status;
Shortcut *bp;
Shortcut * bp;
if (IS_SET(MODE_KBDLOCK))
return;
@ -1754,7 +1763,8 @@ void run(void) {
trigger = now;
drawing = 1;
}
timeout = (maxlatency - TIMEDIFF(now, trigger)) / maxlatency * minlatency;
timeout = (maxlatency - TIMEDIFF(now, trigger)) / maxlatency *
minlatency;
if (timeout > 0)
continue; /* we have time, try to find idle */
}