[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs TODO.org qe.h qe.c shell.c dired.c
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs TODO.org qe.h qe.c shell.c dired.c |
Date: |
Fri, 27 May 2016 18:20:30 +0000 (UTC) |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 16/05/27 18:20:30
Modified files:
. : TODO.org qe.h qe.c shell.c dired.c
Log message:
shell: improve current directory handling
- add get_default_path mode function
- move dired specific code to dired_get_default_path()
- add shell_get_default_path(), gets directory from prompt on current
line
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/TODO.org?cvsroot=qemacs&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.216&r2=1.217
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.222&r2=1.223
http://cvs.savannah.gnu.org/viewcvs/qemacs/shell.c?cvsroot=qemacs&r1=1.106&r2=1.107
http://cvs.savannah.gnu.org/viewcvs/qemacs/dired.c?cvsroot=qemacs&r1=1.64&r2=1.65
Patches:
Index: TODO.org
===================================================================
RCS file: /sources/qemacs/qemacs/TODO.org,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- TODO.org 7 Mar 2016 10:34:12 -0000 1.10
+++ TODO.org 27 May 2016 18:20:30 -0000 1.11
@@ -6,8 +6,8 @@
* Needed for release version 5
* Priority 0
-** shell: turn on interactive mode on M-> and some other commands that move
- the cursor to the end of file
+** shell: turn on interactive mode on commands that move the cursor
+ to the end of buffer
** basic: reset last command when executing macro
** extra: add function to add entry in TOTO.org
** clang: indentation bug on {\nputchar(expr ? 'a' : 'b');\n}
@@ -68,12 +68,10 @@
** search: make isearch bindings for minibuffer
** session: previous answers, ...
** session: register session store functions
-** shell: fix current directory for process buffer
** shell: handle long shell lines
** shell: integrate kill/paste including multiple lines
** shell: fix crash bug when invoking qemacs recursively in the terminal
** shell: set current directory of new shell buffer to that of current window
-** shell: set qemacs default directory to that of shell window upon cd command
** shell: yank at shell prompt
** syntax: fix overlong line coloring
** syntax: support ReStructuredText (RST)
@@ -503,4 +501,3 @@
MAC-CYRILLIC.TXT MAC-GREEK.TXT MAC-ICELAND.TXT MAC-TURKISH.TXT
cpdata.txt
koi8_ru.cp
-
Index: qe.h
===================================================================
RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.216
retrieving revision 1.217
diff -u -b -r1.216 -r1.217
--- qe.h 21 May 2016 16:13:41 -0000 1.216
+++ qe.h 27 May 2016 18:20:30 -0000 1.217
@@ -1309,6 +1309,7 @@
EditBufferDataType *data_type; /* native buffer data type (NULL = raw) */
void (*get_mode_line)(EditState *s, buf_t *out);
void (*indent_func)(EditState *s, int offset);
+ char *(*get_default_path)(EditState *s, char *buf, int buf_size);
/* mode specific key bindings */
struct KeyDef *first_key;
Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.222
retrieving revision 1.223
diff -u -b -r1.222 -r1.223
--- qe.c 21 May 2016 16:13:41 -0000 1.222
+++ qe.c 27 May 2016 18:20:30 -0000 1.223
@@ -53,7 +53,7 @@
void print_at_byte(QEditScreen *screen,
int x, int y, int width, int height,
const char *str, int style_index);
-static void get_default_path(EditState *s, char *buf, int buf_size);
+static char *get_default_path(EditState *s, char *buf, int buf_size);
static EditBuffer *predict_switch_to_buffer(EditState *s);
static StringArray *get_history(const char *name);
static void qe_key_process(int key);
@@ -6108,16 +6108,15 @@
}
/* compute default path for find/save buffer */
-static void get_default_path(EditState *s, char *buf, int buf_size)
+static char *get_default_path(EditState *s, char *buf, int buf_size)
{
EditBuffer *b = s->b;
char buf1[MAX_FILENAME_SIZE];
const char *filename;
- /* CG: should have more specific code for dired/shell buffer... */
- if (b->flags & BF_DIRED) {
- makepath(buf, buf_size, b->filename, "");
- return;
+ /* dispatch to mode specific handler if any */
+ if (s->mode->get_default_path) {
+ return s->mode->get_default_path(s, buf, buf_size);
}
if ((b->flags & BF_SYSTEM)
@@ -6129,6 +6128,7 @@
}
canonicalize_absolute_path(buf1, sizeof(buf1), filename);
splitpath(buf, buf_size, NULL, 0, buf1);
+ return buf;
}
/* should have: rawbuf[len] == '\0' */
Index: shell.c
===================================================================
RCS file: /sources/qemacs/qemacs/shell.c,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -b -r1.106 -r1.107
--- shell.c 21 May 2016 16:13:41 -0000 1.106
+++ shell.c 27 May 2016 18:20:30 -0000 1.107
@@ -1846,6 +1846,42 @@
#endif
}
+/* get current directory from prompt on current line */
+/* XXX: should extend behavior to handle more subtile cases */
+static char *shell_get_default_path(EditState *s, char *buf, int buf_size)
+{
+ char line[1024];
+ int offset = eb_goto_bol(s->b, s->offset);
+ int start, first_blank, last_blank, stop, i;
+
+ eb_get_strline(s->b, line, sizeof(line), &offset);
+
+ first_blank = last_blank = 0;
+ for (i = 0; line[i] != '\0'; i++) {
+ int c = line[i];
+ if (c == '$' || c == '>')
+ break;
+ if (c == ' ') {
+ if (!first_blank)
+ first_blank = i + 1;
+ last_blank = i;
+ }
+ }
+ stop = i;
+ if (last_blank == i - 1)
+ stop = last_blank;
+
+ start = 0;
+ if (first_blank < last_blank)
+ start = first_blank;
+
+ line[stop] = '\0';
+
+ canonicalize_absolute_path(buf, buf_size, line + start);
+ append_slash(buf, buf_size);
+ return buf;
+}
+
static void do_shell_command(EditState *e, const char *cmd)
{
EditBuffer *b;
@@ -2116,6 +2152,7 @@
shell_mode.move_bof = shell_move_bof;
shell_mode.move_eof = shell_move_eof;
shell_mode.write_char = shell_write_char;
+ shell_mode.get_default_path = shell_get_default_path;
qe_register_mode(&shell_mode, MODEF_NOCMD | MODEF_VIEW);
qe_register_cmd_table(shell_commands, &shell_mode);
Index: dired.c
===================================================================
RCS file: /sources/qemacs/qemacs/dired.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -b -r1.64 -r1.65
--- dired.c 16 Sep 2015 12:35:43 -0000 1.64
+++ dired.c 27 May 2016 18:20:30 -0000 1.65
@@ -1162,6 +1162,11 @@
}
}
+static char *dired_get_default_path(EditState *s, char *buf, int buf_size)
+{
+ return makepath(buf, buf_size, s->b->filename, "");
+}
+
static int dired_mode_init(EditState *s, EditBuffer *b, int flags)
{
DiredState *ds = qe_get_buffer_mode_data(b, &dired_mode, NULL);
@@ -1326,6 +1331,7 @@
dired_mode.mode_free = dired_mode_free;
/* CG: not a good idea, display hook has side effect on layout */
dired_mode.display_hook = dired_display_hook;
+ dired_mode.get_default_path = dired_get_default_path;
/* first register mode */
qe_register_mode(&dired_mode, /* MODEF_DATATYPE | */ MODEF_MAJOR |
MODEF_VIEW);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemacs-commit] qemacs TODO.org qe.h qe.c shell.c dired.c,
Charlie Gordon <=