.
This commit is contained in:
parent
ea6f464ad6
commit
125826ac1a
@ -106,6 +106,7 @@ All can be configured sucklessly under "config/colors.h". Hopefully the comments
|
||||
| int window_change | Bit mask type of the CH_\* macros. Keeps track of the windows to be refresed on the next run of display(). Could be better utalized.
|
||||
|
||||
# TODO /*move soon*/
|
||||
1. create a step in the mean loop where the cursor us forced into the right window based on mode
|
||||
+ sort out constants.h
|
||||
+ scrollbar() uses magic int literals?
|
||||
+ lineflagafterfile is stupid
|
||||
@ -125,6 +126,7 @@ All can be configured sucklessly under "config/colors.h". Hopefully the comments
|
||||
Aborted
|
||||
+ Changing text can crash without replacing text and leaving the console ncursed
|
||||
+ After an attempted change malloc *can* cry and crash
|
||||
+ Changing text fucks up redisplaying
|
||||
|
||||
# Future features / contributor wishlist
|
||||
+ providing support for other languages by integrating new lexers (e.g. ctag's)
|
||||
|
@ -77,7 +77,7 @@ const char *prompts[] = {[INPUT_NORMAL] = "$ ",
|
||||
[INPUT_PIPE] = "Pipe to shell command: ",
|
||||
[INPUT_READ] = "Read from file: ",
|
||||
[INPUT_CHANGE_TO] = "To: ",
|
||||
[INPUT_CHANGE] = "To: "};
|
||||
[INPUT_CHANGE] = "###"};
|
||||
|
||||
unsigned int topline = 1; /* top line of page */
|
||||
|
||||
@ -614,7 +614,7 @@ static inline void display_cursor(void) {
|
||||
waddch(*current_window, i);
|
||||
}
|
||||
|
||||
void horswp_field(void) {
|
||||
void horswp_window(void) {
|
||||
if(input_mode != INPUT_NORMAL){ return; }
|
||||
|
||||
if(current_window != &wresult) {
|
||||
@ -634,7 +634,7 @@ void horswp_field(void) {
|
||||
window_change |= CH_RESULT;
|
||||
}
|
||||
|
||||
void verswp_field(void) {
|
||||
void verswp_window(void) {
|
||||
if(current_window == &wresult) { return; }
|
||||
current_window = (current_window == &winput) ? &wmode : &winput;
|
||||
window_change |= CH_INPUT | CH_MODE;
|
||||
|
11
src/global.h
11
src/global.h
@ -75,6 +75,8 @@ struct cmd { /* command history struct */
|
||||
char *text; /* input field text */
|
||||
};
|
||||
|
||||
/* bitmask type to mark which windows have to be rerendered by
|
||||
display() */
|
||||
enum {
|
||||
CH_NONE = 0x0000,
|
||||
CH_RESULT = 0x0001 << 0,
|
||||
@ -84,6 +86,7 @@ enum {
|
||||
CH_HELP = 0x0001 << 4, /* do NOT add to CH_ALL */
|
||||
CH_ALL = CH_RESULT | CH_INPUT | CH_MODE | CH_CASE
|
||||
};
|
||||
extern int window_change;
|
||||
|
||||
enum {
|
||||
INPUT_NORMAL,
|
||||
@ -93,6 +96,7 @@ enum {
|
||||
INPUT_CHANGE_TO,
|
||||
INPUT_CHANGE
|
||||
};
|
||||
extern int input_mode;
|
||||
|
||||
#ifndef DFLT_INCDIR
|
||||
# define DFLT_INCDIR "/usr/include"
|
||||
@ -181,8 +185,6 @@ extern unsigned int mdisprefs; /* maximum displayed references */
|
||||
extern unsigned int nextline; /* next line to be shown */
|
||||
extern long searchcount; /* count of files searched */
|
||||
extern unsigned int totallines; /* total reference lines */
|
||||
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 */
|
||||
@ -237,13 +239,12 @@ extern char *reflines; /* symbol reference lines file */
|
||||
extern bool do_press_any_key; /* wait for any key to continue */
|
||||
extern int current_page;
|
||||
#define topref (current_page * mdisprefs)
|
||||
void verswp_field(void);
|
||||
void horswp_field(void);
|
||||
void horswp_window(void);
|
||||
void verswp_window(void);
|
||||
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;
|
||||
int changestring(const char *from, const char *to, const bool *const change,
|
||||
const int change_len);
|
||||
|
||||
|
53
src/input.c
53
src/input.c
@ -46,6 +46,11 @@
|
||||
|
||||
#include "keys.h"
|
||||
|
||||
extern const void *const winput;
|
||||
extern const void *const wmode;
|
||||
extern const void *const wresult;
|
||||
extern const void *const *const current_window;
|
||||
|
||||
bool do_press_any_key = false;
|
||||
|
||||
static jmp_buf env; /* setjmp/longjmp buffer */
|
||||
@ -219,10 +224,10 @@ noredisp:
|
||||
static int global_input(const int c) {
|
||||
switch(c) {
|
||||
case '\t':
|
||||
horswp_field();
|
||||
horswp_window();
|
||||
break;
|
||||
case '%':
|
||||
verswp_field();
|
||||
verswp_window();
|
||||
break;
|
||||
case ctrl('K'):
|
||||
field = (field + (FIELDS - 1)) % FIELDS;
|
||||
@ -251,32 +256,14 @@ static int global_input(const int c) {
|
||||
window_change |= CH_RESULT;
|
||||
break;
|
||||
case '>': /* write or append the lines to a file */
|
||||
break; // XXX
|
||||
// char filename[PATHLEN + 1];
|
||||
// char* s;
|
||||
// char ch;
|
||||
// FILE* file;
|
||||
// if (totallines == 0) {
|
||||
// postmsg("There are no lines to write to a file");
|
||||
// return(NO);
|
||||
// }
|
||||
// move(PRLINE, 0);
|
||||
////addstr("Write to file: "); // XXX
|
||||
// s = "w";
|
||||
// if ((ch = getch()) == '>') {
|
||||
// move(PRLINE, 0);
|
||||
////addstr(appendprompt); // XXX fix
|
||||
////ch = '\0';
|
||||
////s = "a";
|
||||
////}
|
||||
////if (ch != '\r' && mygetline("", newpat, COLS - sizeof(appendprompt), c,
|
||||
///NO) > 0) { / shellpath(filename, sizeof(filename), newpat); / if
|
||||
///((file = myfopen(filename, s)) == NULL) { / cannotopen(filename); /
|
||||
///} else { / seekline(1); / while ((ch = getc(refsfound)) !=
|
||||
///EOF) { / putc(ch, file); / } / seekline(topline); /
|
||||
///fclose(file); / }
|
||||
////}
|
||||
////clearprompt();
|
||||
if (totallines == 0) {
|
||||
postmsg("There are no lines to write to a file");
|
||||
break;
|
||||
}
|
||||
if(*current_window == wresult){ horswp_window(); }
|
||||
if(*current_window == wmode){ verswp_window(); }
|
||||
input_mode = INPUT_APPEND;
|
||||
window_change |= CH_INPUT;
|
||||
break;
|
||||
case '<': /* read lines from a file */
|
||||
break; // XXX
|
||||
@ -369,11 +356,6 @@ static int 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;
|
||||
|
||||
int change_input(const int c) {
|
||||
MOUSE *p; /* mouse data */
|
||||
|
||||
@ -412,7 +394,7 @@ int change_input(const int c) {
|
||||
case ctrl('D'):
|
||||
changestring(input_line, newpat, change, totallines);
|
||||
input_mode = INPUT_NORMAL;
|
||||
horswp_field();
|
||||
horswp_window();
|
||||
search(newpat);
|
||||
break;
|
||||
default:
|
||||
@ -426,6 +408,8 @@ int change_input(const int c) {
|
||||
}
|
||||
}
|
||||
|
||||
input_mode = INPUT_NORMAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -538,6 +522,7 @@ int handle_input(const int c) {
|
||||
assert("'current_window' dangling.");
|
||||
break; /* NOTREACHED */
|
||||
case INPUT_CHANGE_TO:
|
||||
case INPUT_APPEND:
|
||||
return interpret(c);
|
||||
case INPUT_CHANGE:
|
||||
return change_input(c);
|
||||
|
@ -80,7 +80,7 @@ static void redisplay_function() {
|
||||
}
|
||||
|
||||
static void callback_handler(char *line) {
|
||||
if(!line) { return; }
|
||||
if(!line) { return; } // XXX; should behave differently with different modes
|
||||
|
||||
add_history(line);
|
||||
|
||||
@ -88,7 +88,7 @@ static void callback_handler(char *line) {
|
||||
case INPUT_NORMAL:
|
||||
strncpy(input_line, line, PATLEN);
|
||||
search(input_line);
|
||||
horswp_field();
|
||||
horswp_window();
|
||||
curdispline = 0;
|
||||
current_page = 0;
|
||||
PCS_reset();
|
||||
@ -97,12 +97,27 @@ static void callback_handler(char *line) {
|
||||
strncpy(newpat, line, PATLEN);
|
||||
change = calloc(totallines, sizeof(*change));
|
||||
input_mode = INPUT_CHANGE;
|
||||
horswp_field();
|
||||
horswp_window();
|
||||
return;
|
||||
case INPUT_APPEND: {
|
||||
char filename[PATHLEN + 1];
|
||||
FILE* file;
|
||||
char ch;
|
||||
shellpath(filename, sizeof(filename), line);
|
||||
file = fopen(filename, "a+");
|
||||
seekpage(0);
|
||||
while ((ch = getc(refsfound)) != EOF) {
|
||||
putc(ch, file);
|
||||
}
|
||||
fclose(file);
|
||||
input_mode = INPUT_NORMAL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch(field) {
|
||||
case CHANGE:
|
||||
if(totallines == 0){ return; }
|
||||
input_mode = INPUT_CHANGE_TO;
|
||||
break;
|
||||
case DEFINITION:
|
||||
|
Loading…
Reference in New Issue
Block a user