chiark
/
gitweb
/
~mdw
/
tig
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e3e7b9f
)
Misc cleanups
author
Jonas Fonseca
<fonseca@diku.dk>
Tue, 18 Apr 2006 21:12:21 +0000
(23:12 +0200)
committer
Jonas Fonseca
<fonseca@antimatter.localdomain>
Tue, 18 Apr 2006 21:12:21 +0000
(23:12 +0200)
cgit.c
patch
|
blob
|
blame
|
history
diff --git
a/cgit.c
b/cgit.c
index aa42f6f3ca86991ffd200fda401f804336b8080e..a05103ec8ed0dedd12fafec64063824c7c10db52 100644
(file)
--- a/
cgit.c
+++ b/
cgit.c
@@
-1,6
+1,11
@@
-/*
+/*
Cursed git browser
*
*
+ * Copyright (c) Jonas Fonseca, 2006
*
*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*/
#include <stdarg.h>
*/
#include <stdarg.h>
@@
-13,7
+18,8
@@
#include <curses.h>
#include <curses.h>
-#define CGIT_HELP "(q)uit, (s)hell, (j) down, (k) up"
+#define MSG_HELP "(q)uit, (s)hell, (j) down, (k) up"
+
#define KEY_ESC 27
#define KEY_TAB 9
#define KEY_ESC 27
#define KEY_TAB 9
@@
-21,11
+27,11
@@
WINDOW *mainwin;
WINDOW *statuswin;
WINDOW *mainwin;
WINDOW *statuswin;
-typedef void (*pipe_
filt
er_T)(char *, int);
+typedef void (*pipe_
read
er_T)(char *, int);
FILE *pipe;
long pipe_lineno;
FILE *pipe;
long pipe_lineno;
-pipe_
filter_T pipe_filt
er;
+pipe_
reader_T pipe_read
er;
static void
static void
@@
-106,7
+112,7
@@
init(void)
statuswin = newwin(1, 0, y - 1, 0);
wattrset(statuswin, COLOR_PAIR(COLOR_GREEN));
statuswin = newwin(1, 0, y - 1, 0);
wattrset(statuswin, COLOR_PAIR(COLOR_GREEN));
- put_status(
CGIT
_HELP);
+ put_status(
MSG
_HELP);
mainwin = newwin(y - 1, 0, 0, 0);
scrollok(mainwin, TRUE);
mainwin = newwin(y - 1, 0, 0, 0);
scrollok(mainwin, TRUE);
@@
-114,31
+120,34
@@
init(void)
}
/*
}
/*
- * Pipe
filt
ers
+ * Pipe
read
ers
*/
#define DIFF_CMD \
"git-rev-list HEAD^..HEAD | " \
*/
#define DIFF_CMD \
"git-rev-list HEAD^..HEAD | " \
- "git-diff-tree --stdin --pretty -r --cc --always"
+ "git-diff-tree --stdin --pretty -r --cc --always
--stat
"
-#define LOG_CMD
\
+#define LOG_CMD
0
\
"git-rev-list $(git-rev-parse --since=1.month) HEAD | " \
"git-diff-tree --stdin --pretty -r --root"
"git-rev-list $(git-rev-parse --since=1.month) HEAD | " \
"git-diff-tree --stdin --pretty -r --root"
+#define LOG_CMD \
+ "git-rev-list HEAD | git-diff-tree --stdin --pretty -r --root"
+
static void
static void
-log_
filt
er(char *line, int lineno)
+log_
read
er(char *line, int lineno)
{
{
- static int log_
filt
er_skip;
+ static int log_
read
er_skip;
if (!line) {
wattrset(mainwin, A_NORMAL);
if (!line) {
wattrset(mainwin, A_NORMAL);
- log_
filt
er_skip = 0;
+ log_
read
er_skip = 0;
return;
}
if (!strncmp("commit ", line, 7)) {
return;
}
if (!strncmp("commit ", line, 7)) {
-
attrset(
COLOR_PAIR(COLOR_GREEN));
+
wattrset(mainwin,
COLOR_PAIR(COLOR_GREEN));
} else if (!strncmp("Author: ", line, 8)) {
wattrset(mainwin, COLOR_PAIR(COLOR_CYAN));
} else if (!strncmp("Author: ", line, 8)) {
wattrset(mainwin, COLOR_PAIR(COLOR_CYAN));
@@
-166,12
+175,12
@@
log_filter(char *line, int lineno)
} else if (line[0] == ':') {
pipe_lineno--;
} else if (line[0] == ':') {
pipe_lineno--;
- log_
filt
er_skip = 1;
+ log_
read
er_skip = 1;
return;
return;
- } else if (log_
filt
er_skip) {
+ } else if (log_
read
er_skip) {
pipe_lineno--;
pipe_lineno--;
- log_
filt
er_skip = 0;
+ log_
read
er_skip = 0;
return;
} else {
return;
} else {
@@
-182,11
+191,11
@@
log_filter(char *line, int lineno)
}
static FILE *
}
static FILE *
-open_pipe(char *cmd, pipe_
filter_T filt
er)
+open_pipe(char *cmd, pipe_
reader_T read
er)
{
pipe = popen(cmd, "r");
pipe_lineno = 0;
{
pipe = popen(cmd, "r");
pipe_lineno = 0;
- pipe_
filter = filt
er;
+ pipe_
reader = read
er;
wclear(mainwin);
wmove(mainwin, 0, 0);
put_status("Loading...");
wclear(mainwin);
wmove(mainwin, 0, 0);
put_status("Loading...");
@@
-210,15
+219,15
@@
read_pipe(int lines)
if (linelen)
line[linelen - 1] = 0;
if (linelen)
line[linelen - 1] = 0;
- pipe_
filt
er(line, pipe_lineno++);
+ pipe_
read
er(line, pipe_lineno++);
}
if (feof(pipe) || ferror(pipe)) {
}
if (feof(pipe) || ferror(pipe)) {
- pipe_
filt
er(NULL, pipe_lineno - 1);
+ pipe_
read
er(NULL, pipe_lineno - 1);
pclose(pipe);
pipe = NULL;
pclose(pipe);
pipe = NULL;
- pipe_
filt
er = NULL;
- put_status("%s (lines %d)",
CGIT
_HELP, pipe_lineno - 1);
+ pipe_
read
er = NULL;
+ put_status("%s (lines %d)",
MSG
_HELP, pipe_lineno - 1);
}
}
}
}
@@
-231,7
+240,7
@@
main(int argc, char *argv[])
{
init();
{
init();
- //pipe = open_pipe(LOG_CMD, log_
filt
er);
+ //pipe = open_pipe(LOG_CMD, log_
read
er);
for (;;) {
int c;
for (;;) {
int c;
@@
-269,11
+278,11
@@
main(int argc, char *argv[])
break;
case 'd':
break;
case 'd':
- pipe = open_pipe(DIFF_CMD, log_
filt
er);
+ pipe = open_pipe(DIFF_CMD, log_
read
er);
break;
case 'l':
break;
case 'l':
- pipe = open_pipe(LOG_CMD, log_
filt
er);
+ pipe = open_pipe(LOG_CMD, log_
read
er);
break;
case 's':
break;
case 's':
@@
-283,7
+292,7
@@
main(int argc, char *argv[])
system("sh"); /* run shell */
werase(statuswin);
system("sh"); /* run shell */
werase(statuswin);
- mvwaddstr(statuswin, 0, 0,
CGIT
_HELP);
+ mvwaddstr(statuswin, 0, 0,
MSG
_HELP);
reset_prog_mode();
break;
}
reset_prog_mode();
break;
}