1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-25 18:46:30 -05:00

Compare commits

..

3 Commits

6 changed files with 40 additions and 65 deletions

4
.gitignore vendored
View File

@ -1,2 +1,4 @@
em
depend.mak
ue
*.o
*.exe

View File

@ -1,5 +1,5 @@
# Makefile -- uEMACS
# Copyright (c) 2014-2021 Renaud Fivet
# Makefile -- µEMACS
# Copyright © 2013-2021 Renaud Fivet
# Make the build silent by default
V =
@ -25,7 +25,7 @@ WARNINGS=-pedantic -Wall -Wextra -Wstrict-prototypes -Wno-unused-parameter
CFLAGS=-O2 $(WARNINGS)
LDFLAGS=-s
LIBS=-lcurses
DEFINES=-DAUTOCONF -DPROGRAM=$(PROGRAM)
DEFINES=-DAUTOCONF -DPROGRAM=$(PROGRAM) # -DNDEBUG
ifeq ($(uname_S),Linux)
DEFINES += -DPOSIX -DUSG
else ifeq ($(uname_S),CYGWIN)
@ -38,18 +38,6 @@ else
$(error $(uname_S) needs configuration)
endif
#ifeq ($(uname_S),FreeBSD)
# DEFINES=-DAUTOCONF -DPOSIX -DSYSV -D_FREEBSD_C_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -D_XOPEN_SOURCE=600
#endif
#ifeq ($(uname_S),Darwin)
# DEFINES=-DAUTOCONF -DPOSIX -DSYSV -D_DARWIN_C_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -D_XOPEN_SOURCE=600
#endif
#LIBS=-ltermcap # BSD
#LIBS=-lcurses # SYSV
#LIBS=-ltermlib
#LIBS=-L/usr/lib/termcap -ltermcap
LFLAGS=-hbx
BINDIR=/usr/bin
LIBDIR=/usr/lib
@ -60,15 +48,9 @@ $(PROGRAM): $(OBJS)
$(E) " LINK " $@
$(Q) $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
SPARSE=sparse
SPARSE_FLAGS=-D__LITTLE_ENDIAN__ -D__x86_64__ -D__linux__ -D__unix__
sparse:
$(SPARSE) $(SPARSE_FLAGS) $(DEFINES) $(SRCS)
clean:
$(E) " CLEAN"
$(Q) rm -f $(PROGRAM) core lintout makeout tags *.o
$(Q) rm -f $(PROGRAM) depend.mak *.o
install: $(PROGRAM)
strip $(PROGRAM)
@ -78,22 +60,6 @@ install: $(PROGRAM)
chmod 755 ${BINDIR}/$(PROGRAM)
chmod 644 ${LIBDIR}/emacs.hlp ${LIBDIR}/.emacsrc
lint: ${SRC}
@rm -f lintout
lint ${LFLAGS} ${SRC} >lintout
cat lintout
splint:
splint -weak $(DEFINES) $(SRCS) -booltype boolean -booltrue TRUE -boolfalse FALSE +posixlib +matchanyintegral
errs:
@rm -f makeout
make $(PROGRAM) >makeout 2>&1
tags: ${SRC}
@rm -f tags
ctags ${SRC}
.c.o:
$(E) " CC " $@
$(Q) ${CC} ${CFLAGS} ${DEFINES} -c $*.c

18
bind.c
View File

