You can subscribe to this list here.
| 2005 |
Jan
|
Feb
(3) |
Mar
(5) |
Apr
(2) |
May
(69) |
Jun
(81) |
Jul
|
Aug
(49) |
Sep
(46) |
Oct
|
Nov
(1) |
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(70) |
Feb
(99) |
Mar
(148) |
Apr
|
May
|
Jun
|
Jul
(81) |
Aug
|
Sep
(1) |
Oct
(1) |
Nov
(1) |
Dec
(6) |
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
(1) |
Jul
(156) |
Aug
(10) |
Sep
(1) |
Oct
(43) |
Nov
(35) |
Dec
|
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(7) |
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2009 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <rr...@us...> - 2009-01-10 22:50:47
|
Revision: 992
http://zee.svn.sourceforge.net/zee/?rev=992&view=rev
Author: rrt
Date: 2009-01-10 22:50:39 +0000 (Sat, 10 Jan 2009)
Log Message:
-----------
Remove DEF_ARG and replace with simple DEF, as DEF_ARG is redundant.
Modified Paths:
--------------
trunk/zee/src/basic.c
trunk/zee/src/funcs.c
trunk/zee/src/main.h
trunk/zee/src/search.c
Modified: trunk/zee/src/basic.c
===================================================================
--- trunk/zee/src/basic.c 2008-10-16 07:02:57 UTC (rev 991)
+++ trunk/zee/src/basic.c 2009-01-10 22:50:39 UTC (rev 992)
@@ -113,11 +113,11 @@
}
END_DEF
-DEF_ARG(edit_goto_column,
+DEF(edit_goto_column,
"\
Read a number N and move the cursor to column number N.\n\
-",
-UINT(to_col, "Goto column: "))
+")
+UINT(to_col, "Goto column: ")
{
if (ok) {
if (buf->pt.o > to_col)
@@ -166,12 +166,12 @@
return ok;
}
-DEF_ARG(edit_goto_line,
+DEF(edit_goto_line,
"\
Move the cursor to the beginning of the specified line.\n\
Line 1 is the beginning of the buffer.\
-",
-UINT(to_line, "Goto line: "))
+")
+UINT(to_line, "Goto line: ")
{
if (ok && to_line > 0) {
goto_line(to_line - 1);
Modified: trunk/zee/src/funcs.c
===================================================================
--- trunk/zee/src/funcs.c 2008-10-16 07:02:57 UTC (rev 991)
+++ trunk/zee/src/funcs.c 2009-01-10 22:50:39 UTC (rev 992)
@@ -157,7 +157,7 @@
/***********************************************************************
- Move through words
+ Move through words
***********************************************************************/
DEF(move_previous_word,
@@ -298,12 +298,12 @@
END_DEF
// FIXME: Better names for edit_repeat and execute_command.
-DEF_ARG(edit_repeat,
+DEF(edit_repeat,
"\
Repeat a command a given number of times.\
-",
+")
UINT(reps, "Repeat count: ")
-COMMAND(name, "Command: "))
+COMMAND(name, "Command: ")
{
if (ok) {
undo_save(UNDO_START_SEQUENCE, buf->pt, 0, 0);
Modified: trunk/zee/src/main.h
===================================================================
--- trunk/zee/src/main.h 2008-10-16 07:02:57 UTC (rev 991)
+++ trunk/zee/src/main.h 2009-01-10 22:50:39 UTC (rev 992)
@@ -155,7 +155,7 @@
// Named keys
enum {
#define X(key_sym, key_name, text_name, key_code) \
- key_sym = key_code,
+ key_sym = key_code,
#include "tbl_keys.h"
#undef X
KBD_NOKEY = INT_MAX
@@ -195,12 +195,6 @@
{ \
bool ok = true;
-/* Declare a command that takes arguments.
- `args' is a comma-separated list. */
-#define DEF_ARG(name, doc, args) \
- DEF(name, doc) \
- args
-
// End a command definition.
#define END_DEF \
lua_pushboolean(L, ok); \
Modified: trunk/zee/src/search.c
===================================================================
--- trunk/zee/src/search.c 2008-10-16 07:02:57 UTC (rev 991)
+++ trunk/zee/src/search.c 2009-01-10 22:50:39 UTC (rev 992)
@@ -62,7 +62,7 @@
options | PCRE_ANCHORED, ovector, 3);
}
}
-
+
if (index >= 0) {
if (!backward)
ret = ovector[1];
@@ -259,12 +259,12 @@
}
// FIXME: Make edit_replace run on selection.
-DEF_ARG(edit_replace,
+DEF(edit_replace,
"\
Replace the next occurrence of a regexp with other text.\n\
-",
+")
STR(find, "Replace string: ")
-STR(repl, rblist_to_string(rblist_fmt("Replace `%r' with: ", find))))
+STR(repl, rblist_to_string(rblist_fmt("Replace `%r' with: ", find)))
{
if (ok) {
bool find_no_upper = no_upper(find) && get_variable_bool("case_replace");
@@ -283,13 +283,13 @@
// FIXME: Translate this into Lua, adding Lua versions of argument
// declarations for interactive functions. Then can start rewriting
// Zee commands piecemeal in Lua.
-DEF_ARG(edit_replace_all,
+DEF(edit_replace_all,
"\
Replace all occurrences of a regexp with other text from the cursor\n\
to end of the buffer.\n\
-",
+")
STR(find, "Replace string: ")
-STR(repl, rblist_to_string(rblist_fmt("Replace `%r' with: ", find))))
+STR(repl, rblist_to_string(rblist_fmt("Replace `%r' with: ", find)))
{
if (ok) {
lua_pushstring(L, rblist_to_string(find));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2008-10-16 07:04:03
|
Revision: 991
http://zee.svn.sourceforge.net/zee/?rev=991&view=rev
Author: rrt
Date: 2008-10-16 07:02:57 +0000 (Thu, 16 Oct 2008)
Log Message:
-----------
Add autom4te.cache to bitlib's ignore list.
Simplify replace_nstring's code, and make checking that the buffer is
readonly and that size characters can be deleted the caller's
responsibility. It no longer returns a flag.
Simplify edit_kill_line.
Add a FIXME to nonstd.h: should be using gnulib for these macros.
Modified Paths:
--------------
trunk/zee/src/extern.h
trunk/zee/src/funcs.c
trunk/zee/src/killring.c
trunk/zee/src/line.c
trunk/zee/src/nonstd.h
Property Changed:
----------------
trunk/zee/bitlib/
Property changes on: trunk/zee/bitlib
___________________________________________________________________
Modified: svn:ignore
- config.log
config.status
libtool
.libs
.deps
Makefile
+ config.log
config.status
libtool
.libs
.deps
Makefile
autom4te.cache
Modified: trunk/zee/src/extern.h
===================================================================
--- trunk/zee/src/extern.h 2008-10-15 23:19:30 UTC (rev 990)
+++ trunk/zee/src/extern.h 2008-10-16 07:02:57 UTC (rev 991)
@@ -78,7 +78,7 @@
bool line_replace_text(size_t line, size_t offset, size_t oldlen, rblist newtext, bool replace_case);
bool insert_char(int c);
bool wrap_break_line(void);
-bool replace_nstring(size_t size, rblist *as, rblist bs);
+void replace_nstring(size_t size, rblist *as, rblist bs);
// lua.c ------------------------------------------------------------------
lua_obj get_variable(const char *key);
Modified: trunk/zee/src/funcs.c
===================================================================
--- trunk/zee/src/funcs.c 2008-10-15 23:19:30 UTC (rev 990)
+++ trunk/zee/src/funcs.c 2008-10-16 07:02:57 UTC (rev 991)
@@ -373,9 +373,13 @@
#endif
undo_save(UNDO_START_SEQUENCE, buf->pt, 0, 0);
- if (buf->pt.n != r.start.n || r.start.o != buf->pt.o)
+ if (buf->pt.n != r.start.n || r.start.o != buf->pt.o) {
CMDCALL(edit_select_other_end);
- ok = replace_nstring(r.size, NULL, out);
+ }
+ ok = warn_if_readonly_buffer();
+ if (ok) {
+ replace_nstring(r.size, NULL, out);
+ }
undo_save(UNDO_END_SEQUENCE, buf->pt, 0, 0);
buf->flags &= ~BFLAG_ANCHORED;
}
Modified: trunk/zee/src/killring.c
===================================================================
--- trunk/zee/src/killring.c 2008-10-15 23:19:30 UTC (rev 990)
+++ trunk/zee/src/killring.c 2008-10-16 07:02:57 UTC (rev 991)
@@ -44,9 +44,9 @@
if (!(lastflag & FLAG_DONE_KILL))
clear_kill_buffer();
- if (warn_if_readonly_buffer())
+ if (warn_if_readonly_buffer()) {
ok = false;
- else {
+ } else {
undo_save(UNDO_START_SEQUENCE, buf->pt, 0, 0);
if (!eolp()) {
@@ -54,7 +54,7 @@
killed_text = rblist_concat(killed_text,
rblist_sub(buf->lines, rblist_line_to_start_pos(buf->lines, buf->pt.n),
rblist_line_length(buf->lines, buf->pt.n)));
- ok = replace_nstring(rblist_line_length(buf->lines, buf->pt.n), &rbl, rblist_empty);
+ replace_nstring(rblist_line_length(buf->lines, buf->pt.n), &rbl, rblist_empty);
thisflag |= FLAG_DONE_KILL;
}
@@ -102,16 +102,14 @@
the text killed this time appends to the text killed last time.\
")
{
- if (copy_selection()) {
- if (buf->flags & BFLAG_READONLY)
- warn_if_readonly_buffer();
- else {
- Region r;
- assert(calculate_the_region(&r));
- if (buf->pt.n != r.start.n || r.start.o != buf->pt.o)
- CMDCALL(edit_select_other_end);
- ok = replace_nstring(r.size, NULL, rblist_empty);
- }
+ if (copy_selection() && !warn_if_readonly_buffer()) {
+ Region r;
+ assert(calculate_the_region(&r));
+ if (buf->pt.n != r.start.n || r.start.o != buf->pt.o)
+ CMDCALL(edit_select_other_end);
+ replace_nstring(r.size, NULL, rblist_empty);
+ } else {
+ ok = false;
}
}
END_DEF
@@ -183,10 +181,13 @@
if (rblist_length(killed_text) == 0) {
minibuf_error("Nothing to paste");
ok = false;
- } else if (!warn_if_readonly_buffer()) {
- CMDCALL(edit_select_on);
- ok = replace_nstring(0, NULL, killed_text);
- buf->flags &= ~BFLAG_ANCHORED;
+ } else {
+ ok = warn_if_readonly_buffer();
+ if (ok) {
+ CMDCALL(edit_select_on);
+ replace_nstring(0, NULL, killed_text);
+ buf->flags &= ~BFLAG_ANCHORED;
+ }
}
}
END_DEF
Modified: trunk/zee/src/line.c
===================================================================
--- trunk/zee/src/line.c 2008-10-15 23:19:30 UTC (rev 990)
+++ trunk/zee/src/line.c 2008-10-16 07:02:57 UTC (rev 991)
@@ -71,7 +71,7 @@
Marker *cur_pt = point_marker(), *m;
for (m = buf->markers; m != NULL; m = m->next)
- if (m->pt.n == buf->pt.n && (m->pt.o >= buf->pt.o + (offset < 0)))
+ if (m->pt.n == buf->pt.n && m->pt.o > buf->pt.o)
m->pt.o += offset;
buf->pt = cur_pt->pt;
@@ -187,7 +187,12 @@
*/
bool insert_char(int c)
{
- return replace_nstring(0, NULL, rblist_from_char(c));
+ if (!warn_if_readonly_buffer()) {
+ return false;
+ }
+
+ replace_nstring(0, NULL, rblist_from_char(c));
+ return true;
}
DEF(edit_insert_tab,
@@ -349,63 +354,36 @@
/*
* Replace `size' characters at point with the string `repl'.
* If `ret' is non-NULL, return the characters replaced in it.
- * Return true if the replacement is performed without incident, or
- * false if the buffer is read-only or if there are fewer than
- * `size' characters after point (in which case nothing is inserted).
*/
-// FIXME: check behaviour when there are not `size' characters to delete.
-// Is documentation correct? Is specification sensible?
-bool replace_nstring(size_t size, rblist *ret, rblist repl)
+void replace_nstring(size_t size, rblist *ret, rblist repl)
{
- rbacc rba = rbacc_new();
-
assert(repl);
- if (warn_if_readonly_buffer())
- return false;
-
- if (size || rblist_length(repl))
+ if (size || rblist_length(repl)) {
+ buf->flags |= BFLAG_MODIFIED;
undo_save(UNDO_REPLACE_BLOCK, buf->pt, size, rblist_length(repl));
+ }
+ // Remove string.
if (size) {
buf->flags &= ~BFLAG_ANCHORED;
- while (size--) {
- if (ret) {
- if (!eolp())
- rbacc_add_char(rba, following_char());
- else
- rbacc_add_char(rba, '\n');
- }
-
- if (eobp())
- break;
-
- buf->lines = rblist_concat(rblist_sub(buf->lines, 0, rblist_line_to_start_pos(buf->lines, buf->pt.n) + buf->pt.o),
- rblist_sub(buf->lines, rblist_line_to_start_pos(buf->lines, buf->pt.n) + buf->pt.o + 1,
- rblist_length(buf->lines)));
- adjust_markers(-1);
- buf->flags |= BFLAG_MODIFIED;
- }
-
if (ret)
- *ret = rbacc_to_rblist(rba);
+ *ret = rblist_sub(buf->lines, rblist_line_to_start_pos(buf->lines, buf->pt.n) + buf->pt.o,
+ rblist_line_to_end_pos(buf->lines, buf->pt.n));
- if (eobp()) {
- minibuf_error("End of buffer");
- return false;
- }
+ buf->lines = rblist_concat(rblist_sub(buf->lines, 0, rblist_line_to_start_pos(buf->lines, buf->pt.n) + buf->pt.o),
+ rblist_sub(buf->lines, rblist_line_to_start_pos(buf->lines, buf->pt.n) + buf->pt.o + size,
+ rblist_length(buf->lines)));
}
// Insert string.
- if (repl && rblist_length(repl)) {
+ if (rblist_length(repl)) {
buf->lines = rblist_concat(rblist_concat(rblist_sub(buf->lines, 0, rblist_line_to_start_pos(buf->lines, buf->pt.n) + buf->pt.o), repl),
rblist_sub(buf->lines, rblist_line_to_start_pos(buf->lines, buf->pt.n) + buf->pt.o, rblist_length(buf->lines)));
- buf->flags |= BFLAG_MODIFIED;
- adjust_markers((ssize_t)rblist_length(repl));
}
- return true;
+ adjust_markers((ssize_t)rblist_length(repl) - (ssize_t)size);
}
DEF(edit_insert_character,
@@ -441,7 +419,14 @@
Join lines if the character is a newline.\
")
{
- ok = replace_nstring(1, NULL, rblist_empty);
+ if (eobp()) {
+ minibuf_error("End of buffer");
+ ok = false;
+ } else if (warn_if_readonly_buffer()) {
+ ok = false;
+ } else {
+ replace_nstring(1, NULL, rblist_empty);
+ }
}
END_DEF
Modified: trunk/zee/src/nonstd.h
===================================================================
--- trunk/zee/src/nonstd.h 2008-10-15 23:19:30 UTC (rev 990)
+++ trunk/zee/src/nonstd.h 2008-10-16 07:02:57 UTC (rev 991)
@@ -18,6 +18,8 @@
Software Foundation, Fifth Floor, 51 Franklin Street, Boston, MA
02111-1301, USA. */
+/* FIXME: Use gnulib's minmax module */
+
#ifndef NONSTD_H
#undef min
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2008-10-15 23:19:37
|
Revision: 990
http://zee.svn.sourceforge.net/zee/?rev=990&view=rev
Author: rrt
Date: 2008-10-15 23:19:30 +0000 (Wed, 15 Oct 2008)
Log Message:
-----------
Simplify adjust_markers
Modified Paths:
--------------
trunk/zee/src/line.c
Modified: trunk/zee/src/line.c
===================================================================
--- trunk/zee/src/line.c 2008-08-28 13:39:48 UTC (rev 989)
+++ trunk/zee/src/line.c 2008-10-15 23:19:30 UTC (rev 990)
@@ -66,16 +66,16 @@
return marker_new(buf->pt);
}
-static void adjust_markers(size_t line, size_t pointo, ssize_t offset)
+static void adjust_markers(ssize_t offset)
{
- Marker *m = point_marker(), *marker;
+ Marker *cur_pt = point_marker(), *m;
- for (marker = buf->markers; marker; marker = marker->next)
- if (marker->pt.n == line && (marker->pt.o >= pointo + (offset < 0)))
- marker->pt.o += offset;
+ for (m = buf->markers; m != NULL; m = m->next)
+ if (m->pt.n == buf->pt.n && (m->pt.o >= buf->pt.o + (offset < 0)))
+ m->pt.o += offset;
- buf->pt = m->pt;
- remove_marker(m);
+ buf->pt = cur_pt->pt;
+ remove_marker(cur_pt);
}
/*
@@ -384,7 +384,7 @@
buf->lines = rblist_concat(rblist_sub(buf->lines, 0, rblist_line_to_start_pos(buf->lines, buf->pt.n) + buf->pt.o),
rblist_sub(buf->lines, rblist_line_to_start_pos(buf->lines, buf->pt.n) + buf->pt.o + 1,
rblist_length(buf->lines)));
- adjust_markers(buf->pt.n, buf->pt.o, -1);
+ adjust_markers(-1);
buf->flags |= BFLAG_MODIFIED;
}
@@ -402,7 +402,7 @@
buf->lines = rblist_concat(rblist_concat(rblist_sub(buf->lines, 0, rblist_line_to_start_pos(buf->lines, buf->pt.n) + buf->pt.o), repl),
rblist_sub(buf->lines, rblist_line_to_start_pos(buf->lines, buf->pt.n) + buf->pt.o, rblist_length(buf->lines)));
buf->flags |= BFLAG_MODIFIED;
- adjust_markers(buf->pt.n, buf->pt.o, (ssize_t)rblist_length(repl));
+ adjust_markers((ssize_t)rblist_length(repl));
}
return true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2008-08-28 13:39:39
|
Revision: 989
http://zee.svn.sourceforge.net/zee/?rev=989&view=rev
Author: rrt
Date: 2008-08-28 13:39:48 +0000 (Thu, 28 Aug 2008)
Log Message:
-----------
tbl_keys.h is now a Lua file, not a C file.
tbl_funcs.lua is generated, so should be in LUA_RUNTIME_EXTRA, not
LUA_RUNTIME (it shouldn't be counted by make loc).
Modified Paths:
--------------
trunk/zee/src/Makefile.am
Modified: trunk/zee/src/Makefile.am
===================================================================
--- trunk/zee/src/Makefile.am 2008-08-02 16:22:11 UTC (rev 988)
+++ trunk/zee/src/Makefile.am 2008-08-28 13:39:48 UTC (rev 989)
@@ -16,7 +16,6 @@
LUA_RUNTIME = \
lib.lua \
tbl_vars.lua \
- tbl_funcs.lua \
tbl_keys.h \
bind.lua \
completion.lua \
@@ -25,7 +24,9 @@
minibuf.lua \
texinfo.lua
-LUA_RUNTIME_EXTRA = std.lua
+LUA_RUNTIME_EXTRA = \
+ std.lua \
+ tbl_funcs.lua
dist_pkgdata_DATA = \
$(LUA_RUNTIME) \
@@ -39,7 +40,7 @@
zee_base_SOURCES = \
rblist.c \
rblist.h \
- rbacc.c \
+ rbacc.c \
rbacc.h \
rbutil.c \
rbutil.h \
@@ -50,7 +51,6 @@
extern.h \
main.h \
tbl_opts.h \
- tbl_keys.h \
copyright.h \
basic.c \
bind.c \
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2008-08-02 16:22:05
|
Revision: 988
http://zee.svn.sourceforge.net/zee/?rev=988&view=rev
Author: rrt
Date: 2008-08-02 16:22:11 +0000 (Sat, 02 Aug 2008)
Log Message:
-----------
Implement key binding and minibuffer manipulation in Lua.
Modified Paths:
--------------
trunk/zee/src/Makefile.am
trunk/zee/src/basic.c
trunk/zee/src/bind.c
trunk/zee/src/bind.lua
trunk/zee/src/buffer.c
trunk/zee/src/extern.h
trunk/zee/src/file.c
trunk/zee/src/funcs.c
trunk/zee/src/help.c
trunk/zee/src/killring.c
trunk/zee/src/line.c
trunk/zee/src/lua.c
trunk/zee/src/macro.c
trunk/zee/src/main.c
trunk/zee/src/minibuf.c
trunk/zee/src/search.c
trunk/zee/src/tbl_vars.lua
trunk/zee/src/undo.c
Modified: trunk/zee/src/Makefile.am
===================================================================
--- trunk/zee/src/Makefile.am 2008-08-02 16:17:11 UTC (rev 987)
+++ trunk/zee/src/Makefile.am 2008-08-02 16:22:11 UTC (rev 988)
@@ -22,6 +22,7 @@
completion.lua \
history.lua \
keys.lua \
+ minibuf.lua \
texinfo.lua
LUA_RUNTIME_EXTRA = std.lua
@@ -97,19 +98,19 @@
$(PACKAGE).info $(PACKAGE).dvi: $(BUILT_TEXI)
tbl_funcs.h tbl_funcs.lua funcs.texi: $(zee_base_SOURCES) mkfuncs.lua
- LUA_INIT= LUA_PATH="$(srcdir)/?.lua" $(LUA) -e 'PACKAGE="$(PACKAGE)"' $(srcdir)/mkfuncs.lua $(srcdir) $(zee_base_SOURCES)
+ LUA_INIT= LUA_PATH="$(srcdir)/?.lua" $(LUA) -e 'PACKAGE="$(PACKAGE)"' -e 'PACKAGE_NAME="$(PACKAGE_NAME)"' $(srcdir)/mkfuncs.lua $(srcdir) $(zee_base_SOURCES)
$(PACKAGE)rc vars.texi: tbl_vars.lua mkvars.lua
- LUA_INIT= LUA_PATH="$(srcdir)/?.lua" $(LUA) -e 'PACKAGE="$(PACKAGE)"' $(srcdir)/mkvars.lua $(srcdir)/tbl_vars.lua
+ LUA_INIT= LUA_PATH="$(srcdir)/?.lua" $(LUA) -e 'PACKAGE="$(PACKAGE)"' -e 'PACKAGE_NAME="$(PACKAGE_NAME)"' $(srcdir)/mkvars.lua $(srcdir)/tbl_vars.lua
opts.texi: tbl_opts.h mkopts.lua
- LUA_INIT= LUA_PATH="$(srcdir)/?.lua" $(LUA) -e 'PACKAGE="$(PACKAGE)"' $(srcdir)/mkopts.lua $(srcdir)/tbl_opts.h
+ LUA_INIT= LUA_PATH="$(srcdir)/?.lua" $(LUA) -e 'PACKAGE="$(PACKAGE)"' -e 'PACKAGE_NAME="$(PACKAGE_NAME)"' $(srcdir)/mkopts.lua $(srcdir)/tbl_opts.h
keys.texi: tbl_keys.h mkkeys.lua
- LUA_INIT= LUA_PATH="$(srcdir)/?.lua" $(LUA) -e 'PACKAGE="$(PACKAGE)"' $(srcdir)/mkkeys.lua $(srcdir)/tbl_keys.h
+ LUA_INIT= LUA_PATH="$(srcdir)/?.lua" $(LUA) -e 'PACKAGE="$(PACKAGE)"' -e 'PACKAGE_NAME="$(PACKAGE_NAME)"' $(srcdir)/mkkeys.lua $(srcdir)/tbl_keys.h
copyright.texi: copyright.h mkcopyright.lua
- LUA_INIT= LUA_PATH="$(srcdir)/?.lua" $(LUA) -e 'PACKAGE="$(PACKAGE)"' $(srcdir)/mkcopyright.lua $(srcdir)/copyright.h
+ LUA_INIT= LUA_PATH="$(srcdir)/?.lua" $(LUA) -e 'PACKAGE="$(PACKAGE)"' -e 'PACKAGE_NAME="$(PACKAGE_NAME)"' $(srcdir)/mkcopyright.lua $(srcdir)/copyright.h
loc:
cloc --no3 --force_lang=m4,ac --force_lang=Make,am $(zee_base_SOURCES) term_*.c Makefile.am ../Makefile.am ../configure.ac \
Modified: trunk/zee/src/basic.c
===================================================================
--- trunk/zee/src/basic.c 2008-08-02 16:17:11 UTC (rev 987)
+++ trunk/zee/src/basic.c 2008-08-02 16:22:11 UTC (rev 988)
@@ -238,7 +238,7 @@
if (buf->pt.n > 0)
ok = goto_line(buf->pt.n > win.eheight ? buf->pt.n - win.eheight : 0) ? true : false;
else {
- minibuf_error(rblist_from_string("Beginning of buffer"));
+ minibuf_error("Beginning of buffer");
ok = false;
}
}
@@ -252,7 +252,7 @@
if (buf->pt.n < rblist_nl_count(buf->lines))
ok = goto_line(buf->pt.n + win.eheight) ? true : false;
else {
- minibuf_error(rblist_from_string("End of buffer"));
+ minibuf_error("End of buffer");
ok = false;
}
}
Modified: trunk/zee/src/bind.c
===================================================================
--- trunk/zee/src/bind.c 2008-08-02 16:17:11 UTC (rev 987)
+++ trunk/zee/src/bind.c 2008-08-02 16:22:11 UTC (rev 988)
@@ -65,64 +65,3 @@
add_cmd_to_macro();
}
}
-
-DEF(key_bind,
-"\
-Bind a command to a key chord.\n\
-Read key chord and command name, and bind the command to the key\n\
-chord.\
-")
-{
- size_t key = KBD_NOKEY;
- rblist name = NULL;
-
- if (lua_gettop(L) > 1) {
- (void)CLUE_DO(L, rblist_to_string(rblist_fmt("_key = strtochord(\"%s\")", lua_tostring(L, -2))));
- CLUE_GET(L, _key, number, key);
- name = rblist_from_string(lua_tostring(L, -1));
- lua_pop(L, 2);
- } else {
- minibuf_write(rblist_from_string("Bind key: "));
- key = getkey();
- (void)CLUE_DO(L, rblist_to_string(rblist_fmt("_key = chordtostr(%d)", key)));
- const char *key_name;
- CLUE_GET(L, _key, string, key_name);
- name = minibuf_read_name(rblist_fmt("Bind key %s to command: ", key_name));
- }
-
- if (name) {
- if (key != KBD_NOKEY) {
- (void)CLUE_DO(L, rblist_to_string(rblist_fmt("bind_key(%d, \"%r\")", key, name)));
- } else {
- minibuf_error(rblist_from_string("Invalid key"));
- ok = false;
- }
- }
-}
-END_DEF
-
-DEF(key_unbind,
-"\
-Unbind a key.\n\
-Read key chord, and unbind it.\
-")
-{
- size_t key = KBD_NOKEY;
-
- if (lua_gettop(L) > 0) {
- (void)CLUE_DO(L, rblist_to_string(rblist_fmt("_key = strtochord(\"%s\")", lua_tostring(L, -1))));
- CLUE_GET(L, _key, number, key);
- lua_pop(L, 1);
- } else {
- minibuf_write(rblist_from_string("Unbind key: "));
- key = getkey();
- }
-
- if (key != KBD_NOKEY) {
- (void)CLUE_DO(L, rblist_to_string(rblist_fmt("bind_key(%d, nil)", key)));
- } else {
- minibuf_error(rblist_from_string("Invalid key"));
- ok = false;
- }
-}
-END_DEF
Modified: trunk/zee/src/bind.lua
===================================================================
--- trunk/zee/src/bind.lua 2008-08-02 16:17:11 UTC (rev 987)
+++ trunk/zee/src/bind.lua 2008-08-02 16:22:11 UTC (rev 988)
@@ -37,3 +37,54 @@
function binding_to_command(key)
return _bindings[key]
end
+
+def{key_bind =
+ function (key, name)
+ local code
+ if key then
+ code = strtochord(key)
+ else
+ minibuf_write("Bind key: ")
+ local key_name = chordtostr(getkey())
+ name = minibuf_read_name(string.format("Bind key %s to command: ", key_name))
+ end
+
+ if name and name ~= "" then
+ if code ~= 0 then
+ bind_key(code, name)
+ else
+ minibuf_error("Invalid key")
+ -- FIXME: Use ok as in C
+ return false
+ end
+ end
+ -- FIXME: Use ok as in C
+ return true
+ end,
+ "Bind a command to a key chord.\nRead key chord and command name, and bind the command to the key\nchord."
+}
+
+def{key_unbind =
+ function (key)
+ local code
+ if key then
+ code = strtochord(key)
+ else
+ minibuf_write("Unbind key: ")
+ code = getkey()
+ end
+
+ if code ~= 0 then
+ bind_key(code, nil)
+ else
+ minibuf_error("Invalid key")
+ -- FIXME: Use ok as in C
+ return false
+ end
+
+ minibuf_clear()
+ -- FIXME: Use ok as in C
+ return true
+ end,
+ "Unbind a key.\nRead key chord, and unbind it."
+}
Modified: trunk/zee/src/buffer.c
===================================================================
--- trunk/zee/src/buffer.c 2008-08-02 16:17:11 UTC (rev 987)
+++ trunk/zee/src/buffer.c 2008-08-02 16:22:11 UTC (rev 988)
@@ -47,7 +47,7 @@
bool warn_if_readonly_buffer(void)
{
if (buf->flags & BFLAG_READONLY) {
- minibuf_error(rblist_from_string("Buffer is readonly"));
+ minibuf_error("Buffer is readonly");
return true;
} else {
return false;
@@ -62,7 +62,7 @@
{
assert(buf->mark);
if (!(buf->flags & BFLAG_ANCHORED)) {
- minibuf_error(rblist_from_string("The mark is not active now"));
+ minibuf_error("The mark is not active now");
return true;
} else {
return false;
Modified: trunk/zee/src/extern.h
===================================================================
--- trunk/zee/src/extern.h 2008-08-02 16:17:11 UTC (rev 987)
+++ trunk/zee/src/extern.h 2008-08-02 16:22:11 UTC (rev 988)
@@ -101,8 +101,8 @@
extern int thisflag, lastflag;
// minibuf.c --------------------------------------------------------------
-void minibuf_write(rblist rbl);
-void minibuf_error(rblist rbl);
+int minibuf_write(const char *s);
+int minibuf_error(const char *s);
rblist minibuf_read(rblist rbl, rblist value);
void minibuf_clear(void);
rblist minibuf_read_name(rblist rbl);
Modified: trunk/zee/src/file.c
===================================================================
--- trunk/zee/src/file.c 2008-08-02 16:17:11 UTC (rev 987)
+++ trunk/zee/src/file.c 2008-08-02 16:22:11 UTC (rev 988)
@@ -115,9 +115,9 @@
")
{
if (buffer_write(buf, buf->filename) == false) {
- minibuf_error(rblist_fmt("%s: %s", buf->filename, strerror(errno)));
+ minibuf_error(rblist_to_string(rblist_fmt("%s: %s", buf->filename, strerror(errno))));
} else {
- minibuf_write(rblist_fmt("Wrote `%r'", buf->filename));
+ minibuf_write(rblist_to_string(rblist_fmt("Wrote `%r'", buf->filename)));
buf->flags &= ~BFLAG_MODIFIED;
if (buf->last_undop)
@@ -132,7 +132,7 @@
")
{
if (buf->flags & BFLAG_MODIFIED) {
- minibuf_error(rblist_from_string("Unsaved changes; use `file_save' or `edit_revert'"));
+ minibuf_error("Unsaved changes; use `file_save' or `edit_revert'");
ok = false;
}
@@ -145,6 +145,7 @@
* Function called on unexpected error or crash (SIGSEGV).
* Attempts to save buffer if modified.
*/
+// FIXME: Reset the terminal?
void die(int exitcode)
{
static bool already_dying = 0;
Modified: trunk/zee/src/funcs.c
===================================================================
--- trunk/zee/src/funcs.c 2008-08-02 16:17:11 UTC (rev 987)
+++ trunk/zee/src/funcs.c 2008-08-02 16:22:11 UTC (rev 988)
@@ -71,7 +71,7 @@
")
{
set_mark_to_point();
- minibuf_write(rblist_from_string("Mark set"));
+ minibuf_write("Mark set");
buf->flags |= BFLAG_ANCHORED;
}
END_DEF
@@ -82,7 +82,7 @@
")
{
buf->flags &= ~BFLAG_ANCHORED;
- minibuf_write(rblist_empty);
+ minibuf_write("");
ok = false;
}
END_DEF
@@ -111,45 +111,33 @@
}
END_DEF
-static void quoted_insert_octal(int c1)
-{
- int c2, c3;
- minibuf_write(rblist_fmt("Insert octal character %d-", c1 - '0'));
- c2 = getkey();
+#define HEX_TO_DECIMAL(x) \
+ (((x) > '0' && (x) < '9') ? (x) - '0' : x + 10 - 'A')
- if (!isdigit(c2) || c2 - '0' >= 8) {
- insert_char(c1 - '0');
- insert_char(c2);
- } else {
- minibuf_write(rblist_fmt("Insert octal character %d %d-", c1 - '0', c2 - '0'));
- c3 = getkey();
-
- if (!isdigit(c3) || c3 - '0' >= 8) {
- insert_char((c1 - '0') * 8 + (c2 - '0'));
- insert_char(c3);
- } else
- insert_char((c1 - '8') * 64 + (c2 - '0') * 8 + (c3 - '0'));
- }
-}
-
DEF(edit_insert_quoted,
"\
Read next input character and insert it.\n\
This is useful for inserting control characters.\n\
-You may also type up to 3 octal digits, to insert a character with that code.\
+You may also type 2 hex digits, to insert a character with that code.\
")
{
- int c;
+ minibuf_write("Insert literal character: ");
+ size_t key = xgetkey(GETKEY_UNFILTERED, 0);
+ int c1 = key & 0xff;
- minibuf_write(rblist_from_string("Insert literal character: "));
- c = xgetkey(GETKEY_UNFILTERED, 0);
-
- if (isdigit(c) && c - '0' < 8)
- quoted_insert_octal(c);
- else
- insert_char(c);
-
- minibuf_clear();
+ if (key == (key & 0xff) && isxdigit(c1)) {
+ minibuf_write(rblist_to_string(rblist_fmt("Insert hex character %d-", HEX_TO_DECIMAL(c1))));
+ key = getkey();
+ int c2 = key & 0xff;
+ if (key == (key & 0xff) && isxdigit(c2)) {
+ minibuf_clear();
+ insert_char(HEX_TO_DECIMAL(c1) * 16 + (HEX_TO_DECIMAL(c2)));
+ } else {
+ minibuf_error("Invalid hex digit");
+ }
+ } else {
+ insert_char(c1);
+ }
}
END_DEF
@@ -355,7 +343,7 @@
int fd = mkstemp(tempfile);
if (fd == -1) {
- minibuf_error(rblist_from_string("Cannot open temporary file"));
+ minibuf_error("Cannot open temporary file");
ok = false;
} else {
if (!(buf->flags & BFLAG_ANCHORED))
@@ -371,7 +359,7 @@
FILE *pipe;
if ((pipe = popen(rblist_to_string(cmd), "r")) == NULL) {
- minibuf_error(rblist_from_string("Cannot open pipe to process"));
+ minibuf_error("Cannot open pipe to process");
ok = false;
} else {
rblist out = rbacc_to_rblist(rbacc_add_file(rbacc_new(), pipe));
Modified: trunk/zee/src/help.c
===================================================================
--- trunk/zee/src/help.c 2008-08-02 16:17:11 UTC (rev 987)
+++ trunk/zee/src/help.c 2008-08-02 16:22:11 UTC (rev 988)
@@ -39,7 +39,7 @@
if (quitstr == NULL)
quitstr = "Alt-x, `file_quit', RETURN";
- minibuf_write(rblist_fmt(PACKAGE_STRING ". For a menu type Alt-x. To quit, type %s.", quitstr));
+ minibuf_write(rblist_to_string(rblist_fmt(PACKAGE_STRING ". For a menu type Alt-x. To quit, type %s.", quitstr)));
}
END_DEF
@@ -82,7 +82,7 @@
Display the command invoked by a key sequence.\
")
{
- minibuf_write(rblist_from_string("Describe key:"));
+ minibuf_write("Describe key:");
size_t key = getkey();
(void)CLUE_DO(L, rblist_to_string(rblist_fmt("_key = chordtostr(%d)", key)));
const char *keyname;
@@ -92,10 +92,10 @@
const char *cmd;
CLUE_GET(L, s, string, cmd);
if (cmd == NULL) {
- minibuf_error(rblist_fmt("%s is unbound", keyname));
+ minibuf_error(rblist_to_string(rblist_fmt("%s is unbound", keyname)));
ok = false;
} else {
- minibuf_write(rblist_fmt("%s runs the command `%s'", keyname, cmd));
+ minibuf_write(rblist_to_string(rblist_fmt("%s runs the command `%s'", keyname, cmd)));
}
}
END_DEF
Modified: trunk/zee/src/killring.c
===================================================================
--- trunk/zee/src/killring.c 2008-08-02 16:17:11 UTC (rev 987)
+++ trunk/zee/src/killring.c 2008-08-02 16:22:11 UTC (rev 988)
@@ -181,7 +181,7 @@
")
{
if (rblist_length(killed_text) == 0) {
- minibuf_error(rblist_from_string("Clipboard is empty"));
+ minibuf_error("Nothing to paste");
ok = false;
} else if (!warn_if_readonly_buffer()) {
CMDCALL(edit_select_on);
Modified: trunk/zee/src/line.c
===================================================================
--- trunk/zee/src/line.c 2008-08-02 16:17:11 UTC (rev 987)
+++ trunk/zee/src/line.c 2008-08-02 16:22:11 UTC (rev 988)
@@ -392,7 +392,7 @@
*ret = rbacc_to_rblist(rba);
if (eobp()) {
- minibuf_error(rblist_from_string("End of buffer"));
+ minibuf_error("End of buffer");
return false;
}
}
@@ -457,7 +457,7 @@
if (ok) {
CMDCALL(edit_delete_next_character);
} else {
- minibuf_error(rblist_from_string("Beginning of buffer"));
+ minibuf_error("Beginning of buffer");
ok = false;
}
}
Modified: trunk/zee/src/lua.c
===================================================================
--- trunk/zee/src/lua.c 2008-08-02 16:17:11 UTC (rev 987)
+++ trunk/zee/src/lua.c 2008-08-02 16:22:11 UTC (rev 988)
@@ -93,9 +93,24 @@
}
END_DEF
-/*
- * Register C functions in Lua.
- */
+// Miscellaneous bindings
+static int lua_xgetkey(lua_State *L)
+{
+ int mode = (int)luaL_checknumber(L, 1);
+ size_t timeout = (size_t)luaL_checknumber(L, 2);
+ lua_pushnumber(L, (lua_Number)xgetkey(mode, timeout));
+ return 1;
+}
+
+static int lua_minibuf_read_name(lua_State *L)
+{
+ const char *s = luaL_checkstring(L, 1);
+ rblist name = minibuf_read_name(rblist_from_string(s));
+ lua_pushstring(L, rblist_to_string(name));
+ return 1;
+}
+
+// Register C functions in Lua.
void init_commands(void)
{
static luaL_Reg cmds[] = {
@@ -103,6 +118,10 @@
{# cmd_name, F_ ## cmd_name},
#include "tbl_funcs.h"
#undef X
+ {"minibuf_error", minibuf_error},
+ {"minibuf_write", minibuf_write},
+ {"xgetkey", lua_xgetkey},
+ {"minibuf_read_name", lua_minibuf_read_name},
{NULL, NULL}
};
Modified: trunk/zee/src/macro.c
===================================================================
--- trunk/zee/src/macro.c 2008-08-02 16:17:11 UTC (rev 987)
+++ trunk/zee/src/macro.c 2008-08-02 16:22:11 UTC (rev 988)
@@ -65,13 +65,13 @@
")
{
if (thisflag & FLAG_DEFINING_MACRO) {
- minibuf_error(rblist_from_string("Already defining a macro"));
+ minibuf_error("Already defining a macro");
ok = false;
} else {
if (macro_defined)
cancel_macro_definition();
- minibuf_write(rblist_from_string("Defining macro..."));
+ minibuf_write("Defining macro...");
thisflag |= FLAG_DEFINING_MACRO;
(void)CLUE_DO(L, "_macro = {}");
}
@@ -84,7 +84,7 @@
")
{
if (!(thisflag & FLAG_DEFINING_MACRO)) {
- minibuf_error(rblist_from_string("Not defining a macro"));
+ minibuf_error("Not defining a macro");
ok = false;
} else
thisflag &= ~FLAG_DEFINING_MACRO;
@@ -102,10 +102,10 @@
rblist ms;
if ((ms = minibuf_read(rblist_from_string("Name for last macro: "), rblist_empty)) == NULL) {
- minibuf_error(rblist_from_string("No command name given"));
+ minibuf_error("No command name given");
ok = false;
} else if (!macro_defined) {
- minibuf_error(rblist_from_string("No macro defined"));
+ minibuf_error("No macro defined");
ok = false;
} else {
(void)CLUE_DO(L, rblist_to_string(rblist_fmt("_macro = %r", ms)));
@@ -126,7 +126,7 @@
")
{
if (!macro_defined) {
- minibuf_error(rblist_from_string("No macro has been defined"));
+ minibuf_error("No macro has been defined");
ok = false;
} else {
call_macro("_macro");
Modified: trunk/zee/src/main.c
===================================================================
--- trunk/zee/src/main.c 2008-08-02 16:17:11 UTC (rev 987)
+++ trunk/zee/src/main.c 2008-08-02 16:22:11 UTC (rev 988)
@@ -20,6 +20,8 @@
Software Foundation, Fifth Floor, 51 Franklin Street, Boston, MA
02111-1301, USA. */
+// FIXME: Upgrade to GPL 3
+
#include "config.h"
#include <limits.h>
@@ -71,7 +73,6 @@
}
}
-// FIXME: Reset the terminal?
static void segv_sig_handler(int signo)
{
(void)signo;
@@ -79,7 +80,6 @@
die(2);
}
-// FIXME: Reset the terminal?
static void other_sig_handler(int signo)
{
(void)signo;
@@ -124,7 +124,7 @@
// FIXME: Generate the list of files to load
require(PKGDATADIR "/lib.lua");
require(PKGDATADIR "/texinfo.lua");
- require(PKGDATADIR "/tbl_vars.lua"); // FIXME: interpret the texinfo commands
+ require(PKGDATADIR "/tbl_vars.lua");
require(PKGDATADIR "/tbl_funcs.lua");
require(PKGDATADIR "/bind.lua");
require(PKGDATADIR "/completion.lua");
@@ -132,12 +132,13 @@
rblist key_tbl = file_read(rblist_from_string(PKGDATADIR "/tbl_keys.h"));
CLUE_SET(L, key_tbl, string, rblist_to_string(key_tbl));
require(PKGDATADIR "/keys.lua");
+ require(PKGDATADIR "/minibuf.lua");
// FIXME: Load last for now because of its effect on the global environment
require(PKGDATADIR "/std.lua");
init_commands();
init_bindings();
- while (getopt_long_only(argc, argv, "", longopts, &longopt) != -1)
+ while (getopt_long_only(argc, argv, "", longopts, &longopt) != -1) {
switch (longopt) {
case 0:
bflag = true;
@@ -159,19 +160,22 @@
hflag = true;
break;
case 5:
- fprintf(stderr,
- PACKAGE_STRING "\n"
-#define X(name, email, years) \
- "Copyright (c) " years " " name " <" email ">\n"
+ {
+#define X(name, email, years) \
+ "Copyright (c) " years " " name " <" email ">\n"
+ static const char *copyright_notice =
+ PACKAGE_STRING "\n"
#include "copyright.h"
+ PACKAGE_NAME " comes with ABSOLUTELY NO WARRANTY.\n"
+ "You may redistribute copies of " PACKAGE_NAME "\n"
+ "under the terms of the GNU General Public License.\n"
+ "For more information about these matters, see the file named COPYING.\n";
#undef X
- PACKAGE_NAME " comes with ABSOLUTELY NO WARRANTY.\n"
- "You may redistribute copies of " PACKAGE_NAME "\n"
- "under the terms of the GNU General Public License.\n"
- "For more information about these matters, see the file named COPYING.\n"
- );
- return 0;
+ fprintf(stderr, copyright_notice);
+ return 0;
+ }
}
+ }
argc -= optind;
argv += optind;
Modified: trunk/zee/src/minibuf.c
===================================================================
--- trunk/zee/src/minibuf.c 2008-08-02 16:17:11 UTC (rev 987)
+++ trunk/zee/src/minibuf.c 2008-08-02 16:22:11 UTC (rev 988)
@@ -52,25 +52,36 @@
/*
* Write the specified string in the minibuffer.
*/
-void minibuf_write(rblist rbl)
+int minibuf_write(const char *s)
{
- minibuf_draw(rbl);
+ // FIXME: Hack to make it work from Lua
+ if ((lua_State *)s == L) {
+ s = lua_tostring(L, -1);
+ lua_pop(L, 1);
+ }
+ minibuf_draw(rblist_from_string(s));
// Redisplay (and leave the cursor in the correct position).
term_display();
term_refresh();
+
+ // FIXME: Hack to make it work from Lua
+ return 0;
}
/*
* Write the specified error string in the minibuffer and beep.
*/
-void minibuf_error(rblist rbl)
+int minibuf_error(const char *s)
{
- minibuf_write(rbl);
+ minibuf_write(s);
term_beep();
if (thisflag & FLAG_DEFINING_MACRO)
cancel_macro_definition();
+
+ // FIXME: Hack to make it work from Lua
+ return 0;
}
static size_t mb_backward_char(size_t i)
@@ -372,7 +383,7 @@
}
if (rblist_length(ms) == 0) {
- minibuf_error(rblist_from_string("No name given"));
+ minibuf_error("No name given");
return NULL;
}
@@ -387,7 +398,7 @@
ok = true;
break;
} else {
- minibuf_error(rblist_fmt("There is nothing called `%r'", ms));
+ minibuf_error(rblist_to_string(rblist_fmt("There is nothing called `%r'", ms)));
waitkey(WAITKEY_DEFAULT);
}
}
Modified: trunk/zee/src/search.c
===================================================================
--- trunk/zee/src/search.c 2008-08-02 16:17:11 UTC (rev 987)
+++ trunk/zee/src/search.c 2008-08-02 16:22:11 UTC (rev 988)
@@ -154,7 +154,7 @@
find_err = NULL;
}
- minibuf_write(rbl);
+ minibuf_write(rblist_to_string(rbl));
int c = getkey();
if (c == (KBD_CTRL | 'g')) {
@@ -195,7 +195,7 @@
last_search = pattern;
buf->mark->pt = start;
- minibuf_write(rblist_from_string("Mark saved when search started"));
+ minibuf_write("Mark saved when search started");
} else
minibuf_clear();
break;
Modified: trunk/zee/src/tbl_vars.lua
===================================================================
--- trunk/zee/src/tbl_vars.lua 2008-08-02 16:17:11 UTC (rev 987)
+++ trunk/zee/src/tbl_vars.lua 2008-08-02 16:22:11 UTC (rev 988)
@@ -1,5 +1,6 @@
-- Built-in variables
+-- FIXME: interpret the texinfo commands
def{tab_display_width = 8,
"Number of spaces displayed for a tab character."}
def{indent_width = 2,
Modified: trunk/zee/src/undo.c
===================================================================
--- trunk/zee/src/undo.c 2008-08-02 16:17:11 UTC (rev 987)
+++ trunk/zee/src/undo.c 2008-08-02 16:22:11 UTC (rev 988)
@@ -105,11 +105,11 @@
if (!warn_if_readonly_buffer()) {
if (buf->next_undop == NULL) {
- minibuf_error(rblist_from_string("No further undo information"));
+ minibuf_error("No further undo information");
buf->next_undop = buf->last_undop;
} else {
buf->next_undop = revert_action(buf->next_undop);
- minibuf_write(rblist_from_string("Undo!"));
+ minibuf_write("Undo!");
ok = true;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2008-08-02 16:17:02
|
Revision: 987
http://zee.svn.sourceforge.net/zee/?rev=987&view=rev
Author: rrt
Date: 2008-08-02 16:17:11 +0000 (Sat, 02 Aug 2008)
Log Message:
-----------
Add minibuf_clear function
Added Paths:
-----------
trunk/zee/src/minibuf.lua
Added: trunk/zee/src/minibuf.lua
===================================================================
--- trunk/zee/src/minibuf.lua (rev 0)
+++ trunk/zee/src/minibuf.lua 2008-08-02 16:17:11 UTC (rev 987)
@@ -0,0 +1,3 @@
+function minibuf_clear()
+ minibuf_write("")
+end
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2008-08-02 16:16:24
|
Revision: 986
http://zee.svn.sourceforge.net/zee/?rev=986&view=rev
Author: rrt
Date: 2008-08-02 16:16:34 +0000 (Sat, 02 Aug 2008)
Log Message:
-----------
Add getkey function
Modified Paths:
--------------
trunk/zee/src/keys.lua
Modified: trunk/zee/src/keys.lua
===================================================================
--- trunk/zee/src/keys.lua 2008-08-02 16:15:04 UTC (rev 985)
+++ trunk/zee/src/keys.lua 2008-08-02 16:16:34 UTC (rev 986)
@@ -85,3 +85,9 @@
return key
end
+
+-- Wait for a keystroke indefinitely, and return the
+-- corresponding keycode.
+function getkey()
+ return xgetkey(0, 0)
+end
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2008-08-02 16:14:54
|
Revision: 985
http://zee.svn.sourceforge.net/zee/?rev=985&view=rev
Author: rrt
Date: 2008-08-02 16:15:04 +0000 (Sat, 02 Aug 2008)
Log Message:
-----------
Add aborting require.
Modified Paths:
--------------
trunk/zee/src/lib.lua
Modified: trunk/zee/src/lib.lua
===================================================================
--- trunk/zee/src/lib.lua 2008-08-02 16:12:56 UTC (rev 984)
+++ trunk/zee/src/lib.lua 2008-08-02 16:15:04 UTC (rev 985)
@@ -21,3 +21,12 @@
docstring[name] = s
end
end
+
+-- Load a file of Lua, aborting if not found.
+function require(f)
+ local ok, err = pcall(dofile, f .. ".lua")
+ if not ok then
+ io.stderr:write(string.format(PACKAGE_NAME .. " is not properly installed: could not load file `%s'\n%s\n", f, err))
+ die(1)
+ end
+end
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2008-08-02 16:12:48
|
Revision: 984
http://zee.svn.sourceforge.net/zee/?rev=984&view=rev
Author: rrt
Date: 2008-08-02 16:12:56 +0000 (Sat, 02 Aug 2008)
Log Message:
-----------
#include stddef.h for e.g. size_t
Modified Paths:
--------------
trunk/zee/src/rblist.h
Modified: trunk/zee/src/rblist.h
===================================================================
--- trunk/zee/src/rblist.h 2008-08-02 16:11:13 UTC (rev 983)
+++ trunk/zee/src/rblist.h 2008-08-02 16:12:56 UTC (rev 984)
@@ -23,6 +23,8 @@
#ifndef RBLIST_H
#define RBLIST_H
+#include <stddef.h>
+
/*
* The type of lists. This is a pointer type. The structure it points
* to is opaque. You may assume the structure is immutable (const). No
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2008-08-02 16:11:04
|
Revision: 983
http://zee.svn.sourceforge.net/zee/?rev=983&view=rev
Author: rrt
Date: 2008-08-02 16:11:13 +0000 (Sat, 02 Aug 2008)
Log Message:
-----------
Change category of manual
Modified Paths:
--------------
trunk/zee/src/zee.texi
Modified: trunk/zee/src/zee.texi
===================================================================
--- trunk/zee/src/zee.texi 2007-11-12 00:45:34 UTC (rev 982)
+++ trunk/zee/src/zee.texi 2008-08-02 16:11:13 UTC (rev 983)
@@ -2,7 +2,7 @@
@setfilename zee.info
@settitle The Zee Manual
-@dircategory Text editors
+@dircategory Editors
@direntry
* Zee: (zee). Zee text editor.
@end direntry
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2007-11-12 00:45:32
|
Revision: 982
http://zee.svn.sourceforge.net/zee/?rev=982&view=rev
Author: rrt
Date: 2007-11-11 16:45:34 -0800 (Sun, 11 Nov 2007)
Log Message:
-----------
Rewrite bind_key and binding_to_command in Lua.
Make edit_insert_character bindable by adding lastkey(), and bind it
to all printing characters by default (copied from Zile).
Rename "doc" Lua "macro" to "def", in preparation for starting to
define user commands in Lua.
Modified Paths:
--------------
trunk/zee/src/bind.c
trunk/zee/src/bind.lua
trunk/zee/src/extern.h
trunk/zee/src/help.c
trunk/zee/src/keys.c
trunk/zee/src/lib.lua
trunk/zee/src/line.c
trunk/zee/src/macro.c
trunk/zee/src/mkfuncs.lua
trunk/zee/src/tbl_vars.lua
Modified: trunk/zee/src/bind.c
===================================================================
--- trunk/zee/src/bind.c 2007-11-10 23:27:28 UTC (rev 981)
+++ trunk/zee/src/bind.c 2007-11-12 00:45:34 UTC (rev 982)
@@ -30,23 +30,15 @@
#include "rbacc.h"
-rblist binding_to_command(size_t key)
-{
- (void)CLUE_DO(L, rblist_to_string(rblist_fmt("s = _bindings[%d]", key)));
- const char *s;
- CLUE_GET(L, s, string, s);
- return s ? rblist_from_string(s) : NULL;
-}
-
-static void bind_key(size_t key, rblist cmd)
-{
- CLUE_SET(L, key, number, (lua_Number)key);
- CLUE_SET(L, cmd, string, cmd ? rblist_to_string(cmd) : "nil");
- (void)CLUE_DO(L, "_bindings[key] = cmd");
-}
-
void init_bindings(void)
{
+ /* Bind all printing keys to self_insert_command */
+ for (size_t i = 0; i <= 0xff; i++) {
+ if (isprint(i)) {
+ (void)CLUE_DO(L, rblist_to_string(rblist_fmt("bind_key(%d, \"edit_insert_character\")", i)));
+ }
+ }
+
require(PKGDATADIR "/cua_bindings");
}
@@ -57,25 +49,14 @@
}
bool ok = true;
- rblist rbl = binding_to_command(key);
- if (rbl) {
- (void)CLUE_DO(L, rblist_to_string(rblist_fmt("_ok = %r()", rbl)));
+ (void)CLUE_DO(L, rblist_to_string(rblist_fmt("s = binding_to_command(%d)", key)));
+ const char *s;
+ CLUE_GET(L, s, string, s);
+ if (s) {
+ (void)CLUE_DO(L, rblist_to_string(rblist_fmt("_ok = %s()", s)));
CLUE_GET(L, _ok, boolean, ok);
} else {
- if (key == KBD_RET) {
- key = '\n';
- } else if (key == KBD_TAB) {
- key = '\t';
- }
-
- /* FIXME: Make edit_insert_character bindable like
- self_insert_command in Zile, and bind it; printable characters
- should be bound to it by default. */
- if (key <= 0xff) {
- CMDCALL_UINT(edit_insert_character, (int)key);
- } else {
- term_beep();
- }
+ term_beep();
}
/* Only add keystrokes if we're already in macro defining mode
@@ -111,7 +92,7 @@
if (name) {
if (key != KBD_NOKEY) {
- bind_key(key, name);
+ (void)CLUE_DO(L, rblist_to_string(rblist_fmt("bind_key(%d, \"%r\")", key, name)));
} else {
minibuf_error(rblist_from_string("Invalid key"));
ok = false;
@@ -138,7 +119,7 @@
}
if (key != KBD_NOKEY) {
- bind_key(key, NULL);
+ (void)CLUE_DO(L, rblist_to_string(rblist_fmt("bind_key(%d, nil)", key)));
} else {
minibuf_error(rblist_from_string("Invalid key"));
ok = false;
Modified: trunk/zee/src/bind.lua
===================================================================
--- trunk/zee/src/bind.lua 2007-11-10 23:27:28 UTC (rev 981)
+++ trunk/zee/src/bind.lua 2007-11-12 00:45:34 UTC (rev 982)
@@ -20,19 +20,20 @@
_bindings = {}
+function bind_key(key, cmd)
+ _bindings[key] = cmd
+end
+
function command_to_binding(cmd)
- -- FIXME: This could be simplified with table.concat
- local s = ""
- local n = false
+ local t = {}
for i, v in pairs(_bindings) do
if v == cmd then
- if n then
- s = s .. ", "
- else
- n = true
- end
- s = s .. chordtostr(i)
+ table.insert(t, chordtostr(i))
end
end
- return s
+ return table.concat(t, ", ")
end
+
+function binding_to_command(key)
+ return _bindings[key]
+end
Modified: trunk/zee/src/extern.h
===================================================================
--- trunk/zee/src/extern.h 2007-11-10 23:27:28 UTC (rev 981)
+++ trunk/zee/src/extern.h 2007-11-12 00:45:34 UTC (rev 982)
@@ -34,7 +34,6 @@
// bind.c -----------------------------------------------------------------
void process_key(size_t key);
void init_bindings(void);
-rblist binding_to_command(size_t key);
// buffer.c ---------------------------------------------------------------
void buffer_new(void);
@@ -52,6 +51,7 @@
void die(int exitcode);
// keys.c -----------------------------------------------------------------
+size_t lastkey(void);
size_t xgetkey(int mode, size_t timeout);
size_t getkey(void);
void waitkey(size_t timeout);
Modified: trunk/zee/src/help.c
===================================================================
--- trunk/zee/src/help.c 2007-11-10 23:27:28 UTC (rev 981)
+++ trunk/zee/src/help.c 2007-11-12 00:45:34 UTC (rev 982)
@@ -88,12 +88,14 @@
const char *keyname;
CLUE_GET(L, _key, string, keyname);
- rblist cmd;
- if ((cmd = binding_to_command(key)) == NULL) {
+ (void)CLUE_DO(L, rblist_to_string(rblist_fmt("s = binding_to_command(%d)", key)));
+ const char *cmd;
+ CLUE_GET(L, s, string, cmd);
+ if (cmd == NULL) {
minibuf_error(rblist_fmt("%s is unbound", keyname));
ok = false;
} else {
- minibuf_write(rblist_fmt("%s runs the command `%r'", keyname, cmd));
+ minibuf_write(rblist_fmt("%s runs the command `%s'", keyname, cmd));
}
}
END_DEF
Modified: trunk/zee/src/keys.c
===================================================================
--- trunk/zee/src/keys.c 2007-11-10 23:27:28 UTC (rev 981)
+++ trunk/zee/src/keys.c 2007-11-12 00:45:34 UTC (rev 982)
@@ -38,7 +38,14 @@
static int key_buf[MAX_KEY_BUF];
static int *keyp = key_buf;
+static size_t _last_key;
+/* Return last key pressed */
+size_t lastkey(void)
+{
+ return _last_key;
+}
+
/*
* Get a keystroke, waiting for up to timeout 10ths of a second if
* mode contains GETKEY_DELAYED, and translating it into a
@@ -46,15 +53,15 @@
*/
size_t xgetkey(int mode, size_t timeout)
{
- size_t key;
-
- if (keyp > key_buf)
- return *--keyp;
-
- key = term_xgetkey(mode, timeout);
- if (thisflag & FLAG_DEFINING_MACRO)
- add_key_to_cmd(key);
- return key;
+ if (keyp > key_buf) {
+ _last_key = *--keyp;
+ } else {
+ _last_key = term_xgetkey(mode, timeout);
+ if (thisflag & FLAG_DEFINING_MACRO) {
+ add_key_to_cmd(_last_key);
+ }
+ }
+ return _last_key;
}
/*
Modified: trunk/zee/src/lib.lua
===================================================================
--- trunk/zee/src/lib.lua 2007-11-10 23:27:28 UTC (rev 981)
+++ trunk/zee/src/lib.lua 2007-11-12 00:45:34 UTC (rev 982)
@@ -1,15 +1,15 @@
--- Library functions for Lua mk* scripts
+-- Zee-specific library functions
--- Utility function for parsing tbl_*.h
+-- Parse re-usable C headers
function X(...)
xarg = {...}
end
--- Utility function for parsing doc-stringed definitions
+-- Extract the docstrings from tbl_funcs.lua
docstring = {}
-function doc(t)
+function def(t)
local name, s
- for i, v in pairs (t) do
+ for i, v in pairs(t) do
if type(i) == "string" then
name = i
_G[name] = v
Modified: trunk/zee/src/line.c
===================================================================
--- trunk/zee/src/line.c 2007-11-10 23:27:28 UTC (rev 981)
+++ trunk/zee/src/line.c 2007-11-12 00:45:34 UTC (rev 982)
@@ -408,18 +408,18 @@
return true;
}
-DEF_ARG(edit_insert_character,
+DEF(edit_insert_character,
"\
Insert the character you type.\n\
Whichever character you type to run this command is inserted.\
-",
-UINT(c, "Insert character: "))
+")
{
if (ok) {
undo_save(UNDO_START_SEQUENCE, buf->pt, 0, 0);
buf->flags &= ~BFLAG_ANCHORED;
+ int c = lastkey() & ~KBD_CTRL;
if (c <= 0xff) {
if (isspace(c) && buf->flags & BFLAG_WRAP_MODE &&
get_goalc() > (size_t)get_variable_number("wrap_column"))
Modified: trunk/zee/src/macro.c
===================================================================
--- trunk/zee/src/macro.c 2007-11-10 23:27:28 UTC (rev 981)
+++ trunk/zee/src/macro.c 2007-11-12 00:45:34 UTC (rev 982)
@@ -46,7 +46,7 @@
cmd_started = true;
}
- (void)CLUE_DO(L, rblist_to_string(rblist_fmt("table.insert(_cmd, %r)", binding_to_command(key))));
+ (void)CLUE_DO(L, rblist_to_string(rblist_fmt("table.insert(_cmd, binding_to_command(%d))", key)));
macro_defined = true;
}
Modified: trunk/zee/src/mkfuncs.lua
===================================================================
--- trunk/zee/src/mkfuncs.lua 2007-11-10 23:27:28 UTC (rev 981)
+++ trunk/zee/src/mkfuncs.lua 2007-11-12 00:45:34 UTC (rev 982)
@@ -49,7 +49,7 @@
h2:write("\n")
h3:write("-- Automatically generated file: DO NOT EDIT!\n")
-h3:write("-- Docstrings for user commands\n")
+h3:write("-- Stubs with docstrings for user commands implemented in C\n")
h3:write("\n")
for i in ipairs(arg) do
@@ -88,7 +88,7 @@
infodoc = string.gsub(infodoc, "\\", "")
h1:write("@item " .. name .. "\n" .. infodoc)
h2:write("X(" .. name .. ")\n")
- h3:write("doc{" .. name .. " = function () end, \"" .. string.gsub(doc, "\\\n", "") .. "\"}\n")
+ h3:write("def{" .. name .. " = function () end, \"" .. string.gsub(doc, "\\\n", "") .. "\"}\n")
end
end
end
Modified: trunk/zee/src/tbl_vars.lua
===================================================================
--- trunk/zee/src/tbl_vars.lua 2007-11-10 23:27:28 UTC (rev 981)
+++ trunk/zee/src/tbl_vars.lua 2007-11-12 00:45:34 UTC (rev 982)
@@ -1,14 +1,14 @@
-- Built-in variables
-doc{tab_display_width = 8,
+def{tab_display_width = 8,
"Number of spaces displayed for a tab character."}
-doc{indent_width = 2,
+def{indent_width = 2,
"Number per indentation for @samp{edit_insert_tab}."}
-doc{wrap_mode = false,
+def{wrap_mode = false,
"Whether wrap mode is automatically enabled."}
-doc{wrap_column = 72,
+def{wrap_column = 72,
"Column beyond which wrapping occurs in wrap mode."}
-doc{caseless_search = true,
+def{caseless_search = true,
"Whether searching ignores case by default."}
-doc{case_replace = true,
+def{case_replace = true,
"Whether @samp{edit_replace} should preserve case."}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2007-11-10 23:27:23
|
Revision: 981
http://zee.svn.sourceforge.net/zee/?rev=981&view=rev
Author: rrt
Date: 2007-11-10 15:27:28 -0800 (Sat, 10 Nov 2007)
Log Message:
-----------
Move initialisation of _bindings to bind.lua from bind.c.
"C commands" should be "user commands" in mkfuncs.lua.
Modified Paths:
--------------
trunk/zee/src/bind.c
trunk/zee/src/bind.lua
trunk/zee/src/mkfuncs.lua
Modified: trunk/zee/src/bind.c
===================================================================
--- trunk/zee/src/bind.c 2007-11-10 23:19:09 UTC (rev 980)
+++ trunk/zee/src/bind.c 2007-11-10 23:27:28 UTC (rev 981)
@@ -47,7 +47,6 @@
void init_bindings(void)
{
- (void)CLUE_DO(L, "_bindings = {}");
require(PKGDATADIR "/cua_bindings");
}
Modified: trunk/zee/src/bind.lua
===================================================================
--- trunk/zee/src/bind.lua 2007-11-10 23:19:09 UTC (rev 980)
+++ trunk/zee/src/bind.lua 2007-11-10 23:27:28 UTC (rev 981)
@@ -18,6 +18,8 @@
-- Software Foundation, Fifth Floor, 51 Franklin Street, Boston, MA
-- 02111-1301, USA.
+_bindings = {}
+
function command_to_binding(cmd)
-- FIXME: This could be simplified with table.concat
local s = ""
Modified: trunk/zee/src/mkfuncs.lua
===================================================================
--- trunk/zee/src/mkfuncs.lua 2007-11-10 23:19:09 UTC (rev 980)
+++ trunk/zee/src/mkfuncs.lua 2007-11-10 23:27:28 UTC (rev 981)
@@ -49,7 +49,7 @@
h2:write("\n")
h3:write("-- Automatically generated file: DO NOT EDIT!\n")
-h3:write("-- Docstrings for C commands\n")
+h3:write("-- Docstrings for user commands\n")
h3:write("\n")
for i in ipairs(arg) do
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2007-11-10 23:19:06
|
Revision: 980
http://zee.svn.sourceforge.net/zee/?rev=980&view=rev
Author: rrt
Date: 2007-11-10 15:19:09 -0800 (Sat, 10 Nov 2007)
Log Message:
-----------
Rewrite strtochord and chordtostr in Lua.
Modified Paths:
--------------
trunk/zee/src/Makefile.am
trunk/zee/src/bind.c
trunk/zee/src/extern.h
trunk/zee/src/help.c
trunk/zee/src/keys.c
trunk/zee/src/keys.lua
Modified: trunk/zee/src/Makefile.am
===================================================================
--- trunk/zee/src/Makefile.am 2007-11-10 22:38:47 UTC (rev 979)
+++ trunk/zee/src/Makefile.am 2007-11-10 23:19:09 UTC (rev 980)
@@ -70,7 +70,7 @@
undo.c
zee_CPPFLAGS = -DPKGDATADIR="\"$(pkgdatadir)\"" -DSYSCONFDIR="\"$(sysconfdir)\""
-zee_LDADD = @LIBOBJS@ ../bitlib/liblua-bit.la
+zee_LDADD = @LIBOBJS@ ../bitlib/bit.la
LUA_BUILDTIME = mkfuncs.lua mkvars.lua mkopts.lua mkkeys.lua mkcopyright.lua
Modified: trunk/zee/src/bind.c
===================================================================
--- trunk/zee/src/bind.c 2007-11-10 22:38:47 UTC (rev 979)
+++ trunk/zee/src/bind.c 2007-11-10 23:19:09 UTC (rev 980)
@@ -97,13 +97,17 @@
rblist name = NULL;
if (lua_gettop(L) > 1) {
- key = strtochord(rblist_from_string(lua_tostring(L, -2)));
+ (void)CLUE_DO(L, rblist_to_string(rblist_fmt("_key = strtochord(\"%s\")", lua_tostring(L, -2))));
+ CLUE_GET(L, _key, number, key);
name = rblist_from_string(lua_tostring(L, -1));
lua_pop(L, 2);
} else {
minibuf_write(rblist_from_string("Bind key: "));
key = getkey();
- name = minibuf_read_name(rblist_fmt("Bind key %r to command: ", chordtostr(key)));
+ (void)CLUE_DO(L, rblist_to_string(rblist_fmt("_key = chordtostr(%d)", key)));
+ const char *key_name;
+ CLUE_GET(L, _key, string, key_name);
+ name = minibuf_read_name(rblist_fmt("Bind key %s to command: ", key_name));
}
if (name) {
@@ -126,7 +130,8 @@
size_t key = KBD_NOKEY;
if (lua_gettop(L) > 0) {
- key = strtochord(rblist_from_string(lua_tostring(L, -1)));
+ (void)CLUE_DO(L, rblist_to_string(rblist_fmt("_key = strtochord(\"%s\")", lua_tostring(L, -1))));
+ CLUE_GET(L, _key, number, key);
lua_pop(L, 1);
} else {
minibuf_write(rblist_from_string("Unbind key: "));
Modified: trunk/zee/src/extern.h
===================================================================
--- trunk/zee/src/extern.h 2007-11-10 22:38:47 UTC (rev 979)
+++ trunk/zee/src/extern.h 2007-11-10 23:19:09 UTC (rev 980)
@@ -56,8 +56,6 @@
size_t getkey(void);
void waitkey(size_t timeout);
void ungetkey(size_t key);
-rblist chordtostr(size_t key);
-size_t strtochord(rblist chord);
// killring.c -------------------------------------------------------------
void init_kill_ring(void);
Modified: trunk/zee/src/help.c
===================================================================
--- trunk/zee/src/help.c 2007-11-10 22:38:47 UTC (rev 979)
+++ trunk/zee/src/help.c 2007-11-10 23:19:09 UTC (rev 980)
@@ -82,17 +82,18 @@
Display the command invoked by a key sequence.\
")
{
- size_t key;
- rblist keyname, cmd;
-
minibuf_write(rblist_from_string("Describe key:"));
- key = getkey();
- keyname = chordtostr(key);
+ size_t key = getkey();
+ (void)CLUE_DO(L, rblist_to_string(rblist_fmt("_key = chordtostr(%d)", key)));
+ const char *keyname;
+ CLUE_GET(L, _key, string, keyname);
+ rblist cmd;
if ((cmd = binding_to_command(key)) == NULL) {
- minibuf_error(rblist_fmt("%r is unbound", keyname));
+ minibuf_error(rblist_fmt("%s is unbound", keyname));
ok = false;
- } else
- minibuf_write(rblist_fmt("%r runs the command `%r'", keyname, cmd));
+ } else {
+ minibuf_write(rblist_fmt("%s runs the command `%r'", keyname, cmd));
+ }
}
END_DEF
Modified: trunk/zee/src/keys.c
===================================================================
--- trunk/zee/src/keys.c 2007-11-10 22:38:47 UTC (rev 979)
+++ trunk/zee/src/keys.c 2007-11-10 23:19:09 UTC (rev 980)
@@ -80,93 +80,3 @@
if (keyp < key_buf + MAX_KEY_BUF && key != KBD_NOKEY)
*keyp++ = key;
}
-
-
-// Key code and name arrays
-
-static size_t keycode[] = {
-#define X(key_sym, key_name, text_name, key_code) \
- key_code,
-#include "tbl_keys.h"
-#undef X
-};
-
-static const char *keyname[] = {
-#define X(key_sym, key_name, text_name, key_code) \
- key_name,
-#include "tbl_keys.h"
-#undef X
-};
-
-/*
- * Convert a key chord into its ASCII representation
- */
-rblist chordtostr(size_t key)
-{
- size_t i;
- rbacc rba = rbacc_new();
-
- if (key & KBD_CTRL)
- rbacc_add_string(rba, "Ctrl-");
- if (key & KBD_META)
- rbacc_add_string(rba, "Alt-");
- key &= ~(KBD_CTRL | KBD_META);
-
- bool found = false;
- for (i = 0; i < sizeof(keycode) / sizeof(keycode[0]); i++)
- if (keycode[i] == key) {
- rbacc_add_string(rba, keyname[i]);
- found = true;
- break;
- }
-
- if (found == false) {
- if (isgraph(key))
- rbacc_add_char(rba, (char)key);
- else
- rbacc_add_rblist(rba, rblist_fmt("<%x>", key));
- }
-
- return rbacc_to_rblist(rba);
-}
-
-/*
- * Find a key name as a prefix of `rbl', returning its keycode, and
- * the number of characters consumed in `*len'.
- */
-static size_t strtokey(rblist rbl, size_t *len)
-{
- size_t i;
-
- for (i = 0; i < sizeof(keyname) / sizeof(keyname[0]); i++) {
- size_t keylen = strlen(keyname[i]);
- if (rblist_length(rbl) >= keylen &&
- strncmp(rblist_to_string(rbl), keyname[i], keylen) == 0) {
- *len = keylen;
- return keycode[i];
- }
- }
-
- *len = 1;
- return (size_t)rblist_get(rbl, 0);
-}
-
-/*
- * Convert a key chord string to its key code
- */
-size_t strtochord(rblist chord)
-{
- size_t key = 0, len = 0, k;
-
- do {
- size_t l;
- k = strtokey(rblist_sub(chord, len, rblist_length(chord)), &l);
- key |= k;
- len += l;
- } while (k == KBD_CTRL || k == KBD_META);
-
- if (len != rblist_length(chord))
- key = KBD_NOKEY;
-
- return key;
-}
Modified: trunk/zee/src/keys.lua
===================================================================
--- trunk/zee/src/keys.lua 2007-11-10 22:38:47 UTC (rev 979)
+++ trunk/zee/src/keys.lua 2007-11-10 23:19:09 UTC (rev 980)
@@ -18,13 +18,13 @@
-- Software Foundation, Fifth Floor, 51 Franklin Street, Boston, MA
-- 02111-1301, USA.
-keyname = {}
+keyname = {[-1] = "NOKEY"}
function X(key_sym, key_name, text_name, key_code)
keyname[key_code] = key_name
end
loadstring(key_tbl)()
-keycode = {}
+keycode = {NOKEY = -1}
function X(key_sym, key_name, text_name, key_code)
keycode[key_name] = key_code
end
@@ -35,10 +35,10 @@
local i
local s = ""
- if bit.band(key, keycode["Ctrl-"]) then
+ if bit.band(key, keycode["Ctrl-"]) ~= 0 then
s = s .. "Ctrl-"
end
- if bit.band(key, keycode["Alt-"]) then
+ if bit.band(key, keycode["Alt-"]) ~= 0 then
s = s .. "Alt-"
end
key = bit.band(key, bit.bnot(bit.bor(keycode["Ctrl-"], keycode["Alt-"])))
@@ -55,3 +55,33 @@
return s
end
+
+-- Find a key name as a prefix of `s', returning its keycode and the
+-- number of characters consumed
+local function strtokey(s)
+ for _, v in pairs(keyname) do
+ if #s >= #v and string.sub(s, 1, #v) == v then
+ return keycode[v], #v
+ end
+ end
+
+ return string.byte(s, 1), 1
+end
+
+-- Convert a key chord string to its key code
+function strtochord(chord)
+ local key, len = 0, 0
+ local k
+ repeat
+ local l
+ k, l = strtokey(string.sub(chord, len + 1, #chord))
+ key = bit.bor(key, k)
+ len = len + l
+ until k ~= keycode["Ctrl-"] and k ~= keycode["Alt-"]
+
+ if len ~= #chord then
+ key = keycode["NOKEY"]
+ end
+
+ return key
+end
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2007-11-10 22:38:43
|
Revision: 979
http://zee.svn.sourceforge.net/zee/?rev=979&view=rev
Author: rrt
Date: 2007-11-10 14:38:47 -0800 (Sat, 10 Nov 2007)
Log Message:
-----------
Update to bitlib release 23, with important fix.
Modified Paths:
--------------
trunk/zee/bitlib/Makefile.am
trunk/zee/bitlib/Makefile.in
trunk/zee/bitlib/README
trunk/zee/bitlib/lbitlib.c
Modified: trunk/zee/bitlib/Makefile.am
===================================================================
--- trunk/zee/bitlib/Makefile.am 2007-11-10 21:00:34 UTC (rev 978)
+++ trunk/zee/bitlib/Makefile.am 2007-11-10 22:38:47 UTC (rev 979)
@@ -1,7 +1,8 @@
## Process this file with automake to produce Makefile.in
-lib_LTLIBRARIES = liblua-bit.la
+lib_LTLIBRARIES = bit.la
-liblua_bit_la_SOURCES = lbitlib.c
+bit_la_SOURCES = lbitlib.c
+bit_la_LDFLAGS = -module
-all: liblua-bit.la
+all: bit.la
Modified: trunk/zee/bitlib/Makefile.in
===================================================================
--- trunk/zee/bitlib/Makefile.in 2007-11-10 21:00:34 UTC (rev 978)
+++ trunk/zee/bitlib/Makefile.in 2007-11-10 22:38:47 UTC (rev 979)
@@ -54,9 +54,12 @@
am__installdirs = "$(DESTDIR)$(libdir)"
libLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(lib_LTLIBRARIES)
-liblua_bit_la_LIBADD =
-am_liblua_bit_la_OBJECTS = lbitlib.lo
-liblua_bit_la_OBJECTS = $(am_liblua_bit_la_OBJECTS)
+bit_la_LIBADD =
+am_bit_la_OBJECTS = lbitlib.lo
+bit_la_OBJECTS = $(am_bit_la_OBJECTS)
+bit_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(bit_la_LDFLAGS) \
+ $(LDFLAGS) -o $@
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@@ -69,8 +72,8 @@
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
-SOURCES = $(liblua_bit_la_SOURCES)
-DIST_SOURCES = $(liblua_bit_la_SOURCES)
+SOURCES = $(bit_la_SOURCES)
+DIST_SOURCES = $(bit_la_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -193,8 +196,9 @@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-lib_LTLIBRARIES = liblua-bit.la
-liblua_bit_la_SOURCES = lbitlib.c
+lib_LTLIBRARIES = bit.la
+bit_la_SOURCES = lbitlib.c
+bit_la_LDFLAGS = -module
all: all-am
.SUFFIXES:
@@ -259,8 +263,8 @@
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
-liblua-bit.la: $(liblua_bit_la_OBJECTS) $(liblua_bit_la_DEPENDENCIES)
- $(LINK) -rpath $(libdir) $(liblua_bit_la_OBJECTS) $(liblua_bit_la_LIBADD) $(LIBS)
+bit.la: $(bit_la_OBJECTS) $(bit_la_DEPENDENCIES)
+ $(bit_la_LINK) -rpath $(libdir) $(bit_la_OBJECTS) $(bit_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -585,7 +589,7 @@
tags uninstall uninstall-am uninstall-libLTLIBRARIES
-all: liblua-bit.la
+all: bit.la
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
Modified: trunk/zee/bitlib/README
===================================================================
--- trunk/zee/bitlib/README 2007-11-10 21:00:34 UTC (rev 978)
+++ trunk/zee/bitlib/README 2007-11-10 22:38:47 UTC (rev 979)
@@ -1,4 +1,4 @@
- bitlib release 22
+ bitlib release 23
-----------------
by Reuben Thomas <rr...@sc...>
@@ -15,7 +15,7 @@
Thanks to John Passaniti for his bitwise operations library, some of
whose ideas I used, to Thatcher Ulrich for portability fixes, and to
-John Stiles for suggesting a bug fix.
+John Stiles for a bug fix.
Installation
@@ -43,23 +43,20 @@
Lua functions provided:
-bit.bnot(a) returns the one's complement of a
-bit.band(w1,...) returns the bitwise and of the w's
-bit.bor(w1,...) returns the bitwise or of the w's
-bit.bxor(w1,...) returns the bitwise exclusive or of the w's
-bit.lshift(a,b) returns a shifted left b places
-bit.rshift(a,b) returns a shifted logically right b places
-bit.arshift(a,b) returns a shifted arithmetically right b places
-bit.mod(a,b) returns the integer remainder of a divided by b
+bit.bnot(a) returns the one's complement of a
+bit.band(w1, ...) returns the bitwise and of the w's
+bit.bor(w1, ...) returns the bitwise or of the w's
+bit.bxor(w1, ...) returns the bitwise exclusive or of the w's
+bit.lshift(a, b) returns a shifted left b places
+bit.rshift(a, b) returns a shifted logically right b places
+bit.arshift(a, b) returns a shifted arithmetically right b places
-All function arguments should be integers. The number of bits is the
-lesser of the number of bits in uintmax_t and the number in the
-mantissa of lua_Number (assuming it is floating point, otherwise just
-the number of bits in lua_Number). lua_Number is typically a 64-byte
-IEEE float, which give 53 bits (the size of the mantissa), and
-uintmax_t is typically 64 bits. If you use a number too large for
-lua_Number, you certainly lose the extra bits, and you may even find
-that your compiler clamps values to UINTMAX_MAX.
+All function arguments should be integers. By default, the numbers
+used are 32-bit. This can be changed by redefining Integer and
+UInteger at the top of lbitlib.c. The type used should at most have
+the same number of bits as the mantissa of lua_Number, to avoid
+casting problems. lua_Number is typically a 64-byte IEEE float, which
+has a 53 bit mantissa.
The logical operations start with "b" for "bit" to avoid clashing with
reserved words; although "xor" isn't a reserved word, it seemed better
Modified: trunk/zee/bitlib/lbitlib.c
===================================================================
--- trunk/zee/bitlib/lbitlib.c 2007-11-10 21:00:34 UTC (rev 978)
+++ trunk/zee/bitlib/lbitlib.c 2007-11-10 22:38:47 UTC (rev 979)
@@ -6,8 +6,8 @@
#include <lauxlib.h>
#include <lua.h>
-typedef uintmax_t Integer;
-typedef intmax_t UInteger;
+typedef int32_t Integer;
+typedef uint32_t UInteger;
#define checkUInteger(L, n) ((UInteger)luaL_checknumber((L), (n)))
@@ -40,7 +40,6 @@
TDYADIC(lshift, <<, Integer, UInteger)
TDYADIC(rshift, >>, UInteger, UInteger)
TDYADIC(arshift, >>, Integer, UInteger)
-TDYADIC(mod, %, Integer, Integer)
static const struct luaL_reg bitlib[] = {
{"bnot", bit_bnot},
@@ -50,7 +49,6 @@
{"lshift", bit_lshift},
{"rshift", bit_rshift},
{"arshift", bit_arshift},
- {"mod", bit_mod},
{NULL, NULL}
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2007-11-10 21:00:38
|
Revision: 978
http://zee.svn.sourceforge.net/zee/?rev=978&view=rev
Author: rrt
Date: 2007-11-10 13:00:34 -0800 (Sat, 10 Nov 2007)
Log Message:
-----------
Set some ignores.
Property Changed:
----------------
trunk/zee/bitlib/
Property changes on: trunk/zee/bitlib
___________________________________________________________________
Name: svn:ignore
+ config.log
config.status
libtool
.libs
.deps
Makefile
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2007-11-10 12:13:50
|
Revision: 977
http://zee.svn.sourceforge.net/zee/?rev=977&view=rev
Author: rrt
Date: 2007-11-10 04:13:53 -0800 (Sat, 10 Nov 2007)
Log Message:
-----------
Use new Clue API.
Modified Paths:
--------------
trunk/zee/src/bind.c
trunk/zee/src/help.c
trunk/zee/src/killring.c
trunk/zee/src/main.c
trunk/zee/src/main.h
trunk/zee/src/minibuf.c
Modified: trunk/zee/src/bind.c
===================================================================
--- trunk/zee/src/bind.c 2007-11-10 12:13:39 UTC (rev 976)
+++ trunk/zee/src/bind.c 2007-11-10 12:13:53 UTC (rev 977)
@@ -34,14 +34,14 @@
{
(void)CLUE_DO(L, rblist_to_string(rblist_fmt("s = _bindings[%d]", key)));
const char *s;
- CLUE_EXPORT(L, s, s, string);
+ CLUE_GET(L, s, string, s);
return s ? rblist_from_string(s) : NULL;
}
static void bind_key(size_t key, rblist cmd)
{
- CLUE_IMPORT(L, (lua_Number)key, key, number);
- CLUE_IMPORT(L, cmd ? rblist_to_string(cmd) : "nil", cmd, string);
+ CLUE_SET(L, key, number, (lua_Number)key);
+ CLUE_SET(L, cmd, string, cmd ? rblist_to_string(cmd) : "nil");
(void)CLUE_DO(L, "_bindings[key] = cmd");
}
@@ -61,7 +61,7 @@
rblist rbl = binding_to_command(key);
if (rbl) {
(void)CLUE_DO(L, rblist_to_string(rblist_fmt("_ok = %r()", rbl)));
- CLUE_EXPORT(L, ok, _ok, boolean);
+ CLUE_GET(L, _ok, boolean, ok);
} else {
if (key == KBD_RET) {
key = '\n';
Modified: trunk/zee/src/help.c
===================================================================
--- trunk/zee/src/help.c 2007-11-10 12:13:39 UTC (rev 976)
+++ trunk/zee/src/help.c 2007-11-10 12:13:53 UTC (rev 977)
@@ -35,7 +35,7 @@
{
(void)CLUE_DO(L, "s = command_to_binding(\"file_quit\")");
const char *quitstr;
- CLUE_EXPORT(L, quitstr, s, string);
+ CLUE_GET(L, s, string, quitstr);
if (quitstr == NULL)
quitstr = "Alt-x, `file_quit', RETURN";
@@ -47,7 +47,7 @@
{
(void)CLUE_DO(L, rblist_to_string(rblist_fmt("s = docstring[\"%r\"]", name)));
const char *s;
- CLUE_EXPORT(L, s, s, string);
+ CLUE_GET(L, s, string, s);
return s;
}
@@ -64,7 +64,7 @@
rblist where = rblist_empty;
(void)CLUE_DO(L, rblist_to_string(rblist_fmt("s = command_to_binding(\"%r\")", name)));
const char *bindings;
- CLUE_EXPORT(L, bindings, s, string);
+ CLUE_GET(L, s, string, bindings);
if (bindings)
where = rblist_fmt("\n\nBound to: %s", bindings);
const char *doc = get_docstring(name);
Modified: trunk/zee/src/killring.c
===================================================================
--- trunk/zee/src/killring.c 2007-11-10 12:13:39 UTC (rev 976)
+++ trunk/zee/src/killring.c 2007-11-10 12:13:53 UTC (rev 977)
@@ -140,7 +140,7 @@
undo_save(UNDO_START_SEQUENCE, buf->pt, 0, 0);
CMDCALL(edit_select_on);
(void)CLUE_DO(L, rblist_to_string(rblist_fmt("_ok = %s()", cmd)));
- CLUE_EXPORT(L, ok, _ok, boolean);
+ CLUE_GET(L, _ok, boolean, ok);
if (ok) {
CMDCALL(edit_kill_selection);
}
Modified: trunk/zee/src/main.c
===================================================================
--- trunk/zee/src/main.c 2007-11-10 12:13:39 UTC (rev 976)
+++ trunk/zee/src/main.c 2007-11-10 12:13:53 UTC (rev 977)
@@ -130,7 +130,7 @@
require(PKGDATADIR "/completion.lua");
require(PKGDATADIR "/history.lua");
rblist key_tbl = file_read(rblist_from_string(PKGDATADIR "/tbl_keys.h"));
- CLUE_IMPORT(L, rblist_to_string(key_tbl), key_tbl, string);
+ CLUE_SET(L, key_tbl, string, rblist_to_string(key_tbl));
require(PKGDATADIR "/keys.lua");
// FIXME: Load last for now because of its effect on the global environment
require(PKGDATADIR "/std.lua");
Modified: trunk/zee/src/main.h
===================================================================
--- trunk/zee/src/main.h 2007-11-10 12:13:39 UTC (rev 976)
+++ trunk/zee/src/main.h 2007-11-10 12:13:53 UTC (rev 977)
@@ -246,11 +246,11 @@
#define CMDCALL(name) \
(void)CLUE_DO(L, "_ok = " #name "()"); \
- CLUE_EXPORT(L, ok, _ok, boolean)
+ CLUE_GET(L, _ok, boolean, ok)
// Call a command with an integer argument
#define CMDCALL_UINT(name, arg) \
(void)CLUE_DO(L, rblist_to_string(rblist_fmt("_ok = " #name "(%d)", arg))); \
- CLUE_EXPORT(L, ok, _ok, boolean)
+ CLUE_GET(L, _ok, boolean, ok)
#endif // !MAIN_H
Modified: trunk/zee/src/minibuf.c
===================================================================
--- trunk/zee/src/minibuf.c 2007-11-10 12:13:39 UTC (rev 976)
+++ trunk/zee/src/minibuf.c 2007-11-10 12:13:53 UTC (rev 977)
@@ -34,10 +34,10 @@
// Bindings to Lua completion functions
static bool completion_try(rblist search)
{
- CLUE_IMPORT(L, rblist_to_string(search), search, string);
+ CLUE_SET(L, search, string, rblist_to_string(search));
(void)CLUE_DO(L, "b = completion_try(cp, search)");
bool b;
- CLUE_EXPORT(L, b, b, boolean);
+ CLUE_GET(L, b, boolean, b);
return b;
}
@@ -122,7 +122,7 @@
if (history) {
(void)CLUE_DO(L, rblist_to_string(rblist_fmt("s = previous_history_element(%s)", history)));
const char *s;
- CLUE_EXPORT(L, s, s, string);
+ CLUE_GET(L, s, string, s);
if (s) {
if (!*saved) {
*saved = *as;
@@ -138,7 +138,7 @@
if (history) {
(void)CLUE_DO(L, rblist_to_string(rblist_fmt("s = next_history_element(%s)", history)));
const char *s;
- CLUE_EXPORT(L, s, s, string);
+ CLUE_GET(L, s, string, s);
if (s) {
*as = rblist_from_string(s);
} else if (*saved) {
@@ -195,7 +195,7 @@
{
(void)CLUE_DO(L, "ms = cp.match");
const char *s;
- CLUE_EXPORT(L, s, ms, string);
+ CLUE_GET(L, ms, string, s);
return rblist_from_string(s);
}
@@ -203,7 +203,7 @@
{
(void)CLUE_DO(L, "m = #(cp.matches)");
size_t matches;
- CLUE_EXPORT(L, matches, m, number);
+ CLUE_GET(L, m, number, matches);
return matches;
}
@@ -227,12 +227,12 @@
if (cp != NULL && (!old_as || rblist_compare(old_as, rbl))) {
// Using completions and `rbl' has changed, so display new completions.
completion_try(rbl);
- CLUE_IMPORT(L, rblist_to_string(rbl), search, string);
+ CLUE_SET(L, search, string, rblist_to_string(rbl));
(void)CLUE_DO(L, "completion_remove_suffix(cp)");
(void)CLUE_DO(L, "completion_remove_prefix(cp, search)");
(void)CLUE_DO(L, rblist_to_string(rblist_fmt("s = completion_write(cp, %d)", win.ewidth)));
const char *s;
- CLUE_EXPORT(L, s, s, string);
+ CLUE_GET(L, s, string, s);
rblist rbl = rblist_from_string(s);
popup_set(rbl);
term_display();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2007-11-10 12:13:40
|
Revision: 976
http://zee.svn.sourceforge.net/zee/?rev=976&view=rev
Author: rrt
Date: 2007-11-10 04:13:39 -0800 (Sat, 10 Nov 2007)
Log Message:
-----------
Fix a typo
Modified Paths:
--------------
trunk/zee/src/clue.h
Modified: trunk/zee/src/clue.h
===================================================================
--- trunk/zee/src/clue.h 2007-11-10 12:04:57 UTC (rev 975)
+++ trunk/zee/src/clue.h 2007-11-10 12:13:39 UTC (rev 976)
@@ -77,4 +77,4 @@
/* Run some Lua code `code'. */
#define CLUE_DO(L, code) \
- (luaL_loadstring(L, str) || lua_pcall(L, 0, 0, 0))
+ (luaL_loadstring(L, code) || lua_pcall(L, 0, 0, 0))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2007-11-10 12:05:01
|
Revision: 975
http://zee.svn.sourceforge.net/zee/?rev=975&view=rev
Author: rrt
Date: 2007-11-10 04:04:57 -0800 (Sat, 10 Nov 2007)
Log Message:
-----------
Release 3. Rename CLUE_EXPORT to CLUE_GET and CLUE_IMPORT to CLUE_SET
to be more similar to the Lua API.
Make CLUE_DO not put return values on the stack.
Modified Paths:
--------------
trunk/zee/src/clue.h
Modified: trunk/zee/src/clue.h
===================================================================
--- trunk/zee/src/clue.h 2007-11-10 12:03:44 UTC (rev 974)
+++ trunk/zee/src/clue.h 2007-11-10 12:04:57 UTC (rev 975)
@@ -1,6 +1,6 @@
/* Clue: minimal C-Lua integration
- release 2
+ release 3
Copyright (c) 2007 Reuben Thomas.
@@ -54,9 +54,8 @@
#define CLUE_CLOSE(L) \
lua_close(L)
-/* Import a C value `cexp' into a Lua global `lvar', as Lua type
- `lty'. */
-#define CLUE_IMPORT(L, cexp, lvar, lty) \
+/* Set a Lua variable `lvar' of type 'lty' to C value `cexp'. */
+#define CLUE_SET(L, lvar, lty, cexp) \
do { \
lua_checkstack(L, 2); \
lua_pushstring(L, #lvar); \
@@ -64,10 +63,10 @@
lua_rawset(L, LUA_GLOBALSINDEX); \
} while (0)
-/* Export a Lua global `lvar' of Lua whose value is of type `lty' to a
- C variable `cvar'. Exported strings should be copied if their
- value is required after further Clue calls. */
-#define CLUE_EXPORT(L, cvar, lvar, lty) \
+/* Read a value of type `lty' from Lua global `lvar' into C variable
+ `cvar'. Strings should be copied if their value is required after
+ further Clue calls. */
+#define CLUE_GET(L, lvar, lty, cvar) \
do { \
lua_checkstack(L, 1); \
lua_pushstring(L, #lvar); \
@@ -78,4 +77,4 @@
/* Run some Lua code `code'. */
#define CLUE_DO(L, code) \
- luaL_dostring(L, code)
+ (luaL_loadstring(L, str) || lua_pcall(L, 0, 0, 0))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2007-11-10 12:03:48
|
Revision: 974
http://zee.svn.sourceforge.net/zee/?rev=974&view=rev
Author: rrt
Date: 2007-11-10 04:03:44 -0800 (Sat, 10 Nov 2007)
Log Message:
-----------
Get Lua chordtostr working.
Modified Paths:
--------------
trunk/zee/src/keys.lua
Modified: trunk/zee/src/keys.lua
===================================================================
--- trunk/zee/src/keys.lua 2007-11-10 12:00:21 UTC (rev 973)
+++ trunk/zee/src/keys.lua 2007-11-10 12:03:44 UTC (rev 974)
@@ -18,15 +18,15 @@
-- Software Foundation, Fifth Floor, 51 Franklin Street, Boston, MA
-- 02111-1301, USA.
-keycode = {}
+keyname = {}
function X(key_sym, key_name, text_name, key_code)
- table.insert(keycode, key_sym)
+ keyname[key_code] = key_name
end
loadstring(key_tbl)()
-keyname = {}
+keycode = {}
function X(key_sym, key_name, text_name, key_code)
- table.insert(keycode, key_name)
+ keycode[key_name] = key_code
end
loadstring(key_tbl)()
@@ -35,24 +35,17 @@
local i
local s = ""
- if bit.band(key, KBD_CTRL) then
+ if bit.band(key, keycode["Ctrl-"]) then
s = s .. "Ctrl-"
end
- if bit.band(key, KBD_META) then
+ if bit.band(key, keycode["Alt-"]) then
s = s .. "Alt-"
end
- key = bit.band(key, bit.bnot(bit.bor(KBD_CTRL, KBD_META)))
+ key = bit.band(key, bit.bnot(bit.bor(keycode["Ctrl-"], keycode["Alt-"])))
- local found = false
- for i, v in ipairs(keycode) do
- if v == key then
- s = s .. keyname[i]
- found = true
- break
- end
- end
-
- if not found then
+ if keyname[key] then
+ s = s .. keyname[key]
+ else
if string.match(string.char(key), "%C") then
s = s .. string.char(key);
else
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2007-11-10 12:00:20
|
Revision: 973
http://zee.svn.sourceforge.net/zee/?rev=973&view=rev
Author: rrt
Date: 2007-11-10 04:00:21 -0800 (Sat, 10 Nov 2007)
Log Message:
-----------
Use key_code rather than key_sym to populate the keycode array, which
is the same (at the moment) but more logical.
Modified Paths:
--------------
trunk/zee/src/keys.c
Modified: trunk/zee/src/keys.c
===================================================================
--- trunk/zee/src/keys.c 2007-11-10 11:53:37 UTC (rev 972)
+++ trunk/zee/src/keys.c 2007-11-10 12:00:21 UTC (rev 973)
@@ -86,7 +86,7 @@
static size_t keycode[] = {
#define X(key_sym, key_name, text_name, key_code) \
- key_sym,
+ key_code,
#include "tbl_keys.h"
#undef X
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2007-11-10 11:53:36
|
Revision: 972
http://zee.svn.sourceforge.net/zee/?rev=972&view=rev
Author: rrt
Date: 2007-11-10 03:53:37 -0800 (Sat, 10 Nov 2007)
Log Message:
-----------
Remove debugging message.
Modified Paths:
--------------
trunk/zee/src/help.c
Modified: trunk/zee/src/help.c
===================================================================
--- trunk/zee/src/help.c 2007-11-09 19:38:23 UTC (rev 971)
+++ trunk/zee/src/help.c 2007-11-10 11:53:37 UTC (rev 972)
@@ -33,7 +33,7 @@
Show the version in the minibuffer.\
")
{
- fprintf(stderr, "%d\n", CLUE_DO(L, "s = command_to_binding(\"file_quit\")"));
+ (void)CLUE_DO(L, "s = command_to_binding(\"file_quit\")");
const char *quitstr;
CLUE_EXPORT(L, quitstr, s, string);
if (quitstr == NULL)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2007-11-09 19:38:19
|
Revision: 971
http://zee.svn.sourceforge.net/zee/?rev=971&view=rev
Author: rrt
Date: 2007-11-09 11:38:23 -0800 (Fri, 09 Nov 2007)
Log Message:
-----------
Fix loading keys list into Lua.
Modified Paths:
--------------
trunk/zee/src/keys.lua
trunk/zee/src/main.c
Modified: trunk/zee/src/keys.lua
===================================================================
--- trunk/zee/src/keys.lua 2007-11-09 19:38:05 UTC (rev 970)
+++ trunk/zee/src/keys.lua 2007-11-09 19:38:23 UTC (rev 971)
@@ -22,13 +22,13 @@
function X(key_sym, key_name, text_name, key_code)
table.insert(keycode, key_sym)
end
-eval(key_tbl)
+loadstring(key_tbl)()
keyname = {}
function X(key_sym, key_name, text_name, key_code)
table.insert(keycode, key_name)
end
-eval(key_tbl)
+loadstring(key_tbl)()
-- Convert a key chord into its ASCII representation
function chordtostr(key)
Modified: trunk/zee/src/main.c
===================================================================
--- trunk/zee/src/main.c 2007-11-09 19:38:05 UTC (rev 970)
+++ trunk/zee/src/main.c 2007-11-09 19:38:23 UTC (rev 971)
@@ -129,13 +129,9 @@
require(PKGDATADIR "/bind.lua");
require(PKGDATADIR "/completion.lua");
require(PKGDATADIR "/history.lua");
- fprintf(stderr, "loading key_tbl\n");
rblist key_tbl = file_read(rblist_from_string(PKGDATADIR "/tbl_keys.h"));
- fprintf(stderr, "importing key_tbl\n");
- CLUE_IMPORT(L, key_tbl, key_tbl, string);
- fprintf(stderr, "running key_tbl\n");
+ CLUE_IMPORT(L, rblist_to_string(key_tbl), key_tbl, string);
require(PKGDATADIR "/keys.lua");
- fprintf(stderr, "run key_tbl\n");
// FIXME: Load last for now because of its effect on the global environment
require(PKGDATADIR "/std.lua");
init_commands();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2007-11-09 19:38:02
|
Revision: 970
http://zee.svn.sourceforge.net/zee/?rev=970&view=rev
Author: rrt
Date: 2007-11-09 11:38:05 -0800 (Fri, 09 Nov 2007)
Log Message:
-----------
Print error message from Lua when require fails.
Modified Paths:
--------------
trunk/zee/src/lua.c
Modified: trunk/zee/src/lua.c
===================================================================
--- trunk/zee/src/lua.c 2007-11-09 19:11:59 UTC (rev 969)
+++ trunk/zee/src/lua.c 2007-11-09 19:38:05 UTC (rev 970)
@@ -126,7 +126,7 @@
void require(char *s)
{
if (luaL_dofile(L, s)) {
- fprintf(stderr, PACKAGE_NAME " is not properly installed: could not load file `%s'", s);
+ fprintf(stderr, PACKAGE_NAME " is not properly installed: could not load file `%s'\n%s\n", s, lua_tostring(L, -1));
die(1);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2007-11-09 19:11:59
|
Revision: 969
http://zee.svn.sourceforge.net/zee/?rev=969&view=rev
Author: rrt
Date: 2007-11-09 11:11:59 -0800 (Fri, 09 Nov 2007)
Log Message:
-----------
Write chordtostr in Lua.
Remove comments from tbl_keys.h so it can parse as C and Lua.
Add libtools files to ignore list.
Modified Paths:
--------------
trunk/zee/Makefile.am
trunk/zee/configure.ac
trunk/zee/src/Makefile.am
trunk/zee/src/main.c
trunk/zee/src/tbl_keys.h
Added Paths:
-----------
trunk/zee/src/keys.lua
Property Changed:
----------------
trunk/zee/
trunk/zee/src/
Property changes on: trunk/zee
___________________________________________________________________
Name: svn:ignore
- depcomp
install-sh
missing
configure
configure.lineno
autom4te.cache
stamp-h1
compile
aclocal.m4
config.log
config.status
config.status.lineno
config.h
config.h.in
Makefile
Makefile.in
zee*.tar.gz
gmon.out
+ depcomp
install-sh
missing
configure
configure.lineno
config.guess
config.sub
libtool
ltmain.sh
autom4te.cache
stamp-h1
compile
aclocal.m4
config.log
config.status
config.status.lineno
config.h
config.h.in
Makefile
Makefile.in
zee*.tar.gz
gmon.out
Modified: trunk/zee/Makefile.am
===================================================================
--- trunk/zee/Makefile.am 2007-11-09 19:02:14 UTC (rev 968)
+++ trunk/zee/Makefile.am 2007-11-09 19:11:59 UTC (rev 969)
@@ -1,5 +1,5 @@
## Process this file with automake to produce Makefile.in
-SUBDIRS = src
+SUBDIRS = bitlib src
dist_doc_DATA = AUTHORS COPYING INSTALL NEWS README THANKS
Modified: trunk/zee/configure.ac
===================================================================
--- trunk/zee/configure.ac 2007-11-09 19:02:14 UTC (rev 968)
+++ trunk/zee/configure.ac 2007-11-09 19:11:59 UTC (rev 969)
@@ -15,6 +15,7 @@
AM_PROG_CC_C_O
AC_REPLACE_FUNCS(getopt_long_only)
AC_HEADER_STDC
+AC_PROG_LIBTOOL
dnl ==================================================================
dnl Debugging
@@ -260,5 +261,6 @@
dnl Generate makefiles
dnl ==================================================================
+AC_CONFIG_SUBDIRS(bitlib)
AC_CONFIG_FILES(Makefile src/Makefile)
AC_OUTPUT
Property changes on: trunk/zee/src
___________________________________________________________________
Name: svn:ignore
- .deps
Makefile
Makefile.in
zee
paths.h
tbl_funcs.h
rblist
rbacc
mkfuncs.lua
mkvars.lua
mkopts.lua
tbl_funcs.lua
zee.info
texinfo.tex
zeerc
copyright.texi
keys.texi
funcs.texi
vars.texi
opts.texi
gmon.out
zee.aux
zee.fn
zee.vr
zee.cp
zee.dvi
zee.ky
zee.pg
zee.log
zee.tp
zee.toc
+ .deps
.libs
Makefile
Makefile.in
zee
paths.h
tbl_funcs.h
rblist
rbacc
mkfuncs.lua
mkvars.lua
mkopts.lua
tbl_funcs.lua
zee.info
texinfo.tex
zeerc
copyright.texi
keys.texi
funcs.texi
vars.texi
opts.texi
gmon.out
zee.aux
zee.fn
zee.vr
zee.cp
zee.dvi
zee.ky
zee.pg
zee.log
zee.tp
zee.toc
Modified: trunk/zee/src/Makefile.am
===================================================================
--- trunk/zee/src/Makefile.am 2007-11-09 19:02:14 UTC (rev 968)
+++ trunk/zee/src/Makefile.am 2007-11-09 19:11:59 UTC (rev 969)
@@ -17,8 +17,11 @@
lib.lua \
tbl_vars.lua \
tbl_funcs.lua \
+ tbl_keys.h \
+ bind.lua \
+ completion.lua \
history.lua \
- completion.lua \
+ keys.lua \
texinfo.lua
LUA_RUNTIME_EXTRA = std.lua
@@ -67,7 +70,7 @@
undo.c
zee_CPPFLAGS = -DPKGDATADIR="\"$(pkgdatadir)\"" -DSYSCONFDIR="\"$(sysconfdir)\""
-zee_LDADD = @LIBOBJS@
+zee_LDADD = @LIBOBJS@ ../bitlib/liblua-bit.la
LUA_BUILDTIME = mkfuncs.lua mkvars.lua mkopts.lua mkkeys.lua mkcopyright.lua
Added: trunk/zee/src/keys.lua
===================================================================
--- trunk/zee/src/keys.lua (rev 0)
+++ trunk/zee/src/keys.lua 2007-11-09 19:11:59 UTC (rev 969)
@@ -0,0 +1,64 @@
+-- Keyboard functions
+-- Copyright (c) 2007 Reuben Thomas. All rights reserved.
+--
+-- This file is part of Zee.
+--
+-- Zee is free software; you can redistribute it and/or modify it under
+-- the terms of the GNU General Public License as published by the Free
+-- Software Foundation; either version 2, or (at your option) any later
+-- version.
+--
+-- Zee 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 General Public License
+-- for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with Zee; see the file COPYING. If not, write to the Free
+-- Software Foundation, Fifth Floor, 51 Franklin Street, Boston, MA
+-- 02111-1301, USA.
+
+keycode = {}
+function X(key_sym, key_name, text_name, key_code)
+ table.insert(keycode, key_sym)
+end
+eval(key_tbl)
+
+keyname = {}
+function X(key_sym, key_name, text_name, key_code)
+ table.insert(keycode, key_name)
+end
+eval(key_tbl)
+
+-- Convert a key chord into its ASCII representation
+function chordtostr(key)
+ local i
+ local s = ""
+
+ if bit.band(key, KBD_CTRL) then
+ s = s .. "Ctrl-"
+ end
+ if bit.band(key, KBD_META) then
+ s = s .. "Alt-"
+ end
+ key = bit.band(key, bit.bnot(bit.bor(KBD_CTRL, KBD_META)))
+
+ local found = false
+ for i, v in ipairs(keycode) do
+ if v == key then
+ s = s .. keyname[i]
+ found = true
+ break
+ end
+ end
+
+ if not found then
+ if string.match(string.char(key), "%C") then
+ s = s .. string.char(key);
+ else
+ s = s .. string.format("<%x>", key);
+ end
+ end
+
+ return s
+end
Modified: trunk/zee/src/main.c
===================================================================
--- trunk/zee/src/main.c 2007-11-09 19:02:14 UTC (rev 968)
+++ trunk/zee/src/main.c 2007-11-09 19:11:59 UTC (rev 969)
@@ -118,14 +118,24 @@
#endif
CLUE_INIT(L);
+ luaopen_bit(L);
assert(L);
init_kill_ring();
+ // FIXME: Generate the list of files to load
require(PKGDATADIR "/lib.lua");
require(PKGDATADIR "/texinfo.lua");
require(PKGDATADIR "/tbl_vars.lua"); // FIXME: interpret the texinfo commands
require(PKGDATADIR "/tbl_funcs.lua");
+ require(PKGDATADIR "/bind.lua");
+ require(PKGDATADIR "/completion.lua");
require(PKGDATADIR "/history.lua");
- require(PKGDATADIR "/completion.lua");
+ fprintf(stderr, "loading key_tbl\n");
+ rblist key_tbl = file_read(rblist_from_string(PKGDATADIR "/tbl_keys.h"));
+ fprintf(stderr, "importing key_tbl\n");
+ CLUE_IMPORT(L, key_tbl, key_tbl, string);
+ fprintf(stderr, "running key_tbl\n");
+ require(PKGDATADIR "/keys.lua");
+ fprintf(stderr, "run key_tbl\n");
// FIXME: Load last for now because of its effect on the global environment
require(PKGDATADIR "/std.lua");
init_commands();
Modified: trunk/zee/src/tbl_keys.h
===================================================================
--- trunk/zee/src/tbl_keys.h 2007-11-09 19:02:14 UTC (rev 968)
+++ trunk/zee/src/tbl_keys.h 2007-11-09 19:11:59 UTC (rev 969)
@@ -1,52 +1,30 @@
-/* Table of named keys
- Copyright (c) 2007 Reuben Thomas. All rights reserved.
-
- This file is part of Zee.
-
- Zee is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 2, or (at your option) any later
- version.
-
- Zee 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 General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License
- along with Zee; see the file COPYING. If not, write to the Free
- Software Foundation, Fifth Floor, 51 Franklin Street, Boston, MA
- 02111-1301, USA. */
-
-// Order: symbol, text abbreviation, text name, Zee code
-
-X(KBD_CTRL, "Ctrl-", "Control", 01000)
-X(KBD_META, "Alt-", "Alt", 02000)
+X(KBD_CTRL, "Ctrl-", "Control", 0x400)
+X(KBD_META, "Alt-", "Alt", 0x800)
X(KBD_SPC, "SPC", "Space", (' '))
-X(KBD_TAB, "TAB", "Tab", 00402)
-X(KBD_RET, "RET", "Return", 00403)
-X(KBD_PGUP, "PGUP", "PageUp", 00404)
-X(KBD_PGDN, "PGDN", "PageDown", 00405)
-X(KBD_HOME, "HOME", "Home", 00406)
-X(KBD_END, "END", "End", 00407)
-X(KBD_DEL, "DEL", "Delete", 00410)
-X(KBD_BS, "BS", "Backspace", 00411)
-X(KBD_INS, "INS", "Insert", 00412)
-X(KBD_LEFT, "LEFT", "Left", 00413)
-X(KBD_RIGHT, "RIGHT", "Right", 00414)
-X(KBD_UP, "UP", "Up", 00415)
-X(KBD_DOWN, "DOWN", "Down", 00416)
-X(KBD_SLEFT, "S-LEFT", "Shift-Left", 00417)
-X(KBD_SRIGHT, "S-RIGHT", "Shift-Right", 00420)
-X(KBD_F1, "F1", "F1", 00421)
-X(KBD_F2, "F2", "F2", 00422)
-X(KBD_F3, "F3", "F3", 00423)
-X(KBD_F4, "F4", "F4", 00424)
-X(KBD_F5, "F5", "F5", 00425)
-X(KBD_F6, "F6", "F6", 00426)
-X(KBD_F7, "F7", "F7", 00427)
-X(KBD_F8, "F8", "F8", 00430)
-X(KBD_F9, "F9", "F9", 00431)
-X(KBD_F10, "F10", "F10", 00432)
-X(KBD_F11, "F11", "F11", 00433)
-X(KBD_F12, "F12", "F12", 00434)
+X(KBD_TAB, "TAB", "Tab", 0x102)
+X(KBD_RET, "RET", "Return", 0x103)
+X(KBD_PGUP, "PGUP", "PageUp", 0x104)
+X(KBD_PGDN, "PGDN", "PageDown", 0x105)
+X(KBD_HOME, "HOME", "Home", 0x106)
+X(KBD_END, "END", "End", 0x107)
+X(KBD_DEL, "DEL", "Delete", 0x108)
+X(KBD_BS, "BS", "Backspace", 0x109)
+X(KBD_INS, "INS", "Insert", 0x10a)
+X(KBD_LEFT, "LEFT", "Left", 0x10b)
+X(KBD_RIGHT, "RIGHT", "Right", 0x10c)
+X(KBD_UP, "UP", "Up", 0x10d)
+X(KBD_DOWN, "DOWN", "Down", 0x10e)
+X(KBD_SLEFT, "S-LEFT", "Shift-Left", 0x10f)
+X(KBD_SRIGHT, "S-RIGHT", "Shift-Right", 0x110)
+X(KBD_F1, "F1", "F1", 0x111)
+X(KBD_F2, "F2", "F2", 0x112)
+X(KBD_F3, "F3", "F3", 0x113)
+X(KBD_F4, "F4", "F4", 0x114)
+X(KBD_F5, "F5", "F5", 0x115)
+X(KBD_F6, "F6", "F6", 0x116)
+X(KBD_F7, "F7", "F7", 0x117)
+X(KBD_F8, "F8", "F8", 0x118)
+X(KBD_F9, "F9", "F9", 0x119)
+X(KBD_F10, "F10", "F10", 0x11a)
+X(KBD_F11, "F11", "F11", 0x11b)
+X(KBD_F12, "F12", "F12", 0x11c)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rr...@us...> - 2007-11-09 19:02:11
|
Revision: 968
http://zee.svn.sourceforge.net/zee/?rev=968&view=rev
Author: rrt
Date: 2007-11-09 11:02:14 -0800 (Fri, 09 Nov 2007)
Log Message:
-----------
Add braces.
Modified Paths:
--------------
trunk/zee/src/file.c
Modified: trunk/zee/src/file.c
===================================================================
--- trunk/zee/src/file.c 2007-11-09 19:01:54 UTC (rev 967)
+++ trunk/zee/src/file.c 2007-11-09 19:02:14 UTC (rev 968)
@@ -56,9 +56,9 @@
rblist file_read(rblist filename)
{
FILE *fp;
- if ((fp = fopen(rblist_to_string(filename), "r")) == NULL)
+ if ((fp = fopen(rblist_to_string(filename), "r")) == NULL) {
return NULL;
- else {
+ } else {
rbacc rba = rbacc_add_file(rbacc_new(), fp);
fclose(fp);
return rbacc_to_rblist(rba);
@@ -75,11 +75,12 @@
buf->filename = filename;
rblist rbl;
- if ((rbl = file_read(buf->filename)) != NULL)
+ if ((rbl = file_read(buf->filename)) != NULL) {
// Add lines to buffer
buf->lines = rbl;
- else if (errno != ENOENT)
+ } else if (errno != ENOENT) {
buf->flags |= BFLAG_READONLY;
+ }
}
/*
@@ -95,8 +96,9 @@
assert(bp);
- if ((fp = fopen(rblist_to_string(filename), "w")) == NULL)
+ if ((fp = fopen(rblist_to_string(filename), "w")) == NULL) {
return false;
+ }
// Save all the lines.
if (fwrite(rblist_to_string(buf->lines), sizeof(char), len, fp) < len) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|