anon 10 months ago
parent
commit
a7331159b8
10 changed files with 96 additions and 66 deletions
  1. +11
    -10
      Makefile
  2. +14
    -1
      README.md
  3. +0
    -44
      src/constants.h
  4. +6
    -3
      src/display.c
  5. +1
    -1
      src/global.h
  6. +4
    -6
      src/input.c
  7. +53
    -0
      src/keys.h
  8. +1
    -1
      src/main.c
  9. +5
    -0
      src/readline.c
  10. +1
    -0
      src/refsfound.c

+ 11
- 10
Makefile View File

@@ -1,4 +1,5 @@
DEBUG:=1
GCC:=0

CC=gcc
CFLAGS:=-Wall -Wextra -Wpedantic
@@ -6,6 +7,16 @@ CPPFLAGS:=${shell pkg-config --cflags ncurses readline}
LDLIBS=-I ${CHDRD} ${shell pkg-config --libs ncurses readline}
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/
LEXF:=$(shell find ${LEXD} -iname '*.l')
GENLEX:=$(subst .l,.c,${LEXF})
@@ -22,16 +33,6 @@ CHDR:=$(addsuffix .gch,$(subst ${HDRD},${CHDRD},${HDR}))

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}
${LINK.c} ${OBJ} -o ${OUTPUT} ${LDLIBS}



+ 14
- 1
README.md View File

@@ -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*/
## To the code
+ 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
+ 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
+ replaced repeated inline #ifdef KEY_\*-s with guaranteed definitions
+ 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
+ lineflagafterfile is stupid
+ 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
+ Changing text double frees:


+ 0
- 44
src/constants.h View File

@@ -57,9 +57,6 @@
this macro will always be in a statement by itself */
#define skiprefchar() if (*(++blockp + 1) == '\0') (void) read_block()

#ifndef ESC
# define ESC '\033' /* escape character */
#endif
#define DEL '\177' /* delete character */
#define DUMMYCHAR ' ' /* use space as a dummy character */
#define MSGLEN ((PATLEN) + 80) /* displayed message length */
@@ -115,46 +112,5 @@
#define O_TEXT 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 */

+ 6
- 3
src/display.c View File

@@ -284,8 +284,6 @@ static inline void display_results(){
char function[PATLEN + 1]; /* function name */
char linenum[NUMLEN + 1]; /* line number */

werase(wresult);

if (totallines == 0) {
/* if no references were found */
/* redisplay the last message */
@@ -337,7 +335,11 @@ static inline void display_results(){
srctxtw -= numlen+1;

/* 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
there is no more room */
@@ -510,6 +512,7 @@ display(void)

if(window_change){
if(window_change == CH_HELP){
werase(whelp);
display_help();
/* Do not display over the help msg and */
/* rely on display_help() setting CH_ALL */


+ 1
- 1
src/global.h View File

@@ -244,7 +244,7 @@ extern int current_page;
void verswp_field(void);
void horswp_field(void);
bool interpret(int c); // XXX: probably rename
int handle_input(const char c);
int handle_input(const int c);
int dispchar2int(const char c);

long seekpage(size_t i);


+ 4
- 6
src/input.c View File

@@ -36,18 +36,16 @@
*/

#include "global.h"
#if defined(USE_NCURSES) && !defined(RENAMED_NCURSES)
#include <ncurses.h>
#else
#include <curses.h>
#endif
#include <setjmp.h> /* jmp_buf */
#include <stdlib.h>
#include <errno.h>
#if HAVE_SYS_TERMIOS_H
#include <sys/termios.h>
# include <sys/termios.h>
#endif

#include "keys.h"

bool do_press_any_key = false;

static jmp_buf env; /* setjmp/longjmp buffer */
@@ -536,7 +534,7 @@ extern const void const* wresult;
extern const void const* const* current_window;

int
handle_input(const char c){
handle_input(const int c){
/* - was wating for any input - */
if(do_press_any_key){
do_press_any_key = false;


+ 53
- 0
src/keys.h View 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*/

+ 1
- 1
src/main.c View File

@@ -356,7 +356,7 @@ static inline void linemode_event_loop(void){
static inline void screenmode_event_loop(void){
for (;;) {
display();
handle_input(getch());
handle_input(wgetch(stdscr)); // NOTE: getch() does not return key codes
}
}



+ 5
- 0
src/readline.c View File

@@ -36,7 +36,12 @@ static void redisplay_function(){
static void callback_handler(char* line){
if(!line){ return; }
strncpy(input_line, line, PATLEN);

search();

curdispline = 0;
PCS_reset();
current_page = 0;
}

static int interpret_break(){


+ 1
- 0
src/refsfound.c View File

@@ -18,6 +18,7 @@ long seekpage(size_t i){
while(PCS_top < i){
const char c = getc(*hto_page);
if(c == '\n'){ ++lc; }
if(c == EOF){ return -1; }
if(lc == mdisprefs){
PCS_pos[++PCS_top] = ftell(*hto_page);
}


Loading…
Cancel
Save