@ -448,22 +448,19 @@ static const char *getfname( unsigned keycode, const char *failmsg) {
* String key name TO Command Key
*
* char *keyname; name of key to translate to Command key form
* fmt: [M-][^X][^][FN]X
* fmt: [M-|^X][^][FN]X
* returns ~0 on invalid sequence
*/
static unsigned int stock( char *keyname) {
/* parse it up */
unsigned c = 0 ;
/* first, the META prefix */
/* first, the prefix META or ^X */
if( *keyname == 'M' && keyname[ 1] == '-') {
c = META ;
keyname += 2 ;
}
/* control-x prefix */
if( *keyname == '^' && keyname[ 1] == 'X') {
c |= CTLX ;
} else if( *keyname == '^' && keyname[ 1] == 'X') {
c = CTLX ;
keyname += 2 ;
}
@ -487,10 +484,9 @@ static unsigned int stock( char *keyname) {
if( *keyname < 32 || *keyname == 0x7F) {
c |= CTRL ;
*keyname ^= 0x40 ;
}
/* make sure we are not lower case (not with function keys) */
if( *keyname >= 'a' && *keyname <= 'z' && !(c & SPEC))
} else if( c && !(c & SPEC)
&& *keyname >= 'a' && *keyname <= 'z')
/* make sure we are not lower case (not with function keys) */
*keyname -= 32 ;
/* the final sequence... */

36
input.c
View File

@ -371,11 +371,10 @@ int get1key( void) {
}
/* GETCMD: Get a command from the keyboard. Process all applicable prefix
keys. Handle alted and controlled FNx, not shifted. Allow double
prefix M-^X.
keys. Handle alted and controlled FNx, not shifted.
*/
int getcmd( void) {
int cmask = 0 ; /* prefixes M- & ^X */
int prefix = 0 ; /* prefixes M- or ^X */
int keyread[ STACKSIZE] ; /* room to process sequences like ^[[24;2~ */
int *kptr = keyread ;
int c ;
@ -390,7 +389,7 @@ int getcmd( void) {
if( c == 'O') { /* F1 .. F4 */
c = *(kptr++) = get1key() ;
if( c >= 'P' && c <= 'S')
return c | SPEC | cmask ;
return c | SPEC | prefix ;
} else if( c == '[') {
int v1, v ; /* ^[[v1;v~ or ^[[v~ */
@ -398,14 +397,17 @@ int getcmd( void) {
v1 = v = 0 ;
while( kptr < &keyread[ STACKSIZE]) {
c = *(kptr++) = get1key() ;
if( (c == '~') || (c >= 'A' && c <= 'Z')) {
if( (c == '~')
|| (c >= 'A' && c <= 'Z')
|| (c >= 'a' && c <= 'z')) {
/* Found end of sequence */
int mask = prefix ;
if( v1) { /* Handle ALT/CTL, not SHFT */
if( (v - 1) & 4)
cmask |= CTRL ;
if( (v - 1) & 2)
cmask |= META ;
mask = META ;
if( (v - 1) & 4)
mask |= CTRL ;
v = v1 ;
}
@ -417,7 +419,7 @@ int getcmd( void) {
break ;
}
return c | SPEC | cmask ;
return c | SPEC | mask ;
} else if( c == ';') { /* Start of SHFT/ALT/CTL state */
v1 = v ;
v = 0 ;
@ -433,20 +435,24 @@ int getcmd( void) {
KPUSH( *(--kptr)) ;
c = get1key() ;
}
} else
kptr-- ;
if( c == metac) {
cmask |= META ;
prefix = META ;
} else if( c == ctlxc) {
cmask |= CTLX ;
if( prefix)
break ; /* ^X^X or M-^X */
else
prefix = CTLX ;
} else
break ;
}
if( cmask && islower( c))
if( prefix && islower( c))
c = flipcase( c) ;
return c | cmask ;
return c | prefix ;
}
/* A more generalized prompt/reply function allowing the caller

View File

@ -9,6 +9,8 @@ set %D3 0
set %D4 -1
set %D5 0
select-buffer maze
# draw the maze layout
$curwidth insert-string " "
newline
@ -98,3 +100,5 @@ write-message $line
set $curline 3
set $curcol 1
set $curchar 32
unmark-buffer

View File

@ -1,4 +1,5 @@
# Visualize Screen Dimensions
select-buffer screensize
insert-string &cat $curwidth &cat "x" $pagelen
insert-string &rig "---------+" &sub 10 $curcol
&sub &div $curwidth 10 1 insert-string "---------+"