Xinqi Bao's Git
projects
/
st.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
Style fixes in tscrollup.
[st.git]
/
st.c
diff --git
a/st.c
b/st.c
index
7ffe59a
..
60243a7
100644
(file)
--- a/
st.c
+++ b/
st.c
@@
-298,13
+298,13
@@
typedef struct {
typedef union {
int i;
typedef union {
int i;
- u
nsigned
int ui;
+ uint ui;
float f;
const void *v;
} Arg;
typedef struct {
float f;
const void *v;
} Arg;
typedef struct {
- u
nsigned
int mod;
+ uint mod;
KeySym keysym;
void (*func)(const Arg *);
const Arg arg;
KeySym keysym;
void (*func)(const Arg *);
const Arg arg;
@@
-360,7
+360,7
@@
static void strparse(void);
static void strreset(void);
static int tattrset(int);
static void strreset(void);
static int tattrset(int);
-static void tprinter(char *
s, size_t len
);
+static void tprinter(char *
, size_t
);
static void tdumpsel(void);
static void tdumpline(int);
static void tdump(void);
static void tdumpsel(void);
static void tdumpline(int);
static void tdump(void);
@@
-371,7
+371,7
@@
static void tdeleteline(int);
static void tinsertblank(int);
static void tinsertblankline(int);
static void tmoveto(int, int);
static void tinsertblank(int);
static void tinsertblankline(int);
static void tmoveto(int, int);
-static void tmoveato(int
x, int y
);
+static void tmoveato(int
, int
);
static void tnew(int, int);
static void tnewline(int);
static void tputtab(bool);
static void tnew(int, int);
static void tnewline(int);
static void tputtab(bool);
@@
-380,7
+380,7
@@
static void treset(void);
static int tresize(int, int);
static void tscrollup(int, int);
static void tscrolldown(int, int);
static int tresize(int, int);
static void tscrollup(int, int);
static void tscrolldown(int, int);
-static void tsetattr(int*, int);
+static void tsetattr(int
*, int);
static void tsetchar(char *, Glyph *, int, int);
static void tsetscroll(int, int);
static void tswapscreen(void);
static void tsetchar(char *, Glyph *, int, int);
static void tsetscroll(int, int);
static void tswapscreen(void);
@@
-413,9
+413,9
@@
static void xsettitle(char *);
static void xresettitle(void);
static void xsetpointermotion(int);
static void xseturgency(int);
static void xresettitle(void);
static void xsetpointermotion(int);
static void xseturgency(int);
-static void xsetsel(char*);
+static void xsetsel(char
*);
static void xtermclear(int, int, int, int);
static void xtermclear(int, int, int, int);
-static void xunloadfont(Font *
f
);
+static void xunloadfont(Font *);
static void xunloadfonts(void);
static void xresize(int, int);
static void xunloadfonts(void);
static void xresize(int, int);
@@
-453,7
+453,7
@@
static size_t utf8validate(long *, size_t);
static ssize_t xwrite(int, char *, size_t);
static void *xmalloc(size_t);
static void *xrealloc(void *, size_t);
static ssize_t xwrite(int, char *, size_t);
static void *xmalloc(size_t);
static void *xrealloc(void *, size_t);
-static char *xstrdup(char *
s
);
+static char *xstrdup(char *);
static void (*handler[LASTEvent])(XEvent *) = {
[KeyPress] = kpress,
static void (*handler[LASTEvent])(XEvent *) = {
[KeyPress] = kpress,
@@
-549,12
+549,10
@@
xrealloc(void *p, size_t len) {
char *
xstrdup(char *s) {
char *
xstrdup(char *s) {
- char *p = strdup(s);
-
- if (!p)
+ if((s = strdup(s)) == NULL)
die("Out of memory\n");
die("Out of memory\n");
- return
p
;
+ return
s
;
}
size_t
}
size_t
@@
-1400,15
+1398,13
@@
tscrolldown(int orig, int n) {
LIMIT(n, 0, term.bot-orig+1);
LIMIT(n, 0, term.bot-orig+1);
+ tsetdirt(orig, term.bot-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];
term.line[i-n] = temp;
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];
term.line[i-n] = temp;
-
- term.dirty[i] = 1;
- term.dirty[i-n] = 1;
}
selscroll(orig, n);
}
selscroll(orig, n);
@@
-1418,17
+1414,16
@@
void
tscrollup(int orig, int n) {
int i;
Line temp;
tscrollup(int orig, int n) {
int i;
Line temp;
+
LIMIT(n, 0, term.bot-orig+1);
tclearregion(0, orig, term.col-1, orig+n-1);
LIMIT(n, 0, term.bot-orig+1);
tclearregion(0, orig, term.col-1, orig+n-1);
+ tsetdirt(orig+n, term.bot);
for(i = orig; i <= term.bot-n; i++) {
for(i = orig; i <= term.bot-n; i++) {
- temp = term.line[i];
- term.line[i] = term.line[i+n];
- term.line[i+n] = temp;
-
- term.dirty[i] = 1;
- term.dirty[i+n] = 1;
+ temp = term.line[i];
+ term.line[i] = term.line[i+n];
+ term.line[i+n] = temp;
}
selscroll(orig, -n);
}
selscroll(orig, -n);
@@
-1544,8
+1539,7
@@
tsetchar(char *c, Glyph *attr, int x, int y) {
* The table is proudly stolen from rxvt.
*/
if(attr->mode & ATTR_GFX) {
* The table is proudly stolen from rxvt.
*/
if(attr->mode & ATTR_GFX) {
- if(c[0] >= 0x41 && c[0] <= 0x7e
- && vt100_0[c[0] - 0x41]) {
+ if(BETWEEN(c[0], 0x41, 0x7e) && vt100_0[c[0] - 0x41]) {
c = vt100_0[c[0] - 0x41];
}
}
c = vt100_0[c[0] - 0x41];
}
}
@@
-1628,18
+1622,14
@@
tinsertblank(int n) {
void
tinsertblankline(int n) {
void
tinsertblankline(int n) {
- if(term.c.y < term.top || term.c.y > term.bot)
- return;
-
- tscrolldown(term.c.y, n);
+ if(BETWEEN(term.c.y, term.top, term.bot))
+ tscrolldown(term.c.y, n);
}
void
tdeleteline(int n) {
}
void
tdeleteline(int n) {
- if(term.c.y < term.top || term.c.y > term.bot)
- return;
-
- tscrollup(term.c.y, n);
+ if(BETWEEN(term.c.y, term.top, term.bot))
+ tscrollup(term.c.y, n);
}
int32_t
}
int32_t
@@
-2260,8
+2250,7
@@
printsel(const Arg *arg) {
}
void
}
void
-tdumpsel(void)
-{
+tdumpsel(void) {
char *ptr;
if((ptr = getsel())) {
char *ptr;
if((ptr = getsel())) {
@@
-2316,9
+2305,9
@@
techo(char *buf, int len) {
for(; len > 0; buf++, len--) {
char c = *buf;
for(; len > 0; buf++, len--) {
char c = *buf;
- if(c <
'\x20'
) { /* control code */
+ if(c <
0x20 || c == 0177
) { /* control code */
if(c != '\n' && c != '\r' && c != '\t') {
if(c != '\n' && c != '\r' && c != '\t') {
- c
|
= '\x40';
+ c
^
= '\x40';
tputc("^", 1);
}
tputc(&c, 1);
tputc("^", 1);
}
tputc(&c, 1);
@@
-3081,7
+3070,7
@@
xinit(void) {
xw.netwmpid = XInternAtom(xw.dpy, "_NET_WM_PID", False);
XChangeProperty(xw.dpy, xw.win, xw.netwmpid, XA_CARDINAL, 32,
xw.netwmpid = XInternAtom(xw.dpy, "_NET_WM_PID", False);
XChangeProperty(xw.dpy, xw.win, xw.netwmpid, XA_CARDINAL, 32,
- PropModeReplace, (u
nsigned
char *)&thispid, 1);
+ PropModeReplace, (uchar *)&thispid, 1);
xresettitle();
XMapWindow(xw.dpy, xw.win);
xresettitle();
XMapWindow(xw.dpy, xw.win);
@@
-3815,7
+3804,7
@@
run(void) {
void
usage(void) {
void
usage(void) {
- die("%s " VERSION " (c) 2010-201
3
st engineers\n" \
+ die("%s " VERSION " (c) 2010-201
4
st engineers\n" \
"usage: st [-a] [-v] [-c class] [-f font] [-g geometry] [-o file]" \
" [-t title] [-w windowid] [-e command ...]\n", argv0);
}
"usage: st [-a] [-v] [-c class] [-f font] [-g geometry] [-o file]" \
" [-t title] [-w windowid] [-e command ...]\n", argv0);
}