.
This commit is contained in:
parent
6eda9b632c
commit
a7331159b8
21
Makefile
21
Makefile
@ -1,4 +1,5 @@
|
|||||||
DEBUG:=1
|
DEBUG:=1
|
||||||
|
GCC:=0
|
||||||
|
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS:=-Wall -Wextra -Wpedantic
|
CFLAGS:=-Wall -Wextra -Wpedantic
|
||||||
@ -6,6 +7,16 @@ CPPFLAGS:=${shell pkg-config --cflags ncurses readline}
|
|||||||
LDLIBS=-I ${CHDRD} ${shell pkg-config --libs ncurses readline}
|
LDLIBS=-I ${CHDRD} ${shell pkg-config --libs ncurses readline}
|
||||||
LEX:=flex
|
LEX:=flex
|
||||||
|
|
||||||
|
ifeq (${DEBUG},1)
|
||||||
|
CFLAGS += -O0 -ggdb
|
||||||
|
else
|
||||||
|
CFLAGS += -O3 -flto=auto -fomit-frame-pointer
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef SAN
|
||||||
|
CFLAGS += -fsanitize=${SAN}
|
||||||
|
endif
|
||||||
|
|
||||||
LEXD:=src/
|
LEXD:=src/
|
||||||
LEXF:=$(shell find ${LEXD} -iname '*.l')
|
LEXF:=$(shell find ${LEXD} -iname '*.l')
|
||||||
GENLEX:=$(subst .l,.c,${LEXF})
|
GENLEX:=$(subst .l,.c,${LEXF})
|
||||||
@ -22,16 +33,6 @@ CHDR:=$(addsuffix .gch,$(subst ${HDRD},${CHDRD},${HDR}))
|
|||||||
|
|
||||||
OUTPUT:=csope
|
OUTPUT:=csope
|
||||||
|
|
||||||
ifeq (${DEBUG},1)
|
|
||||||
CFLAGS += -O0 -ggdb
|
|
||||||
else
|
|
||||||
CFLAGS += -O3 -flto=auto -fomit-frame-pointer
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef SAN
|
|
||||||
CFLAGS += -fsanitize=${SAN}
|
|
||||||
endif
|
|
||||||
|
|
||||||
main: ${CHDR} ${OBJ}
|
main: ${CHDR} ${OBJ}
|
||||||
${LINK.c} ${OBJ} -o ${OUTPUT} ${LDLIBS}
|
${LINK.c} ${OBJ} -o ${OUTPUT} ${LDLIBS}
|
||||||
|
|
||||||
|
15
README.md
15
README.md
@ -39,8 +39,9 @@ fixing it would have been a lost cause, if not for Cscope itself. Well, Csope no
|
|||||||
+ GNU Readline integration (ie. VI/EMACS mode, command history) /*pending*/
|
+ GNU Readline integration (ie. VI/EMACS mode, command history) /*pending*/
|
||||||
## To the code
|
## To the code
|
||||||
+ nuked autoconf, replaced with single Makefile
|
+ nuked autoconf, replaced with single Makefile
|
||||||
+ removed "scanner.l" which seems to be an anchient version (and redundant copy) of "fscanner.l" forgotten by all
|
+ reorganized main()
|
||||||
+ encapsulated changes to the TUI into display.c
|
+ encapsulated changes to the TUI into display.c
|
||||||
|
+ removed "scanner.l" which seems to be an anchient version (and redundant copy) of "fscanner.l" forgotten by all
|
||||||
+ removed macro hell put in place to allow compiling on a dead badger
|
+ removed macro hell put in place to allow compiling on a dead badger
|
||||||
+ replaced repeated inline #ifdef KEY_\*-s with guaranteed definitions
|
+ replaced repeated inline #ifdef KEY_\*-s with guaranteed definitions
|
||||||
+ removed random commets giving tips for and refering to specific issues
|
+ removed random commets giving tips for and refering to specific issues
|
||||||
@ -66,6 +67,18 @@ fixing it would have been a lost cause, if not for Cscope itself. Well, Csope no
|
|||||||
+ Ordering function declarations in global.h by alpha order is not smart
|
+ Ordering function declarations in global.h by alpha order is not smart
|
||||||
+ lineflagafterfile is stupid
|
+ lineflagafterfile is stupid
|
||||||
+ library.h...; "private library", in a program using 90 globals; ffs
|
+ library.h...; "private library", in a program using 90 globals; ffs
|
||||||
|
## Original
|
||||||
|
+ Display the current case mode (^C) onscreen
|
||||||
|
+ emacs like key bindings
|
||||||
|
^S for searching (^Y)
|
||||||
|
Up/dwn Arrow support Next/Prev field. ??
|
||||||
|
Inline editing on Input fields ( ??^B/^F )
|
||||||
|
^X^C to quit ( ^Q ??)
|
||||||
|
Pagdwn/PageUp/+/-
|
||||||
|
+ Same capabilities as interactive in non interactive (one shot) mode
|
||||||
|
+ Provide some how-do-I-use-this-thing doc.
|
||||||
|
+ Replace invlib.[ch] by real database. Failing that, at least sanitize it.
|
||||||
|
|
||||||
|
|
||||||
# BUGS
|
# BUGS
|
||||||
+ Changing text double frees:
|
+ Changing text double frees:
|
||||||
|
@ -57,9 +57,6 @@
|
|||||||
this macro will always be in a statement by itself */
|
this macro will always be in a statement by itself */
|
||||||
#define skiprefchar() if (*(++blockp + 1) == '\0') (void) read_block()
|
#define skiprefchar() if (*(++blockp + 1) == '\0') (void) read_block()
|
||||||
|
|
||||||
#ifndef ESC
|
|
||||||
# define ESC '\033' /* escape character */
|
|
||||||
#endif
|
|
||||||
#define DEL '\177' /* delete character */
|
#define DEL '\177' /* delete character */
|
||||||
#define DUMMYCHAR ' ' /* use space as a dummy character */
|
#define DUMMYCHAR ' ' /* use space as a dummy character */
|
||||||
#define MSGLEN ((PATLEN) + 80) /* displayed message length */
|
#define MSGLEN ((PATLEN) + 80) /* displayed message length */
|
||||||
@ -115,46 +112,5 @@
|
|||||||
#define O_TEXT 0x00
|
#define O_TEXT 0x00
|
||||||
#define O_BINARY 0x00
|
#define O_BINARY 0x00
|
||||||
|
|
||||||
/* Key macros */
|
|
||||||
/* These macros are not guaranteed to be defined,
|
|
||||||
* however we wish to test for these anyways while
|
|
||||||
* interpretting user commands.
|
|
||||||
* Input values are guaranteed to be postive,
|
|
||||||
* so setting them to -1 means the test always just silently fail,
|
|
||||||
* but compile when the they are not supported means of input.
|
|
||||||
*/
|
|
||||||
#ifndef KEY_DOWN
|
|
||||||
# define KEY_DOWN KEY_UNDEF_BASE-1
|
|
||||||
#endif
|
|
||||||
#ifndef KEY_UP
|
|
||||||
# define KEY_UP KEY_UNDEF_BASE-2
|
|
||||||
#endif
|
|
||||||
#ifndef KEY_LEFT
|
|
||||||
# define KEY_LEFT KEY_UNDEF_BASE-3
|
|
||||||
#endif
|
|
||||||
#ifndef KEY_RIGHT
|
|
||||||
# define KEY_RIGHT KEY_UNDEF_BASE-4
|
|
||||||
#endif
|
|
||||||
#ifndef KEY_HOME
|
|
||||||
# define KEY_HOME _KEY_UNDEF_BASE-5
|
|
||||||
#endif
|
|
||||||
#ifndef KEY_LL
|
|
||||||
# define KEY_LL KEY_UNDEF_BASE-6
|
|
||||||
#endif
|
|
||||||
#ifndef KEY_PPAGE
|
|
||||||
# define KEY_PPAGE KEY_UNDEF_BASE-7
|
|
||||||
#endif
|
|
||||||
#ifndef KEY_NPAGE
|
|
||||||
# define KEY_NPAGE KEY_UNDEF_BASE-8
|
|
||||||
#endif
|
|
||||||
#ifdef KEY_ENTER
|
|
||||||
# define KEY_ENTER KEY_UNDEF_BASE-9
|
|
||||||
#endif
|
|
||||||
#ifndef KEY_CLEAR
|
|
||||||
# define KEY_CLEAR KEY_UNDEF_BASE-10
|
|
||||||
#endif
|
|
||||||
#ifndef KEY_RESIZE
|
|
||||||
# define KEY_RESIZE KEY_UNDEF_BASE-11
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* CSCOPE_CONSTANTS_H */
|
#endif /* CSCOPE_CONSTANTS_H */
|
||||||
|
@ -284,8 +284,6 @@ static inline void display_results(){
|
|||||||
char function[PATLEN + 1]; /* function name */
|
char function[PATLEN + 1]; /* function name */
|
||||||
char linenum[NUMLEN + 1]; /* line number */
|
char linenum[NUMLEN + 1]; /* line number */
|
||||||
|
|
||||||
werase(wresult);
|
|
||||||
|
|
||||||
if (totallines == 0) {
|
if (totallines == 0) {
|
||||||
/* if no references were found */
|
/* if no references were found */
|
||||||
/* redisplay the last message */
|
/* redisplay the last message */
|
||||||
@ -337,7 +335,11 @@ static inline void display_results(){
|
|||||||
srctxtw -= numlen+1;
|
srctxtw -= numlen+1;
|
||||||
|
|
||||||
/* decide where to list from */
|
/* decide where to list from */
|
||||||
fseek(refsfound, seekpage(current_page), SEEK_SET);
|
/* XXX: this error handling migth be redundant*/
|
||||||
|
int seekerr;
|
||||||
|
do{
|
||||||
|
seekerr = seekpage(current_page);
|
||||||
|
}while(seekerr == -1 && current_page--);
|
||||||
|
|
||||||
/* until the max references have been displayed or
|
/* until the max references have been displayed or
|
||||||
there is no more room */
|
there is no more room */
|
||||||
@ -510,6 +512,7 @@ display(void)
|
|||||||
|
|
||||||
if(window_change){
|
if(window_change){
|
||||||
if(window_change == CH_HELP){
|
if(window_change == CH_HELP){
|
||||||
|
werase(whelp);
|
||||||
display_help();
|
display_help();
|
||||||
/* Do not display over the help msg and */
|
/* Do not display over the help msg and */
|
||||||
/* rely on display_help() setting CH_ALL */
|
/* rely on display_help() setting CH_ALL */
|
||||||
|
@ -244,7 +244,7 @@ extern int current_page;
|
|||||||
void verswp_field(void);
|
void verswp_field(void);
|
||||||
void horswp_field(void);
|
void horswp_field(void);
|
||||||
bool interpret(int c); // XXX: probably rename
|
bool interpret(int c); // XXX: probably rename
|
||||||
int handle_input(const char c);
|
int handle_input(const int c);
|
||||||
int dispchar2int(const char c);
|
int dispchar2int(const char c);
|
||||||
|
|
||||||
long seekpage(size_t i);
|
long seekpage(size_t i);
|
||||||
|
10
src/input.c
10
src/input.c
@ -36,18 +36,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#if defined(USE_NCURSES) && !defined(RENAMED_NCURSES)
|
|
||||||
#include <ncurses.h>
|
#include <ncurses.h>
|
||||||
#else
|
|
||||||
#include <curses.h>
|
|
||||||
#endif
|
|
||||||
#include <setjmp.h> /* jmp_buf */
|
#include <setjmp.h> /* jmp_buf */
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#if HAVE_SYS_TERMIOS_H
|
#if HAVE_SYS_TERMIOS_H
|
||||||
#include <sys/termios.h>
|
# include <sys/termios.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "keys.h"
|
||||||
|
|
||||||
bool do_press_any_key = false;
|
bool do_press_any_key = false;
|
||||||
|
|
||||||
static jmp_buf env; /* setjmp/longjmp buffer */
|
static jmp_buf env; /* setjmp/longjmp buffer */
|
||||||
@ -536,7 +534,7 @@ extern const void const* wresult;
|
|||||||
extern const void const* const* current_window;
|
extern const void const* const* current_window;
|
||||||
|
|
||||||
int
|
int
|
||||||
handle_input(const char c){
|
handle_input(const int c){
|
||||||
/* - was wating for any input - */
|
/* - was wating for any input - */
|
||||||
if(do_press_any_key){
|
if(do_press_any_key){
|
||||||
do_press_any_key = false;
|
do_press_any_key = false;
|
||||||
|
53
src/keys.h
Normal file
53
src/keys.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#ifndef KEYS_H
|
||||||
|
#define KEYS_H
|
||||||
|
|
||||||
|
/* Key macros */
|
||||||
|
/* These macros are not guaranteed to be defined,
|
||||||
|
* however we wish to test for these anyways while
|
||||||
|
* interpretting user commands.
|
||||||
|
* Input values are guaranteed to be postive,
|
||||||
|
* so setting them to -1 means the test always just silently fail,
|
||||||
|
* but compile when the they are not supported means of input.
|
||||||
|
*/
|
||||||
|
#define KEY_UNDEF_BASE 0
|
||||||
|
|
||||||
|
#ifndef KEY_DOWN
|
||||||
|
# define KEY_DOWN KEY_UNDEF_BASE-1
|
||||||
|
#endif
|
||||||
|
#ifndef KEY_UP
|
||||||
|
# define KEY_UP KEY_UNDEF_BASE-2
|
||||||
|
#endif
|
||||||
|
#ifndef KEY_LEFT
|
||||||
|
# define KEY_LEFT KEY_UNDEF_BASE-3
|
||||||
|
#endif
|
||||||
|
#ifndef KEY_RIGHT
|
||||||
|
# define KEY_RIGHT KEY_UNDEF_BASE-4
|
||||||
|
#endif
|
||||||
|
#ifndef KEY_HOME
|
||||||
|
# define KEY_HOME _KEY_UNDEF_BASE-5
|
||||||
|
#endif
|
||||||
|
#ifndef KEY_LL
|
||||||
|
# define KEY_LL KEY_UNDEF_BASE-6
|
||||||
|
#endif
|
||||||
|
#ifndef KEY_PPAGE
|
||||||
|
# define KEY_PPAGE KEY_UNDEF_BASE-7
|
||||||
|
#endif
|
||||||
|
#ifndef KEY_NPAGE
|
||||||
|
# define KEY_NPAGE KEY_UNDEF_BASE-8
|
||||||
|
#endif
|
||||||
|
#ifdef KEY_ENTER
|
||||||
|
# define KEY_ENTER KEY_UNDEF_BASE-9
|
||||||
|
#endif
|
||||||
|
#ifndef KEY_CLEAR
|
||||||
|
# define KEY_CLEAR KEY_UNDEF_BASE-10
|
||||||
|
#endif
|
||||||
|
#ifndef KEY_RESIZE
|
||||||
|
# define KEY_RESIZE KEY_UNDEF_BASE-11
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Always define ESC */
|
||||||
|
#ifndef ESC
|
||||||
|
# define ESC '\033' /* escape character */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* KEYS_H*/
|
@ -356,7 +356,7 @@ static inline void linemode_event_loop(void){
|
|||||||
static inline void screenmode_event_loop(void){
|
static inline void screenmode_event_loop(void){
|
||||||
for (;;) {
|
for (;;) {
|
||||||
display();
|
display();
|
||||||
handle_input(getch());
|
handle_input(wgetch(stdscr)); // NOTE: getch() does not return key codes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,12 @@ static void redisplay_function(){
|
|||||||
static void callback_handler(char* line){
|
static void callback_handler(char* line){
|
||||||
if(!line){ return; }
|
if(!line){ return; }
|
||||||
strncpy(input_line, line, PATLEN);
|
strncpy(input_line, line, PATLEN);
|
||||||
|
|
||||||
search();
|
search();
|
||||||
|
|
||||||
|
curdispline = 0;
|
||||||
|
PCS_reset();
|
||||||
|
current_page = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int interpret_break(){
|
static int interpret_break(){
|
||||||
|
@ -18,6 +18,7 @@ long seekpage(size_t i){
|
|||||||
while(PCS_top < i){
|
while(PCS_top < i){
|
||||||
const char c = getc(*hto_page);
|
const char c = getc(*hto_page);
|
||||||
if(c == '\n'){ ++lc; }
|
if(c == '\n'){ ++lc; }
|
||||||
|
if(c == EOF){ return -1; }
|
||||||
if(lc == mdisprefs){
|
if(lc == mdisprefs){
|
||||||
PCS_pos[++PCS_top] = ftell(*hto_page);
|
PCS_pos[++PCS_top] = ftell(*hto_page);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user