.
This commit is contained in:
parent
cf671948ea
commit
e19aaa09b9
@ -83,6 +83,8 @@ 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
|
||||
+ sort out the global hell
|
||||
+ changestring() forks sh to execute an ed script...
|
||||
## Original
|
||||
+ Display the current case mode (^C) onscreen
|
||||
+ emacs like key bindings
|
||||
|
@ -1,65 +0,0 @@
|
||||
/*===========================================================================
|
||||
Copyright (c) 1998-2000, The Santa Cruz Operation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
*Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
*Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
*Neither name of The Santa Cruz Operation nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
||||
IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT falseT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT falseT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGE.
|
||||
=========================================================================*/
|
||||
|
||||
/* get a file's base name from its path name */
|
||||
|
||||
#include "global.h"
|
||||
|
||||
const char *
|
||||
basename(char *path)
|
||||
{
|
||||
char *s;
|
||||
|
||||
if ((s = strrchr(path, '/')) != 0) {
|
||||
return(s + 1);
|
||||
}
|
||||
return(path);
|
||||
}
|
||||
|
||||
/* get the requested path components */
|
||||
char *
|
||||
pathcomponents(char *path, int components)
|
||||
{
|
||||
int i;
|
||||
char *s;
|
||||
|
||||
s = path + strlen(path) - 1;
|
||||
for (i = 0; i < components; ++i) {
|
||||
while (s > path && *--s != '/') {
|
||||
;
|
||||
}
|
||||
}
|
||||
if (s > path && *s == '/') {
|
||||
++s;
|
||||
}
|
||||
return(s);
|
||||
}
|
@ -74,7 +74,7 @@ static void scrollbar(MOUSE *p);
|
||||
static void
|
||||
clearprompt(void)
|
||||
{
|
||||
move(PRLINE, 0);
|
||||
wmove(winput, 0, 0);
|
||||
clrtoeol();
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ mark(unsigned int i)
|
||||
{
|
||||
unsigned int j;
|
||||
|
||||
j = i + topline - 1;
|
||||
//j = i + topline - 1;
|
||||
if (j < totallines) {
|
||||
move(displine[i], 1);
|
||||
|
||||
@ -139,38 +139,38 @@ mark(unsigned int i)
|
||||
static void
|
||||
scrollbar(MOUSE *p)
|
||||
{
|
||||
/* reposition list if it makes sense */
|
||||
if (totallines == 0) {
|
||||
return;
|
||||
}
|
||||
switch (p->percent) {
|
||||
///* reposition list if it makes sense */
|
||||
//if (totallines == 0) {
|
||||
//return;
|
||||
//}
|
||||
//switch (p->percent) {
|
||||
|
||||
case 101: /* scroll down one page */
|
||||
if (nextline + mdisprefs > totallines) {
|
||||
nextline = totallines - mdisprefs + 1;
|
||||
}
|
||||
break;
|
||||
//case 101: /* scroll down one page */
|
||||
//if (nextline + mdisprefs > totallines) {
|
||||
// nextline = totallines - mdisprefs + 1;
|
||||
//}
|
||||
//break;
|
||||
|
||||
case 102: /* scroll up one page */
|
||||
nextline = topline - mdisprefs;
|
||||
if (nextline < 1) {
|
||||
nextline = 1;
|
||||
}
|
||||
break;
|
||||
//case 102: /* scroll up one page */
|
||||
//nextline = topline - mdisprefs;
|
||||
//if (nextline < 1) {
|
||||
// nextline = 1;
|
||||
//}
|
||||
//break;
|
||||
|
||||
case 103: /* scroll down one line */
|
||||
nextline = topline + 1;
|
||||
break;
|
||||
//case 103: /* scroll down one line */
|
||||
//nextline = topline + 1;
|
||||
//break;
|
||||
|
||||
case 104: /* scroll up one line */
|
||||
if (topline > 1) {
|
||||
nextline = topline - 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
nextline = p->percent * totallines / 100;
|
||||
}
|
||||
//seekline(nextline);
|
||||
//case 104: /* scroll up one line */
|
||||
//if (topline > 1) {
|
||||
// nextline = topline - 1;
|
||||
//}
|
||||
//break;
|
||||
//default:
|
||||
//nextline = p->percent * totallines / 100;
|
||||
//}
|
||||
////seekline(nextline);
|
||||
}
|
||||
|
||||
|
||||
|
@ -79,21 +79,23 @@
|
||||
#define NUMLEN_STR STRINGIZE(NUMLEN)
|
||||
#define TEMPSTRING_LEN_STR STRINGIZE(TEMPSTRING_LEN)
|
||||
|
||||
/* screen lines */
|
||||
#define PRLINE (LINES - 1) /* input prompt line */
|
||||
|
||||
/* input fields (value matches field order on screen) */
|
||||
#define SYMBOL 0
|
||||
#define DEFINITION 1
|
||||
#define CALLEDBY 2
|
||||
#define CALLING 3
|
||||
#define STRING 4
|
||||
#define CHANGE 5
|
||||
#define REGEXP 6
|
||||
#define FILENAME 7
|
||||
#define INCLUDES 8
|
||||
enum {
|
||||
SYMBOL = 0,
|
||||
DEFINITION = 1,
|
||||
CALLEDBY = 2,
|
||||
CALLING = 3,
|
||||
STRING = 4,
|
||||
CHANGE = 5,
|
||||
REGEXP = 6,
|
||||
FILENAME = 7,
|
||||
INCLUDES = 8
|
||||
};
|
||||
#define FIELDS 10
|
||||
|
||||
// XXX
|
||||
#define bazdmeg 1
|
||||
|
||||
/* file open modes */
|
||||
#ifndef R_OK
|
||||
# define READ R_OK
|
||||
|
@ -49,18 +49,11 @@
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
|
||||
/* XXX */
|
||||
#define MSGLINE 0 /* message line */
|
||||
#define MSGCOL 0 /* message column */
|
||||
|
||||
static const char appendprompt[] = "Append to file: ";
|
||||
static const char pipeprompt[] = "Pipe to shell command: ";
|
||||
static const char readprompt[] = "Read from file: ";
|
||||
static const char toprompt[] = "To: ";
|
||||
static const char inputprompt[] = "$ ";
|
||||
|
||||
int subsystemlen = sizeof("Subsystem")-1; /* OGS subsystem name display field length */
|
||||
int booklen = sizeof("Book")-1; /* OGS book name display field length */
|
||||
int filelen = sizeof("File")-1; /* file name display field length */
|
||||
@ -72,14 +65,21 @@ unsigned int disprefs; /* displayed references */
|
||||
int field; /* input field */
|
||||
unsigned int mdisprefs; /* maximum displayed references */
|
||||
unsigned int nextline; /* next line to be shown */
|
||||
FILE *nonglobalrefs; /* non-global references file */
|
||||
unsigned int topline = 1; /* top line of page */
|
||||
static int bottomline; /* bottom line of page */
|
||||
long searchcount; /* count of files searched */
|
||||
unsigned int totallines; /* total reference lines */
|
||||
unsigned fldcolumn; /* input field column */
|
||||
unsigned int curdispline = 0;
|
||||
int current_page = 0;
|
||||
int input_mode = INPUT_NORMAL;
|
||||
const char* prompts[] = {
|
||||
[INPUT_NORMAL] = "$ ",
|
||||
[INPUT_APPEND] = "Append to file: ",
|
||||
[INPUT_PIPE] = "Pipe to shell command: ",
|
||||
[INPUT_READ] = "Read from file: ",
|
||||
[INPUT_CHANGE] = "To: "
|
||||
};
|
||||
|
||||
static unsigned int topline = 1; /* top line of page */
|
||||
|
||||
/* Selectable windows */
|
||||
WINDOW* winput;
|
||||
@ -124,17 +124,17 @@ struct { /* text of input fields */
|
||||
char *text2;
|
||||
} /* Paralel array to "field_searchers", indexed by "field" */
|
||||
fields[FIELDS + 1] = { /* samuel has a search that is not part of the cscope display */
|
||||
{"Find this", "C symbol", findsymbol},
|
||||
{"Find this", "global definition", finddef},
|
||||
{"Find", "functions called by this function", findcalledby},
|
||||
{"Find", "functions calling this function", findcalling},
|
||||
{"Find this", "text string", findstring},
|
||||
{"Change this", "text string", findstring},
|
||||
{"Find this", "egrep pattern", findregexp},
|
||||
{"Find this", "file", findfile},
|
||||
{"Find", "files #including this file", findinclude},
|
||||
{"Find", "assignments to this symbol", findassign},
|
||||
{"Find all", "function definitions", findallfcns}, /* samuel only */
|
||||
{"Find this", "C symbol"},
|
||||
{"Find this", "global definition"},
|
||||
{"Find", "functions called by this function"},
|
||||
{"Find", "functions calling this function"},
|
||||
{"Find this", "text string"},
|
||||
{"Change this", "text string"},
|
||||
{"Find this", "egrep pattern"},
|
||||
{"Find this", "file"},
|
||||
{"Find", "files #including this file"},
|
||||
{"Find", "assignments to this symbol"},
|
||||
{"Find all", "function definitions"}, /* samuel only */
|
||||
};
|
||||
|
||||
/* initialize display parameters */
|
||||
@ -270,7 +270,7 @@ static inline void display_mode(){
|
||||
}
|
||||
|
||||
static inline void display_command_field(){
|
||||
mvwaddstr(winput, 0, 0, inputprompt);
|
||||
mvwaddstr(winput, 0, 0, prompts[input_mode]);
|
||||
waddstr(winput, rl_line_buffer);
|
||||
}
|
||||
static inline void display_results(){
|
||||
@ -491,13 +491,13 @@ void display_cursor(void){
|
||||
int yoffset = 0, xoffset = 0;
|
||||
|
||||
if(current_window == &winput){
|
||||
xoffset = sizeof(inputprompt)-1 + rl_point;
|
||||
xoffset = strlen(prompts[input_mode]) + rl_point;
|
||||
}else if(current_window == &wmode){
|
||||
yoffset = field;
|
||||
}else if(current_window == &wresult){
|
||||
yoffset = displine[curdispline];
|
||||
}else{
|
||||
assert(("No window selected.", true));
|
||||
assert("No window selected.");
|
||||
}
|
||||
|
||||
wmove(*current_window, yoffset, xoffset);
|
||||
|
@ -79,6 +79,7 @@ static bool check_for_assignment(void);
|
||||
static void putpostingref(POSTING *p, char *pat);
|
||||
static void putref(int seemore, char *file, char *func);
|
||||
static void putsource(int seemore, FILE *output);
|
||||
static FILE *nonglobalrefs; /* non-global references file */
|
||||
|
||||
static sigjmp_buf env; /* setjmp/longjmp buffer */
|
||||
|
||||
@ -707,7 +708,7 @@ findinit(char *pattern)
|
||||
bool isregexp = false;
|
||||
int i;
|
||||
char *s;
|
||||
unsigned char c; /* HBB 20010427: changed uint to uchar */
|
||||
unsigned char c;
|
||||
|
||||
/* HBB: be nice: free regexp before allocating a new one */
|
||||
if(isregexp_valid == true)
|
||||
@ -722,7 +723,7 @@ findinit(char *pattern)
|
||||
*s = '\0';
|
||||
}
|
||||
|
||||
/* HBB 20020620: new: make sure pattern is lowercased. Curses
|
||||
/* Make sure pattern is lowercased. Curses
|
||||
* mode gets this right all on its own, but at least -L mode
|
||||
* doesn't */
|
||||
if (caseless == true) {
|
||||
|
13
src/global.h
13
src/global.h
@ -93,6 +93,13 @@ enum {
|
||||
CH_HELP = 0x0001 << 3, /* do NOT add to CH_ALL */
|
||||
CH_ALL = CH_RESULT | CH_INPUT | CH_MODE
|
||||
};
|
||||
enum {
|
||||
INPUT_NORMAL,
|
||||
INPUT_APPEND,
|
||||
INPUT_PIPE,
|
||||
INPUT_READ,
|
||||
INPUT_CHANGE
|
||||
};
|
||||
|
||||
#ifndef DFLT_INCDIR
|
||||
# define DFLT_INCDIR "/usr/include"
|
||||
@ -180,14 +187,11 @@ extern int numlen; /* line number display field length */
|
||||
extern int *displine; /* screen line of displayed reference */
|
||||
extern unsigned int disprefs; /* displayed references */
|
||||
extern int field; /* input field */
|
||||
extern unsigned fldcolumn; /* input field column */
|
||||
extern unsigned int mdisprefs; /* maximum displayed references */
|
||||
extern unsigned int nextline; /* next line to be shown */
|
||||
extern FILE *nonglobalrefs; /* non-global references file */
|
||||
extern unsigned int topline; /* top line of page */
|
||||
extern long searchcount; /* count of files searched */
|
||||
extern unsigned int totallines; /* total reference lines */
|
||||
extern int window_change;
|
||||
extern int window_change; /* bitmask type to mark which windows have to be rerendered by display() */
|
||||
|
||||
/* find.c global data */
|
||||
extern char block[]; /* cross-reference file block */
|
||||
@ -249,6 +253,7 @@ bool interpret(int c); // XXX: probably rename
|
||||
int handle_input(const int c);
|
||||
int dispchar2int(const char c);
|
||||
int process_mouse();
|
||||
extern int input_mode;
|
||||
|
||||
long seekpage(size_t i);
|
||||
long seekrelline(unsigned i);
|
||||
|
197
src/input.c
197
src/input.c
@ -57,8 +57,7 @@ static void catchint(int sig);
|
||||
/* catch the interrupt signal */
|
||||
|
||||
static void
|
||||
catchint(int sig)
|
||||
{
|
||||
catchint(int sig){
|
||||
UNUSED(sig);
|
||||
|
||||
signal(SIGINT, catchint);
|
||||
@ -74,8 +73,7 @@ myungetch(int c)
|
||||
|
||||
/* get a line from the terminal in non-canonical mode */
|
||||
int
|
||||
mygetline(char p[], char s[], unsigned size, int firstchar, bool iscaseless)
|
||||
{
|
||||
mygetline(char p[], char s[], unsigned size, int firstchar, bool iscaseless){
|
||||
int c;
|
||||
unsigned int i = 0, j;
|
||||
char *sright; /* substring to the right of the cursor */
|
||||
@ -207,8 +205,7 @@ mygetline(char p[], char s[], unsigned size, int firstchar, bool iscaseless)
|
||||
/* ask user to enter a character after reading the message */
|
||||
|
||||
void
|
||||
askforchar(void)
|
||||
{
|
||||
askforchar(void){
|
||||
addstr("Type any character to continue: ");
|
||||
getch();
|
||||
}
|
||||
@ -216,8 +213,7 @@ askforchar(void)
|
||||
/* ask user to press the RETURN key after reading the message */
|
||||
|
||||
void
|
||||
askforreturn(void)
|
||||
{
|
||||
askforreturn(void){
|
||||
fprintf(stderr, "Press the RETURN key to continue: ");
|
||||
getchar();
|
||||
/* HBB 20060419: message probably messed up the screen --- redraw */
|
||||
@ -229,8 +225,7 @@ askforreturn(void)
|
||||
/* expand the ~ and $ shell meta characters in a path */
|
||||
|
||||
void
|
||||
shellpath(char *out, int limit, char *in)
|
||||
{
|
||||
shellpath(char *out, int limit, char *in){
|
||||
char *lastchar;
|
||||
char *s, *v;
|
||||
|
||||
@ -449,7 +444,7 @@ global_input(const int c){
|
||||
break;
|
||||
case '<': /* read lines from a file */
|
||||
break; // XXX
|
||||
move(PRLINE, 0);
|
||||
//move(PRLINE, 0);
|
||||
//addstr(readprompt); // XXX fix
|
||||
//if (mygetline("", newpat, COLS - sizeof(readprompt), '\0', NO) > 0) {
|
||||
// clearprompt();
|
||||
@ -471,7 +466,7 @@ global_input(const int c){
|
||||
return 0;
|
||||
}
|
||||
/* get the shell command */
|
||||
move(PRLINE, 0);
|
||||
//move(PRLINE, 0);
|
||||
//addstr(pipeprompt);
|
||||
//if (mygetline("", newpat, COLS - sizeof(pipeprompt), '\0', NO) == 0) {
|
||||
// clearprompt();
|
||||
@ -530,10 +525,159 @@ global_input(const int c){
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern const void const* winput;
|
||||
extern const void const* wmode;
|
||||
extern const void const* wresult;
|
||||
extern const void const* const* current_window;
|
||||
extern const void *const winput;
|
||||
extern const void *const wmode;
|
||||
extern const void *const wresult;
|
||||
extern const void *const *const current_window;
|
||||
|
||||
static int changestring(bool *change);
|
||||
|
||||
static int
|
||||
change_input(const int c){
|
||||
MOUSE *p; /* mouse data */
|
||||
change = calloc(totallines, sizeof(*change));
|
||||
|
||||
switch(c){
|
||||
case '*': /* invert selection */
|
||||
for(int i = 0; topline + i < nextline; ++i){
|
||||
change[i] = !change[i];
|
||||
}
|
||||
break;
|
||||
case ctrl('A'): /* mark/unmark all lines */
|
||||
for(unsigned i = 0; i < totallines; ++i) {
|
||||
change[i] = !change[i];
|
||||
}
|
||||
/* show that all have been marked */
|
||||
seekline(totallines); // ?!
|
||||
break;
|
||||
case ctrl('X'): /* mouse selection */
|
||||
if ((p = getmouseaction(DUMMYCHAR)) == NULL) {
|
||||
break; /* unknown control sequence */
|
||||
}
|
||||
/* if the button number is a scrollbar tag */
|
||||
if (p->button == '0') {
|
||||
scrollbar(p);
|
||||
break;
|
||||
}
|
||||
/* find the selected line */
|
||||
/* NOTE: the selection is forced into range */
|
||||
{
|
||||
int i;
|
||||
for(i = disprefs - 1; i > 0; --i) {
|
||||
if (p->y1 >= displine[i]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
change[i] = !change[i];
|
||||
}
|
||||
break;
|
||||
case ctrl('D'):
|
||||
changestring(change);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
/* if a line was selected */
|
||||
const int cc = dispchar2int(c);
|
||||
if(cc != -1){
|
||||
change[cc] = !change[cc];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
changestring(bool *change){
|
||||
char newfile[PATHLEN + 1]; /* new file name */
|
||||
char oldfile[PATHLEN + 1]; /* old file name */
|
||||
char linenum[NUMLEN + 1]; /* file line number */
|
||||
char msg[MSGLEN + 1]; /* message */
|
||||
FILE *script; /* shell script file */
|
||||
bool anymarked = false; /* any line marked */
|
||||
|
||||
/* open the temporary file */
|
||||
if((script = myfopen(temp2, "w")) == NULL) {
|
||||
cannotopen(temp2);
|
||||
return(false);
|
||||
}
|
||||
|
||||
/* for each line containing the old text */
|
||||
fprintf(script, "ed - <<\\!\n");
|
||||
*oldfile = '\0';
|
||||
fseek(refsfound, 0, SEEK_SET);
|
||||
for(int i = 0;
|
||||
fscanf(refsfound, "%" PATHLEN_STR "s%*s%" NUMLEN_STR "s%*[^\n]", newfile, linenum) == 2;
|
||||
++i)
|
||||
{
|
||||
/* see if the line is to be changed */
|
||||
if (change[i] == false) { break; }
|
||||
anymarked = true;
|
||||
|
||||
/* if this is a new file */
|
||||
if (strcmp(newfile, oldfile) != 0) {
|
||||
|
||||
/* make sure it can be changed */
|
||||
if (access(newfile, WRITE) != 0) {
|
||||
snprintf(msg, sizeof(msg), "Cannot write to file %s", newfile);
|
||||
postmsg(msg);
|
||||
anymarked = false;
|
||||
break;
|
||||
}
|
||||
/* if there was an old file */
|
||||
if (*oldfile != '\0') {
|
||||
fprintf(script, "w\n"); /* save it */
|
||||
}
|
||||
/* edit the new file */
|
||||
strcpy(oldfile, newfile);
|
||||
fprintf(script, "e %s\n", oldfile);
|
||||
}
|
||||
/* output substitute command */
|
||||
fprintf(script, "%ss/", linenum); /* change */
|
||||
for (char *s = Pattern; *s != '\0'; ++s) {
|
||||
/* old text */
|
||||
if (strchr("/\\[.^*", *s) != NULL) {
|
||||
putc('\\', script);
|
||||
}
|
||||
if (caseless == true && isalpha((unsigned char)*s)) {
|
||||
putc('[', script);
|
||||
if(islower((unsigned char)*s)) {
|
||||
putc(toupper((unsigned char)*s), script);
|
||||
putc(*s, script);
|
||||
} else {
|
||||
putc(*s, script);
|
||||
putc(tolower((unsigned char)*s), script);
|
||||
}
|
||||
putc(']', script);
|
||||
} else {
|
||||
putc(*s, script);
|
||||
}
|
||||
}
|
||||
putc('/', script); /* to */
|
||||
for (char *s = newpat; *s != '\0'; ++s) { /* new text */
|
||||
if (strchr("/\\&", *s) != NULL) {
|
||||
putc('\\', script);
|
||||
}
|
||||
putc(*s, script);
|
||||
}
|
||||
fprintf(script, "/gp\n"); /* and print */
|
||||
}
|
||||
fprintf(script, "w\nq\n!\n"); /* write and quit */
|
||||
fclose(script);
|
||||
|
||||
/* if any line was marked */
|
||||
if (anymarked == true) {
|
||||
/* edit the files */
|
||||
fprintf(stderr, "Changed lines:\n\r");
|
||||
execute("sh", "sh", temp2, NULL);
|
||||
askforchar();
|
||||
}
|
||||
changing = false;
|
||||
mousemenu();
|
||||
fclose(script);
|
||||
free(change);
|
||||
return(anymarked);
|
||||
}
|
||||
|
||||
int
|
||||
handle_input(const int c){
|
||||
@ -546,13 +690,20 @@ handle_input(const int c){
|
||||
const int r = global_input(c);
|
||||
if(r){ return 0; }
|
||||
/* --- mode specific --- */
|
||||
if(*current_window == winput){
|
||||
return interpret(c);
|
||||
}else if(*current_window == wmode){
|
||||
return wmode_input(c);
|
||||
}else if(*current_window == wresult){
|
||||
return wresult_input(c);
|
||||
}
|
||||
switch(input_mode){
|
||||
case INPUT_NORMAL:
|
||||
if(*current_window == winput){
|
||||
return interpret(c);
|
||||
}else if(*current_window == wmode){
|
||||
return wmode_input(c);
|
||||
}else if(*current_window == wresult){
|
||||
return wresult_input(c);
|
||||
}
|
||||
assert("'current_window' dangling.");
|
||||
break; /* NOTREACHED */
|
||||
case INPUT_CHANGE:
|
||||
return change_input(c);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@
|
||||
#ifndef KEY_NPAGE
|
||||
# define KEY_NPAGE KEY_UNDEF_BASE-8
|
||||
#endif
|
||||
#ifdef KEY_ENTER
|
||||
#ifndef KEY_ENTER
|
||||
# define KEY_ENTER KEY_UNDEF_BASE-9
|
||||
#endif
|
||||
#ifndef KEY_CLEAR
|
||||
|
@ -30,6 +30,41 @@
|
||||
DAMAGE.
|
||||
=========================================================================*/
|
||||
|
||||
/* get a file's base name from its path name */
|
||||
|
||||
#include "global.h"
|
||||
|
||||
const char *
|
||||
basename(char *path)
|
||||
{
|
||||
char *s;
|
||||
|
||||
if ((s = strrchr(path, '/')) != 0) {
|
||||
return(s + 1);
|
||||
}
|
||||
return(path);
|
||||
}
|
||||
|
||||
/* get the requested path components */
|
||||
char *
|
||||
pathcomponents(char *path, int components)
|
||||
{
|
||||
int i;
|
||||
char *s;
|
||||
|
||||
s = path + strlen(path) - 1;
|
||||
for (i = 0; i < components; ++i) {
|
||||
while (s > path && *--s != '/') {
|
||||
;
|
||||
}
|
||||
}
|
||||
if (s > path && *s == '/') {
|
||||
++s;
|
||||
}
|
||||
return(s);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* compath(pathname)
|
||||
*
|
||||
@ -44,12 +79,6 @@
|
||||
* and stored in global structures.
|
||||
*/
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
char *
|
||||
compath(char *pathname) /*FDEF*/
|
||||
{
|
@ -35,8 +35,24 @@ static void callback_handler(char* line){
|
||||
if(!line){ return; }
|
||||
strncpy(input_line, line, PATLEN);
|
||||
|
||||
if(!search()){
|
||||
switch(input_mode){
|
||||
case INPUT_NORMAL:
|
||||
search();
|
||||
break;
|
||||
case INPUT_CHANGE:
|
||||
changestring();
|
||||
input_mode = INPUT_NORMAL;
|
||||
break;
|
||||
}
|
||||
|
||||
switch(field){
|
||||
case CHANGE:
|
||||
input_mode = INPUT_CHANGE;
|
||||
break;
|
||||
case DEFINITION:
|
||||
case FILENAME:
|
||||
if(totallines == 1){ editref(0); }
|
||||
break;
|
||||
}
|
||||
|
||||
curdispline = 0;
|
||||
@ -78,7 +94,6 @@ static int rebuild_reference(){
|
||||
postmsg(""); /* clear any previous message */
|
||||
totallines = 0;
|
||||
disprefs = 0;
|
||||
topline = nextline = 1;
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user