|
@@ -515,20 +515,30 @@ int GUIBufferEditor_SmartFind(GUIBufferEditor* w, char* charSet, FindMask_t mask
|
|
int fix_cursor = 0;
|
|
int fix_cursor = 0;
|
|
|
|
|
|
if((mask & FM_SELECTION) && HAS_SELECTION(w->ec->sel) && w->ec->sel->line[0] == w->ec->sel->line[1]) {
|
|
if((mask & FM_SELECTION) && HAS_SELECTION(w->ec->sel) && w->ec->sel->line[0] == w->ec->sel->line[1]) {
|
|
|
|
+ GUIBufferEditor_StopFind(w);
|
|
str = Buffer_StringFromSelection(b, w->ec->sel, NULL);
|
|
str = Buffer_StringFromSelection(b, w->ec->sel, NULL);
|
|
fix_cursor = 1;
|
|
fix_cursor = 1;
|
|
|
|
+ printf("Stopping find and setting search from selection string <%s>\n", str);
|
|
}
|
|
}
|
|
else if(!str && (mask & FM_SEQUENCE) && charSet) {
|
|
else if(!str && (mask & FM_SEQUENCE) && charSet) {
|
|
Buffer_GetSequenceUnder(b, CURSOR_LINE(w->ec->sel), CURSOR_COL(w->ec->sel), charSet, &sel);
|
|
Buffer_GetSequenceUnder(b, CURSOR_LINE(w->ec->sel), CURSOR_COL(w->ec->sel), charSet, &sel);
|
|
if((sel.line[0] == sel.line[1]) && (sel.col[1] - sel.col[0] > 0)) {
|
|
if((sel.line[0] == sel.line[1]) && (sel.col[1] - sel.col[0] > 0)) {
|
|
|
|
+ GUIBufferEditor_StopFind(w);
|
|
str = Buffer_StringFromSelection(b, &sel, NULL);
|
|
str = Buffer_StringFromSelection(b, &sel, NULL);
|
|
fix_cursor = 1;
|
|
fix_cursor = 1;
|
|
|
|
+ printf("Stopping find and setting search from sequence string <%s>\n", str);
|
|
}
|
|
}
|
|
else if(w->findState) {
|
|
else if(w->findState) {
|
|
|
|
+ printf("Continuing with existing find state\n");
|
|
w->findState->findSet->changeCounter++;
|
|
w->findState->findSet->changeCounter++;
|
|
return GUIBufferEditor_RelativeFindMatch(w, 1, 1, w->findState);
|
|
return GUIBufferEditor_RelativeFindMatch(w, 1, 1, w->findState);
|
|
}
|
|
}
|
|
// unhandled / uninitialized else case?
|
|
// unhandled / uninitialized else case?
|
|
|
|
+ else {
|
|
|
|
+ printf("unhandled / uninitialized else case. First search or findstate was cleared?\n");
|
|
|
|
+ str = strdup("");
|
|
|
|
+ fix_cursor = 1;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
str = strdup("");
|
|
str = strdup("");
|
|
@@ -650,6 +660,7 @@ int GUIBufferEditor_RelativeFindMatch(GUIBufferEditor* w, int offset, int contin
|
|
|
|
|
|
|
|
|
|
void GUIBufferEditor_StopFind(GUIBufferEditor* w) {
|
|
void GUIBufferEditor_StopFind(GUIBufferEditor* w) {
|
|
|
|
+ printf("Find state cleared by StopFind\n");
|
|
|
|
|
|
w->ec->findSearchSpace = NULL;
|
|
w->ec->findSearchSpace = NULL;
|
|
BufferFindState_FreeAll(w->findState);
|
|
BufferFindState_FreeAll(w->findState);
|
|
@@ -658,7 +669,9 @@ void GUIBufferEditor_StopFind(GUIBufferEditor* w) {
|
|
}
|
|
}
|
|
|
|
|
|
void BufferFindState_FreeAll(BufferFindState* st) {
|
|
void BufferFindState_FreeAll(BufferFindState* st) {
|
|
|
|
+ printf("Requested to free find state\n");
|
|
if(!st) return;
|
|
if(!st) return;
|
|
|
|
+ printf("Freeing find state\n");
|
|
// clean up errors
|
|
// clean up errors
|
|
if(st->findREError) {
|
|
if(st->findREError) {
|
|
free(st->findREError);
|
|
free(st->findREError);
|
|
@@ -986,6 +999,11 @@ int GUIBufferEditor_ProcessCommand(GUIBufferEditor* w, GUI_Cmd* cmd, int* needRe
|
|
// w->inputMode = 0;
|
|
// w->inputMode = 0;
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
+
|
|
|
|
+ ///////////////////////////////////
|
|
|
|
+ // START FIND & REPLACE COMMANDS //
|
|
|
|
+ ///////////////////////////////////
|
|
|
|
+
|
|
case GUICMD_Buffer_ReplaceNext:
|
|
case GUICMD_Buffer_ReplaceNext:
|
|
GUIBufferEditor_ReplaceNext(w);
|
|
GUIBufferEditor_ReplaceNext(w);
|
|
break;
|
|
break;
|
|
@@ -1047,23 +1065,18 @@ int GUIBufferEditor_ProcessCommand(GUIBufferEditor* w, GUI_Cmd* cmd, int* needRe
|
|
break;
|
|
break;
|
|
|
|
|
|
case GUICMD_Buffer_FindStart:
|
|
case GUICMD_Buffer_FindStart:
|
|
- GUIBufferEditor_StopFind(w);
|
|
|
|
GUIBufferEditor_SmartFind(w, NULL, FM_SELECTION);
|
|
GUIBufferEditor_SmartFind(w, NULL, FM_SELECTION);
|
|
-
|
|
|
|
GUI_SetActive(&w->findQuery);
|
|
GUI_SetActive(&w->findQuery);
|
|
break;
|
|
break;
|
|
|
|
|
|
case GUICMD_Buffer_FindResume:
|
|
case GUICMD_Buffer_FindResume:
|
|
-// w->inputMode = BIM_Find;
|
|
|
|
if(!w->findState) {
|
|
if(!w->findState) {
|
|
GUIBufferEditor_SmartFind(w, NULL, FM_SELECTION);
|
|
GUIBufferEditor_SmartFind(w, NULL, FM_SELECTION);
|
|
}
|
|
}
|
|
-
|
|
|
|
GUI_SetActive(&w->findQuery);
|
|
GUI_SetActive(&w->findQuery);
|
|
|
|
|
|
break;
|
|
break;
|
|
case GUICMD_Buffer_SmartFind:
|
|
case GUICMD_Buffer_SmartFind:
|
|
-// w->inputMode = BIM_Find;
|
|
|
|
GUIBufferEditor_SmartFind(w, cmd->str, FM_SEQUENCE | FM_SELECTION | FM_WITHIN_SELECTION);
|
|
GUIBufferEditor_SmartFind(w, cmd->str, FM_SEQUENCE | FM_SELECTION | FM_WITHIN_SELECTION);
|
|
GUI_SetActive(&w->findQuery);
|
|
GUI_SetActive(&w->findQuery);
|
|
break;
|
|
break;
|
|
@@ -1075,7 +1088,13 @@ int GUIBufferEditor_ProcessCommand(GUIBufferEditor* w, GUI_Cmd* cmd, int* needRe
|
|
case GUICMD_Buffer_FindPrev:
|
|
case GUICMD_Buffer_FindPrev:
|
|
GUIBufferEditor_RelativeFindMatch(w, -1, 1, w->findState);
|
|
GUIBufferEditor_RelativeFindMatch(w, -1, 1, w->findState);
|
|
break;
|
|
break;
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ /////////////////////////////////
|
|
|
|
+ // END FIND & REPLACE COMMANDS //
|
|
|
|
+ /////////////////////////////////
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
case GUICMD_Buffer_CollapseWhitespace:
|
|
case GUICMD_Buffer_CollapseWhitespace:
|
|
Buffer_CollapseWhitespace(w->b, CURSOR_LINE(w->ec->sel), w->ec->sel->col[0]);
|
|
Buffer_CollapseWhitespace(w->b, CURSOR_LINE(w->ec->sel), w->ec->sel->col[0]);
|
|
break;
|
|
break;
|