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 },
if (status == ERR) {
fprintf(stderr, "Error on line %d, near '%.*s': %s\n",
- config_lineno, optlen, opt, config_msg);
+ config_lineno, (int) optlen, opt, config_msg);
config_errors = TRUE;
}
VIEW_(LOG, "log", &pager_ops, ref_head),
VIEW_(TREE, "tree", &tree_ops, ref_commit),
VIEW_(BLOB, "blob", &blob_ops, ref_blob),
- VIEW_(HELP, "help", &help_ops, ""),
- VIEW_(PAGER, "pager", &pager_ops, ""),
+ VIEW_(HELP, "help", &help_ops, ""),
+ VIEW_(PAGER, "pager", &pager_ops, "stdin"),
VIEW_(STATUS, "status", &status_ops, ""),
};
if (minsize < view->width)
refsize = view->width - minsize + 7;
- string_format_from(buf, &bufpos, " %.*s", refsize, view->ref);
+ string_format_from(buf, &bufpos, " %.*s", (int) refsize, view->ref);
}
if (statelen && bufpos < view->width) {
* User request switch noodle
*/
+static void status_update(struct view *view);
+
static int
view_driver(struct view *view, enum request request)
{
break;
case REQ_VIEW_PAGER:
- if (!VIEW(REQ_VIEW_PAGER)->lines) {
+ if (!opt_pipe && !VIEW(REQ_VIEW_PAGER)->lines) {
report("No pager content, press %s to run command from prompt",
get_key(REQ_PROMPT));
break;
view->parent == VIEW(REQ_VIEW_MAIN)) ||
(view == VIEW(REQ_VIEW_BLOB) &&
view->parent == VIEW(REQ_VIEW_TREE))) {
+ int line;
+
view = view->parent;
+ line = view->lineno;
move_view(view, request);
if (view_is_displayed(view))
update_view_title(view);
+ if (line == view->lineno)
+ break;
} else {
move_view(view, request);
break;
redraw_display();
break;
+ case REQ_STATUS_UPDATE:
+ status_update(view);
+ break;
+
case REQ_NONE:
doupdate();
return TRUE;
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,
}
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)
{
char *text;