Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add echo action #626

Merged
merged 1 commit into from
Jun 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/manual.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ Prompt
|:script <file> |Execute commands from `<file>`.
|:exec <flags><args...> |Execute command using `<args>` with external
user-defined command option flags defined in `<flags>`.
|:echo <args...> |Display text in the status bar.
|=============================================================================

[[external-commands]]
Expand Down
12 changes: 12 additions & 0 deletions src/prompt.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ readline_action_generator(const char *text, int state)
"save-display",
"save-options",
"exec",
"echo",
#define REQ_GROUP(help)
#define REQ_(req, help) #req
REQ_INFO,
Expand Down Expand Up @@ -844,6 +845,17 @@ run_prompt_command(struct view *view, const char *argv[])
goto_id(view, argv[1], true, true);
return REQ_NONE;

} else if (!strcmp(cmd, "echo")) {
char text[SIZEOF_STR] = "";

if (argv[1] && !argv_to_string(&argv[1], text, sizeof(text), " ")) {
report("Failed to copy echo string");
return REQ_NONE;
}

report("%s", text);
return REQ_NONE;

} else if (!strcmp(cmd, "save-display")) {
const char *path = argv[1] ? argv[1] : "tig-display.txt";

Expand Down