bak
This commit is contained in:
parent
ab7b3e5c85
commit
a83c6632c3
@ -85,6 +85,7 @@ fixing it would have been a lost cause, if not for Cscope itself. Well, Csope no
|
|||||||
+ library.h...; "private library", in a program using 90 globals; ffs
|
+ library.h...; "private library", in a program using 90 globals; ffs
|
||||||
+ sort out the global hell
|
+ sort out the global hell
|
||||||
+ changestring() forks sh to execute an ed script...
|
+ changestring() forks sh to execute an ed script...
|
||||||
|
+ was there really ever a scrollbar?
|
||||||
## Original
|
## Original
|
||||||
+ Display the current case mode (^C) onscreen
|
+ Display the current case mode (^C) onscreen
|
||||||
+ emacs like key bindings
|
+ emacs like key bindings
|
||||||
|
@ -79,7 +79,7 @@ const char* prompts[] = {
|
|||||||
[INPUT_CHANGE] = "To: "
|
[INPUT_CHANGE] = "To: "
|
||||||
};
|
};
|
||||||
|
|
||||||
static unsigned int topline = 1; /* top line of page */
|
unsigned int topline = 1; /* top line of page */
|
||||||
|
|
||||||
/* Selectable windows */
|
/* Selectable windows */
|
||||||
WINDOW* winput;
|
WINDOW* winput;
|
||||||
|
@ -254,7 +254,7 @@ int handle_input(const int c);
|
|||||||
int dispchar2int(const char c);
|
int dispchar2int(const char c);
|
||||||
int process_mouse();
|
int process_mouse();
|
||||||
extern int input_mode;
|
extern int input_mode;
|
||||||
int changestring(bool *change);
|
int changestring(const char* from, const char* to, bool *change);
|
||||||
|
|
||||||
long seekpage(size_t i);
|
long seekpage(size_t i);
|
||||||
long seekrelline(unsigned i);
|
long seekrelline(unsigned i);
|
||||||
|
63
src/input.c
63
src/input.c
@ -529,24 +529,23 @@ extern const void *const winput;
|
|||||||
extern const void *const wmode;
|
extern const void *const wmode;
|
||||||
extern const void *const wresult;
|
extern const void *const wresult;
|
||||||
extern const void *const *const current_window;
|
extern const void *const *const current_window;
|
||||||
|
extern const int topline;
|
||||||
|
|
||||||
static int
|
int
|
||||||
change_input(const int c){
|
change_input(const int c){
|
||||||
MOUSE *p; /* mouse data */
|
MOUSE *p; /* mouse data */
|
||||||
change = calloc(totallines, sizeof(*change));
|
change = calloc(totallines, sizeof(*change));
|
||||||
|
|
||||||
switch(c){
|
switch(c){
|
||||||
case '*': /* invert selection */
|
case '*': /* invert page */
|
||||||
//for(int i = 0; topline + i < nextline; ++i){
|
for(int i = 0; topline + i < nextline; i++){
|
||||||
// change[i] = !change[i];
|
change[topline + i] = !change[topline + i];
|
||||||
//}
|
}
|
||||||
break;
|
break;
|
||||||
case ctrl('A'): /* mark/unmark all lines */
|
case ctrl('A'): /* invert all lines */
|
||||||
for(unsigned i = 0; i < totallines; ++i) {
|
for(unsigned i = 0; i < totallines; i++) {
|
||||||
change[i] = !change[i];
|
change[i] = !change[i];
|
||||||
}
|
}
|
||||||
/* show that all have been marked */
|
|
||||||
//seekline(totallines); // ?!
|
|
||||||
break;
|
break;
|
||||||
case ctrl('X'): /* mouse selection */
|
case ctrl('X'): /* mouse selection */
|
||||||
if ((p = getmouseaction(DUMMYCHAR)) == NULL) {
|
if ((p = getmouseaction(DUMMYCHAR)) == NULL) {
|
||||||
@ -570,7 +569,7 @@ change_input(const int c){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ctrl('D'):
|
case ctrl('D'):
|
||||||
changestring(change);
|
changestring(input_line, newpat, change);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
@ -586,7 +585,7 @@ change_input(const int c){
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
changestring(bool *change){
|
changestring(const char* from, const char* to, bool *change){
|
||||||
char newfile[PATHLEN + 1]; /* new file name */
|
char newfile[PATHLEN + 1]; /* new file name */
|
||||||
char oldfile[PATHLEN + 1]; /* old file name */
|
char oldfile[PATHLEN + 1]; /* old file name */
|
||||||
char linenum[NUMLEN + 1]; /* file line number */
|
char linenum[NUMLEN + 1]; /* file line number */
|
||||||
@ -632,27 +631,27 @@ changestring(bool *change){
|
|||||||
}
|
}
|
||||||
/* output substitute command */
|
/* output substitute command */
|
||||||
fprintf(script, "%ss/", linenum); /* change */
|
fprintf(script, "%ss/", linenum); /* change */
|
||||||
//for (char *s = Pattern; *s != '\0'; ++s) {
|
for(const char *s = from; *s != '\0'; ++s) {
|
||||||
// /* old text */
|
/* old text */
|
||||||
// if (strchr("/\\[.^*", *s) != NULL) {
|
if (strchr("/\\[.^*", *s) != NULL) {
|
||||||
// putc('\\', script);
|
putc('\\', script);
|
||||||
// }
|
}
|
||||||
// if (caseless == true && isalpha((unsigned char)*s)) {
|
if (caseless == true && isalpha((unsigned char)*s)) {
|
||||||
// putc('[', script);
|
putc('[', script);
|
||||||
// if(islower((unsigned char)*s)) {
|
if(islower((unsigned char)*s)) {
|
||||||
// putc(toupper((unsigned char)*s), script);
|
putc(toupper((unsigned char)*s), script);
|
||||||
// putc(*s, script);
|
putc(*s, script);
|
||||||
// } else {
|
} else {
|
||||||
// putc(*s, script);
|
putc(*s, script);
|
||||||
// putc(tolower((unsigned char)*s), script);
|
putc(tolower((unsigned char)*s), script);
|
||||||
// }
|
}
|
||||||
// putc(']', script);
|
putc(']', script);
|
||||||
// } else {
|
} else {
|
||||||
// putc(*s, script);
|
putc(*s, script);
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
putc('/', script); /* to */
|
putc('/', script); /* to */
|
||||||
for (char *s = newpat; *s != '\0'; ++s) { /* new text */
|
for(const char *s = to; *s != '\0'; ++s) { /* new text */
|
||||||
if (strchr("/\\&", *s) != NULL) {
|
if (strchr("/\\&", *s) != NULL) {
|
||||||
putc('\\', script);
|
putc('\\', script);
|
||||||
}
|
}
|
||||||
@ -661,7 +660,6 @@ changestring(bool *change){
|
|||||||
fprintf(script, "/gp\n"); /* and print */
|
fprintf(script, "/gp\n"); /* and print */
|
||||||
}
|
}
|
||||||
fprintf(script, "w\nq\n!\n"); /* write and quit */
|
fprintf(script, "w\nq\n!\n"); /* write and quit */
|
||||||
fclose(script);
|
|
||||||
|
|
||||||
/* if any line was marked */
|
/* if any line was marked */
|
||||||
if (anymarked == true) {
|
if (anymarked == true) {
|
||||||
@ -670,6 +668,7 @@ changestring(bool *change){
|
|||||||
execute("sh", "sh", temp2, NULL);
|
execute("sh", "sh", temp2, NULL);
|
||||||
askforchar();
|
askforchar();
|
||||||
}
|
}
|
||||||
|
|
||||||
changing = false;
|
changing = false;
|
||||||
mousemenu();
|
mousemenu();
|
||||||
fclose(script);
|
fclose(script);
|
||||||
|
@ -40,7 +40,7 @@ static void callback_handler(char* line){
|
|||||||
search();
|
search();
|
||||||
break;
|
break;
|
||||||
case INPUT_CHANGE:
|
case INPUT_CHANGE:
|
||||||
changestring(NULL);
|
changestring(change);
|
||||||
input_mode = INPUT_NORMAL;
|
input_mode = INPUT_NORMAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user