summary refs log tree commit diff
path: root/ui.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui.c')
-rw-r--r--ui.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/ui.c b/ui.c
index c8f53ff..f44ff05 100644
--- a/ui.c
+++ b/ui.c
@@ -33,6 +33,8 @@
 #define A_ITALIC A_NORMAL
 #endif
 
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+
 static const int TOPIC_COLS = 512;
 static const int CHAT_LINES = 100;
 static const int INPUT_COLS = 512;
@@ -41,6 +43,7 @@ static struct {
 	WINDOW *topic;
 	WINDOW *chat;
 	WINDOW *input;
+	size_t cursor;
 } ui;
 
 void uiInit(void) {
@@ -70,7 +73,7 @@ void uiInit(void) {
 
 	ui.input = newpad(2, INPUT_COLS);
 	mvwhline(ui.input, 0, 0, ACS_HLINE, INPUT_COLS);
-	wmove(ui.input, 1, 0);
+	wmove(ui.input, 1, ui.cursor);
 	nodelay(ui.input, true);
 }
 
@@ -84,17 +87,20 @@ void uiHide(void) {
 }
 
 void uiDraw(void) {
-	pnoutrefresh(ui.topic, 0, 0, 0, 0, 1, COLS - 1);
+	int lastCol = COLS - 1;
+	int lastLine = LINES - 1;
+
+	pnoutrefresh(ui.topic, 0, 0, 0, 0, 1, lastCol);
 	pnoutrefresh(
 		ui.chat,
-		CHAT_LINES - (LINES - 4), 0,
-		2, 0, LINES - 1, COLS - 1
+		CHAT_LINES - (lastLine - 4), 0,
+		2, 0, lastLine, lastCol
 	);
 	pnoutrefresh(
 		ui.input,
-		0, 0,
-		LINES - 2, 0,
-		LINES - 1, COLS - 1
+		0, MAX(0, ui.cursor - lastCol),
+		lastLine - 1, 0,
+		lastLine, lastCol
 	);
 	doupdate();
 }
@@ -213,6 +219,7 @@ void uiRead(void) {
 				len = 0;
 			}
 			break; default: {
+				// TODO: Check overflow
 				if (iswprint(ch)) buf[len++] = ch;
 			}
 		}
@@ -220,4 +227,5 @@ void uiRead(void) {
 	wmove(ui.input, 1, 0);
 	waddnwstr(ui.input, buf, len);
 	wclrtoeol(ui.input);
+	ui.cursor = len;
 }
he git binaries if necessary + a dependency between cgit and libgit.a. Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2007-02-04Update cgitrc templateLars Hjemli Make the descriptions more helpfull. Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2007-02-04Add support for lightweight tagsLars Hjemli There is nothing bad about a tag that has no tag-object, but the old code didn't handle such tags correctly. Fix it. Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2007-02-04Read repo-info from /etc/cgitrcLars Hjemli This makes cgit read all repo-info from the configfile, instead of scanning for possible git-dirs below a common root path. This is primarily done to get better security (separate physical path from logical repo-name). In /etc/cgitrc each repo is registered with the following keys: repo.url repo.name repo.path repo.desc repo.owner Note: *Required keys are repo.url and repo.path, all others are optional *Each occurrence of repo.url starts a new repository registration *Default value for repo.name is taken from repo.url *The value of repo.url cannot contain characters with special meaning for urls (i.e. one of /?%&), while repo.name can contain anything. Example: repo.url=cgit-pub repo.name=cgit/public repo.path=/pub/git/cgit repo.desc=My public cgit repo repo.owner=Lars Hjemli repo.url=cgit-priv repo.name=cgit/private repo.path=/home/larsh/src/cgit/.git repo.desc=My private cgit repo repo.owner=Lars Hjemli Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2007-02-04Do not die if tag has no messageLars Hjemli Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2007-02-03Fix search for non-virtual urlsLars Hjemli When cgit don't use virtual urls, the current repo and page url parameters must be included in the search form as hidden input fields. Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2007-01-28Update README with install/config informationLars Hjemli