From 800a900c3eb2df114a30417537e7f3e9e47d5ad7 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Mon, 10 Apr 2006 18:39:01 +0200 Subject: [PATCH 1/1] Initial commit --- Makefile | 5 +++ cgit | Bin 0 -> 10702 bytes cgit.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 Makefile create mode 100755 cgit create mode 100644 cgit.c diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ca09fb2 --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +LDFLAGS = -lcurses + +all: cgit + +cgit: cgit.c diff --git a/cgit b/cgit new file mode 100755 index 0000000000000000000000000000000000000000..5913b2d4009fd7c5436db14fea49d621f45dca25 GIT binary patch literal 10702 zcmc&)du&wKnLqQenZ|~Ufe^Au%s}kKD0pmxVGU_hgE8QgfWs?Lnp}@(u6@TH&kXZ0 zpl%hYA&u*LLliZeROt%ZRkl^Tt85=>nzo7&5tM%_8ttapY^AaiiLMJ>5tU_WLNfdN zoyYjv0Vzo%_1NG2&hLERd7tymc|Fp(ah=cS6UO;PKoFgMEEsA9cW+UWRuK_1M1xo) z7Klm&QPz3@I-s-glPW+#PyjR+iOfA143XvllPF`_Bf(;ppW8E&9am2S4IN;rOG`E{8KudZqW%vF;C6tBzX_7@(Oxy^i3sqyzc=-pDZU3xw-ZGD z;{`kVHg7Hi$lM_t9%Epq)myhQlO^|)j-k*&n zL^_jBiFj|$j(rh+JMLtJ6U$pNa$dyZd22A16?a7rcP|u6}e$-@8WHVVCMNamoV=2@p zUf7?ttzIjYi3@ulE8n#l^-CnvRxxiUpuu!>jR#|>tz{=-g%||A`Me58P&y&jZ|qvr zVJ(d=EBji?zGmI}s-rNBq`mP8&Uob*rmWedk0E|oIQ}WiL5+ZT3y5}tZcZ`@lNA&@ zpu(^ki36fXFpL|?7Yfl$zDS7eBX1602)V~m1-Aj^cjGAJ=@X)~`~qrH zs=tUY+pAR1nmY7OoGroCv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%1yx<8pe@8IS62RQTRov|4|K8zpUNqfsv2mCyKkDxB=_ks3+ z+&I}D)9{yodH=wX!}d7<{4c=Y(D>`XYjEeIHYL^K2_1hBa*obtHD0OlcYw{A5#KQU zK+DY=h8Kx3A2@SsFh5?_^36K_NsWJ_@$1C8eR#({q2=a{!=He6>h`bkW4yy;@V;uD zj9)Fn+IYoudW$s9YrGWL`v#&-%lB$|m&VU(+^zAG8t>A$PUDAxxsCut`&0{C%kRP`o#Gd;9BQfgtc`&B`ufS%0vwdCy<{jMtOeN(nQy=P8Zf zKp6Y)9I+?;|JCvxTK+Duu_qCX?@FXA^Fuh_NX!B@_HQ=q-&|#)%Wo`h*Z4l2ULE7( zMo0Dk&Ejq?H*YNNp$3)!>jgv?HU68#PGIkwi-#EBQ~oTl_YKA)z^43Rl>h70 z*DeBnRO24_*&aXBxI^Pp)AU8GH`ypRMq9--Hss~wBEA13<3w1Q0Vu*O3{x{%CBU+?_I3EtmW)2zl4#`O4{4aTaaedlih@kV=lH| zJ`<4{$pBZ)N0z z8~sj2zrm63VJ71=n}<01)y^y bn*PkkQ;KW9eDb^$n#_IKv`0wO9!UK^`nOUi literal 0 HcmV?d00001 diff --git a/cgit.c b/cgit.c new file mode 100644 index 0000000..5bb8832 --- /dev/null +++ b/cgit.c @@ -0,0 +1,127 @@ +/* + * + * + */ + +#include +#include +#include +#include + +#include + +/* + * Init and quit + */ + +static void quit(int sig) +{ + endwin(); + + /* do your non-curses wrapup here */ + + exit(0); +} + +static void +init_colors(void) +{ + start_color(); + + init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); + init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK); + init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK); + init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK); + init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK); + init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK); + init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK); + init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK); +} + +static void +init(void) +{ + (void) signal(SIGINT, quit); /* arrange interrupts to terminate */ + + (void) initscr(); /* initialize the curses library */ + keypad(stdscr, TRUE); /* enable keyboard mapping */ + (void) nonl(); /* tell curses not to do NL->CR/NL on output */ + (void) cbreak(); /* take input chars one at a time, no wait for \n */ + (void) noecho(); /* don't echo input */ + + if (has_colors()) + init_colors(); +} + +/* + * Main + */ + +int +main(int argc, char *argv[]) +{ + int x, y; + + init(); + + getmaxyx(stdscr, y, x); + + attrset(COLOR_PAIR(COLOR_GREEN)); + + addch(ACS_VLINE); + printw("%s", "cg-view"); + addch(ACS_LTEE); + addch(ACS_HLINE); + addch(ACS_HLINE); + addch(ACS_HLINE); + addch(ACS_HLINE); + addch(ACS_HLINE); + addch(ACS_HLINE); + addch(ACS_HLINE); + mvprintw(y - 1, 0, "%s", "press 'q' to quit"); + + { + FILE *rev_list = popen("git-rev-list $(git-rev-parse --since=1.month) HEAD", "r"); + char buffer[BUFSIZ]; + char *line; + int lineno = 1; + + while ((line = fgets(buffer, sizeof(buffer), rev_list))) { + move(lineno, 0); + printw("%2d: ", lineno++); + addch(ACS_LTEE); + addch(ACS_HLINE); + addstr(line); + } + } + attrset(A_NORMAL); +/* scrollok();*/ + + for (;;) { + int c = getch(); /* refresh, accept single keystroke of input */ + + /* Process the command keystroke */ + switch (c) { + case 'q': + quit(0); + return 0; + + case 's': + addstr("Shelling out..."); + def_prog_mode(); /* save current tty modes */ + endwin(); /* restore original tty modes */ + system("sh"); /* run shell */ + addstr("returned.\n"); /* prepare return message */ + reset_prog_mode(); + //refresh(); /* restore save modes, repaint screen */ + break; + + default: + if (isprint(c) || isspace(c)) + addch(c); + } + + } + + quit(0); +} -- 2.30.2