summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrés M <andmarti1424@users.noreply.github.com>2017-02-12 15:24:02 -0300
committerGitHub <noreply@github.com>2017-02-12 15:24:02 -0300
commitf15c82c5b891eeb7373be904f4764de5b5bbde99 (patch)
tree90c88096ed5e34adc3369b4c49618ee2976bb6c5
parentee54b2ba021870ee9f3e4582fc45dbe943fe6e30 (diff)
parent99379d23f43c55bd0a49f77d79985d98aa64bd27 (diff)
Merge pull request #143 from melak/feature/file_command
Add :file command
-rw-r--r--src/cmds_command.c27
-rw-r--r--src/doc7
2 files changed, 34 insertions, 0 deletions
diff --git a/src/cmds_command.c b/src/cmds_command.c
index efbd537..88401e9 100644
--- a/src/cmds_command.c
+++ b/src/cmds_command.c
@@ -55,6 +55,7 @@ L"e! txt",
L"datefmt",
L"delfilter",
L"delfilters",
+L"file",
L"fill",
L"filteron",
L"filteroff",
@@ -613,6 +614,32 @@ void do_commandmode(struct block * sb) {
} else if ( inputline[0] == L'w' ) {
savefile();
+ } else if ( ! wcsncmp(inputline, L"file ", 5) ) {
+
+ char cline [BUFFERSIZE];
+ wordexp_t p;
+
+ wcstombs(cline, inputline, BUFFERSIZE);
+ del_range_chars(cline, 0, 4);
+ wordexp(cline, &p, 0);
+
+ if ( p.we_wordc < 1 ) {
+ sc_error("Failed to expand filename");
+ } else {
+ strncpy(curfile, p.we_wordv[0], PATHLEN - 1);
+ sc_info("File name set to \"%s\"", curfile);
+ }
+
+ wordfree(&p);
+
+ } else if ( ! wcscmp(inputline, L"file") ) {
+
+ if( ! *curfile ) {
+ sc_info("Current file has no name");
+ } else {
+ sc_info("Current file: \"%s\"", curfile);
+ }
+
} else if ( inputline[0] == L'x' ) {
if ( savefile() == 0 ) shall_quit = 1;
diff --git a/src/doc b/src/doc
index c369692..36d7784 100644
--- a/src/doc
+++ b/src/doc
@@ -422,6 +422,13 @@ Commands for handling cell content:
Remove the map sequence {lhs} that takes effect in
INSERT_MODE.
+ :file [{file}]
+ If {file} is given, expand {file}, and set the current file
+ name to the result of the expansion.
+
+ If {file} is not given, display the current file name on
+ the status line.
+
:fill {range} {initial_number} {increment_number}
Fill range {range} with values. The first cell of the range
will have {initial_number} and each successive cell