summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0340013)
raw | patch | inline | side by side (parent: 0340013)
author | Jonas Fonseca <fonseca@diku.dk> | |
Fri, 10 Aug 2007 12:12:32 +0000 (14:12 +0200) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Fri, 10 Aug 2007 12:50:22 +0000 (14:50 +0200) |
For now this obsoletes the action triggered when pressing Enter.
tig.c | patch | blob | history | |
tigrc.5.txt | patch | blob | history |
index 465de23a17b2310e8aaefb37ff0b2c15f47160bc..3d57311d635bccca6e1c09b1315ea128c3aef77d 100644 (file)
--- a/tig.c
+++ b/tig.c
REQ_(SHOW_VERSION, "Show version information"), \
REQ_(STOP_LOADING, "Stop all loading views"), \
REQ_(TOGGLE_LINENO, "Toggle line numbers"), \
- REQ_(TOGGLE_REV_GRAPH, "Toggle revision graph visualization")
+ REQ_(TOGGLE_REV_GRAPH, "Toggle revision graph visualization"), \
+ REQ_(STATUS_UPDATE, "Update file status") \
/* User action requests. */
{ '.', REQ_TOGGLE_LINENO },
{ 'g', REQ_TOGGLE_REV_GRAPH },
{ ':', REQ_PROMPT },
+ { 'u', REQ_STATUS_UPDATE },
/* Using the ncurses SIGWINCH handler. */
{ KEY_RESIZE, REQ_SCREEN_RESIZE },
* User request switch noodle
*/
+static void status_update(struct view *view);
+
static int
view_driver(struct view *view, enum request request)
{
redraw_display();
break;
+ case REQ_STATUS_UPDATE:
+ status_update(view);
+ break;
+
case REQ_NONE:
doupdate();
return TRUE;
@@ -3012,7 +3020,12 @@ status_draw(struct view *view, struct line *line, unsigned int lineno, bool sele
static bool
status_enter(struct view *view, struct line *line)
{
- struct status *status = line->data;
+ return TRUE;
+}
+
+static bool
+status_update_file(struct view *view, struct status *status, enum line_type type)
+{
char cmd[SIZEOF_STR];
char buf[SIZEOF_STR];
size_t cmdsize = 0;
size_t written = 0;
FILE *pipe;
- if (!status)
- return TRUE;
-
if (opt_cdup[0] &&
- line->type != LINE_STAT_UNTRACKED &&
+ type != LINE_STAT_UNTRACKED &&
!string_format_from(cmd, &cmdsize, "cd %s;", opt_cdup))
return FALSE;
- switch (line->type) {
+ switch (type) {
case LINE_STAT_STAGED:
if (!string_format_from(buf, &bufsize, "%06o %s\t%s%c",
status->old.mode,
return TRUE;
}
+static void
+status_update(struct view *view)
+{
+ if (view == VIEW(REQ_VIEW_STATUS)) {
+ struct line *line = view->lines
+ ? &view->line[view->lineno] : NULL;
+
+ if (!line || !line->data) {
+ report("No file chosen for update");
+ return;
+ }
+
+ if (!status_update_file(view, line->data, line->type))
+ report("Failed to update file status");
+ } else {
+ report("This action is only valid for the status view");
+ }
+}
+
static void
status_select(struct view *view, struct line *line)
{
diff --git a/tigrc.5.txt b/tigrc.5.txt
index 89459124764b5d2cc4f229b0235790aa0de37312..d9047b3b53e0c80b0c0317c8381bda1e3f23503c 100644 (file)
--- a/tigrc.5.txt
+++ b/tigrc.5.txt
stop-loading Stop all loading views
toggle-lineno Toggle line numbers
toggle-rev-graph Toggle revision graph visualization
+status-update Update file status
------------------------------------------------------------------------------