[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs Makefile clang.c perl.c qe.c qe.h qeconf...
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs Makefile clang.c perl.c qe.c qe.h qeconf... |
Date: |
Sat, 12 Jan 2008 09:57:41 +0000 |
CVSROOT: /cvsroot/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 08/01/12 09:57:41
Modified files:
. : Makefile clang.c perl.c qe.c qe.h qeconfig.h
Added files:
. : script.c
Log message:
added primitive Shell-script mode in module script.c
added extensions .idl .json .pcc for c-mode
match perl scripts on #!.*bin/perl.*
added DisplayState.space_width
added do_electric_filename on minibuf_mode / and ~
expand ~ syntax upon completing filename entry in minibuf
enable undo in minibuffer
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/Makefile?cvsroot=qemacs&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/qemacs/clang.c?cvsroot=qemacs&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/qemacs/perl.c?cvsroot=qemacs&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.66&r2=1.67
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.62&r2=1.63
http://cvs.savannah.gnu.org/viewcvs/qemacs/qeconfig.h?cvsroot=qemacs&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/qemacs/script.c?cvsroot=qemacs&rev=1.1
Patches:
Index: Makefile
===================================================================
RCS file: /cvsroot/qemacs/qemacs/Makefile,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- Makefile 10 Jan 2008 12:21:05 -0000 1.30
+++ Makefile 12 Jan 2008 09:57:40 -0000 1.31
@@ -117,7 +117,7 @@
ifdef CONFIG_ALL_MODES
OBJS+= unihex.o clang.o latex-mode.o xml.o bufed.o \
- makemode.o perl.o htmlsrc.o
+ makemode.o perl.o htmlsrc.o script.o
ifndef CONFIG_WIN32
OBJS+= shell.o dired.o
endif
Index: clang.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/clang.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- clang.c 9 Jan 2008 13:41:41 -0000 1.29
+++ clang.c 12 Jan 2008 09:57:41 -0000 1.30
@@ -45,7 +45,7 @@
"_Bool|_Complex|_Imaginary|";
static const char *c_mode_extensions =
- "c|h|y|e|cc|cs|cpp|cxx|hpp|hxx|jav|java|js|qe|";
+ "c|h|y|e|cc|cs|cpp|cxx|hpp|hxx|idl|jav|java|js|qe|json|pcc";
#if 0
static int get_c_identifier(char *buf, int buf_size, unsigned int *p)
Index: perl.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/perl.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- perl.c 8 Jan 2008 16:37:55 -0000 1.6
+++ perl.c 12 Jan 2008 09:57:41 -0000 1.7
@@ -337,7 +337,7 @@
return 80;
if (p->buf[0] == '#' && p->buf[1] == '!' &&
- memstr(p->buf, p->line_len, "/usr/bin/perl"))
+ memstr(p->buf, p->line_len, "bin/perl"))
return 80;
return 0;
Index: qe.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -b -r1.66 -r1.67
--- qe.c 11 Jan 2008 11:29:29 -0000 1.66
+++ qe.c 12 Jan 2008 09:57:41 -0000 1.67
@@ -2317,7 +2317,8 @@
glyph_width(e->screen, font, '\\'));
s->eol_width = max(s->eol_width, glyph_width(e->screen, font, '$'));
s->default_line_height = font->ascent + font->descent;
- s->tab_width = glyph_width(e->screen, font, ' ') * e->tab_size;
+ s->space_width = glyph_width(e->screen, font, ' ');
+ s->tab_width = s->space_width * e->tab_size;
s->width = e->width - s->eol_width;
s->height = e->height;
s->hex_mode = e->hex_mode;
@@ -2776,6 +2777,7 @@
s->x = 0;
if (s->edit_state->line_numbers) {
/* should skip line number column if present */
+ //s->x = s->space_width * 8;
}
if (len1 > 0) {
memmove(s->fragments, frag, sizeof(TextFragment));
@@ -2784,7 +2786,7 @@
frag->line_index = 0;
frag->len = len1;
s->nb_fragments = 1;
- s->x = w1;
+ s->x += w1;
}
keep_line_chars(s, len1);
}
@@ -2801,6 +2803,10 @@
(s->nb_fragments - s->word_index) * sizeof(TextFragment));
s->nb_fragments -= s->word_index;
s->x = 0;
+ if (s->edit_state->line_numbers) {
+ /* skip line number column if present */
+ //s->x = s->space_width * 8;
+ }
for (i = 0; i < s->nb_fragments; i++) {
s->fragments[i].line_index -= index;
s->x += s->fragments[i].width;
@@ -4477,11 +4483,18 @@
char path[MAX_FILENAME_SIZE];
char file[MAX_FILENAME_SIZE];
char filename[MAX_FILENAME_SIZE];
+ char *current;
FindFileState *ffst;
const char *base;
int len;
- splitpath(path, sizeof(path), file, sizeof(file), cp->current);
+ current = cp->current;
+ if (*current == '~') {
+ canonicalize_absolute_path(filename, sizeof(filename), cp->current);
+ current = filename;
+ }
+
+ splitpath(path, sizeof(path), file, sizeof(file), current);
pstrcat(file, sizeof(file), "*");
ffst = find_file_open(*path ? path : ".", file);
@@ -4679,6 +4692,18 @@
complete_end(&cs);
}
+void do_electric_filename(EditState *s, int key)
+{
+ int c, offset;
+
+ if (completion_function == file_completion) {
+ c = eb_prevc(s->b, s->offset, &offset);
+ if (c == '/')
+ eb_delete(s->b, 0, s->offset);
+ }
+ do_char(s, key, 1);
+}
+
/* space does completion only if a completion method is defined */
void do_completion_space(EditState *s)
{
@@ -4868,7 +4893,7 @@
minibuffer_cb = cb;
minibuffer_opaque = opaque;
- b = eb_new("*minibuf*", BF_SYSTEM);
+ b = eb_new("*minibuf*", BF_SYSTEM | BF_SAVELOG);
s = edit_new(b, 0, qs->screen->height - qs->status_height,
qs->screen->width, qs->status_height, 0);
Index: qe.h
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe.h,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -b -r1.62 -r1.63
--- qe.h 11 Jan 2008 11:29:29 -0000 1.62
+++ qe.h 12 Jan 2008 09:57:41 -0000 1.63
@@ -1294,6 +1294,7 @@
int height; /* display window height */
int eol_width; /* width of eol char */
int default_line_height; /* line height if no chars */
+ int space_width; /* width of space character */
int tab_width; /* width of tabulation */
int x_disp; /* starting x display */
int x; /* current x position */
@@ -1318,8 +1319,7 @@
TextFragment fragments[MAX_SCREEN_WIDTH];
int nb_fragments;
int last_word_space; /* true if last word was a space */
- int word_index; /* fragment index of the start of the current
- word */
+ int word_index; /* fragment index of the start of the current word */
/* line char (in fact glyph) buffer */
unsigned int line_chars[MAX_SCREEN_WIDTH];
short line_char_widths[MAX_SCREEN_WIDTH];
@@ -1632,6 +1632,7 @@
void edit_attach(EditState *s, EditState **ep);
void do_completion(EditState *s);
void do_completion_space(EditState *s);
+void do_electric_filename(EditState *s, int key);
void minibuf_complete_scroll_up_down(EditState *s, int dir);
void do_history(EditState *s, int dir);
void do_minibuffer_get_binary(EditState *s);
Index: qeconfig.h
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qeconfig.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- qeconfig.h 8 Jan 2008 16:37:55 -0000 1.29
+++ qeconfig.h 12 Jan 2008 09:57:41 -0000 1.30
@@ -385,6 +385,10 @@
"previous-history-element", do_history, -1)
CMD1( KEY_CTRL('n'), KEY_DOWN,
"next-history-element", do_history, 1)
+ CMDV( '/', KEY_NONE,
+ "electric-slash", do_electric_filename, ESi, '/', "*v")
+ CMDV( '~', KEY_NONE,
+ "electric-tilde", do_electric_filename, ESi, '~', "*v")
CMD_DEF_END,
};
Index: script.c
===================================================================
RCS file: script.c
diff -N script.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ script.c 12 Jan 2008 09:57:41 -0000 1.1
@@ -0,0 +1,153 @@
+/*
+ * Shell script mode for QEmacs.
+ *
+ * Copyright (c) 2000-2008 Charlie Gordon.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "qe.h"
+
+static const char *script_mode_extensions = "sh|bash|zsh";
+
+/*---------------- Perl colors ----------------*/
+
+enum {
+ SCRIPT_TEXT = QE_STYLE_DEFAULT,
+ SCRIPT_COMMENT = QE_STYLE_COMMENT,
+ SCRIPT_PREPROCESS = QE_STYLE_PREPROCESS,
+ SCRIPT_COMMAND = QE_STYLE_FUNCTION,
+ SCRIPT_VARIABLE = QE_STYLE_TYPE,
+ SCRIPT_STRING = QE_STYLE_STRING,
+ SCRIPT_BACKTICK = QE_STYLE_STRING_Q,
+};
+
+static int script_var(const unsigned int *str, int j, int n)
+{
+ for (; j < n; j++) {
+ if (qe_isalnum_(str[j]) || str[j] == '-')
+ continue;
+ break;
+ }
+ return j;
+}
+
+static void script_colorize_line(unsigned int *str, int n, int *statep,
+ __unused__ int state_only)
+{
+ int i = 0, j, style;
+
+ style = SCRIPT_COMMAND;
+
+ while (i < n) {
+ switch (str[i]) {
+ case '#':
+ if (i > 0 && str[i - 1] == '$')
+ break;
+ style = SCRIPT_COMMENT;
+ if (str[i + 1] == '!')
+ style = SCRIPT_PREPROCESS;
+ set_color(str + i, str + n, style);
+ i = n;
+ continue;
+ case '`':
+ style = SCRIPT_BACKTICK;
+ goto has_string;
+ case '\'':
+ case '"':
+ style = SCRIPT_STRING;
+ has_string:
+ /* parse string const */
+ for (j = i + 1; j < n; j++) {
+ if (str[j] == str[i]) {
+ j++;
+ break;
+ }
+ }
+ set_color(str + i, str + j, style);
+ i = j;
+ continue;
+ case ' ':
+ case '\t':
+ break;
+ default:
+ j = script_var(str, i, n);
+ if (j > i) {
+ while (qe_isblank(str[j]))
+ j++;
+ if (str[j] == '=')
+ style = SCRIPT_VARIABLE;
+ set_color(str + i, str + j, style);
+ style = SCRIPT_TEXT;
+ i = j;
+ continue;
+ }
+ // Should support << syntax
+ // Should support $ syntax
+ style = SCRIPT_TEXT;
+ break;
+ }
+ i++;
+ continue;
+ }
+}
+
+static int script_mode_probe(ModeProbeData *p)
+{
+ if (match_extension(p->filename, script_mode_extensions))
+ return 80;
+
+ if (p->buf[0] == '#') {
+ if (p->buf[1] == '!')
+ return 60;
+ if (p->buf[1] == ' ')
+ return 30;
+ }
+ return 0;
+}
+
+static int script_mode_init(EditState *s, ModeSavedData *saved_data)
+{
+ int ret;
+
+ ret = text_mode_init(s, saved_data);
+ if (ret)
+ return ret;
+ set_colorize_func(s, script_colorize_line);
+ return ret;
+}
+
+/* specific script commands */
+static CmdDef script_commands[] = {
+ CMD_DEF_END,
+};
+
+static ModeDef script_mode;
+
+static int script_init(void)
+{
+ /* c mode is almost like the text mode, so we copy and patch it */
+ memcpy(&script_mode, &text_mode, sizeof(ModeDef));
+ script_mode.name = "Shell-script";
+ script_mode.mode_probe = script_mode_probe;
+ script_mode.mode_init = script_mode_init;
+
+ qe_register_mode(&script_mode);
+ qe_register_cmd_table(script_commands, &script_mode);
+
+ return 0;
+}
+
+qe_module_init(script_init);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemacs-commit] qemacs Makefile clang.c perl.c qe.c qe.h qeconf...,
Charlie Gordon <=