This commit is contained in:
anon 2023-08-10 15:52:28 +02:00
parent ab7b3e5c85
commit a83c6632c3
5 changed files with 38 additions and 38 deletions

View File

@ -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
+ sort out the global hell
+ changestring() forks sh to execute an ed script...
+ was there really ever a scrollbar?
## Original
+ Display the current case mode (^C) onscreen
+ emacs like key bindings

View File

@ -79,7 +79,7 @@ const char* prompts[] = {
[INPUT_CHANGE] = "To: "
};
static unsigned int topline = 1; /* top line of page */
unsigned int topline = 1; /* top line of page */
/* Selectable windows */
WINDOW* winput;
@ -444,9 +444,9 @@ static inline void display_results(){
/* if this is the first displayed line,
display what will fit on the screen */
if (topline == nextline-1) {
disprefs++;
/* break out of two loops */
goto endrefs;
disprefs++;
/* break out of two loops */
goto endrefs;
}
/* erase the reference */

View File

@ -254,7 +254,7 @@ int handle_input(const int c);
int dispchar2int(const char c);
int process_mouse();
extern int input_mode;
int changestring(bool *change);
int changestring(const char* from, const char* to, bool *change);
long seekpage(size_t i);
long seekrelline(unsigned i);

View File

@ -529,24 +529,23 @@ extern const void *const winput;
extern const void *const wmode;
extern const void *const wresult;
extern const void *const *const current_window;
extern const int topline;
static int
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];
//}
case '*': /* invert page */
for(int i = 0; topline + i < nextline; i++){
change[topline + i] = !change[topline + i];
}
break;
case ctrl('A'): /* mark/unmark all lines */
for(unsigned i = 0; i < totallines; ++i) {
case ctrl('A'): /* invert 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) {
@ -570,7 +569,7 @@ change_input(const int c){
}
break;
case ctrl('D'):
changestring(change);
changestring(input_line, newpat, change);
break;
default:
{
@ -586,7 +585,7 @@ change_input(const int c){
}
int
changestring(bool *change){
changestring(const char* from, const char* to, bool *change){
char newfile[PATHLEN + 1]; /* new file name */
char oldfile[PATHLEN + 1]; /* old file name */
char linenum[NUMLEN + 1]; /* file line number */
@ -632,27 +631,27 @@ changestring(bool *change){
}
/* 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);
// }
//}
for(const char *s = from; *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 */
for(const char *s = to; *s != '\0'; ++s) { /* new text */
if (strchr("/\\&", *s) != NULL) {
putc('\\', script);
}
@ -661,7 +660,6 @@ changestring(bool *change){
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) {
@ -670,6 +668,7 @@ changestring(bool *change){
execute("sh", "sh", temp2, NULL);
askforchar();
}
changing = false;
mousemenu();
fclose(script);

View File

@ -40,7 +40,7 @@ static void callback_handler(char* line){
search();
break;
case INPUT_CHANGE:
changestring(NULL);
changestring(change);
input_mode = INPUT_NORMAL;
break;
}