/* This file is part of
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich,
* Copyright 1995-1999 The LyX Team.
*
- * ======================================================*/
+ * ====================================================== */
#include <config.h>
#include "lyx_gui_misc.h"
#include "minibuffer.h"
#include "support/lstrings.h"
+#include "support/textutils.h"
extern BufferView *current_view; // called too many times in this file...
extern MiniBuffer *minibuffer;
// function prototypes
-bool IsLetterCharOrDigit(char ch);
-
// If nothing selected, select the word at the cursor.
// Returns the current selection
// Note: this function should be in LyXText!
//-------------------------------------------------------------
-bool IsLetterCharOrDigit(char ch)
-{
- return IsLetterChar(ch) || isdigit(ch);
-}
// Returns the current selection. If nothing is selected or if the selection
LyXParagraph * par = lt->cursor.par;
if (lt->selection && (lt->sel_cursor.par == par)) {
// (selected) and (begin/end in same paragraph)
-#ifdef NEW_TEXT
- LyXParagraph::size_type pos =
- lt->sel_start_cursor.pos;
- LyXParagraph::size_type endpos =
- lt->sel_end_cursor.pos;
-#else
- int pos =
+ LyXParagraph::size_type pos =
lt->sel_start_cursor.pos;
- int endpos =
+ LyXParagraph::size_type endpos =
lt->sel_end_cursor.pos;
-#endif
int i = 0;
bool fPrevIsSpace = false;
char ch;
ch = par->GetChar(pos);
//HB??: Maybe (ch <= ' ')
- if ((ch == ' ') || (ch <= LYX_META_INSET)) {
+ if ((ch == ' ') || (ch <= LyXParagraph::META_INSET)) {
// consecutive spaces --> 1 space char
if (fPrevIsSpace) {
pos++; // Next text pos
{
lt->sel_cursor = lt->cursor;
int i;
- for (i=0; i < len; i++)
+ for (i= 0; i < len; i++)
lt->CursorRight();
lt->SetSelection();
}
void LyXFindReplace1::StartSearch()
{
LyXFindReplace0::StartSearch();
- SetReplaceEnabled(!current_view->currentBuffer()->isReadonly());
+ SetReplaceEnabled(!current_view->buffer()->isReadonly());
searchForward = true;
if (lsSearch.empty())
- SetSearchString(GetSelectionOrWordAtCursor(current_view->currentBuffer()->text));
+ SetSearchString(GetSelectionOrWordAtCursor(current_view->buffer()->text));
}
if (!current_view->getScreen())
return;
- if (current_view->currentBuffer()->isReadonly())
+ if (current_view->buffer()->isReadonly())
return;
// CutSelection cannot cut a single space, so we have to stop
string const replacestring = ReplaceString();
current_view->getScreen()->HideCursor();
- current_view->currentBuffer()->update(-2);
+ current_view->buffer()->update(-2);
- ltCur = current_view->currentBuffer()->text;
+ ltCur = current_view->buffer()->text;
if (ltCur->selection) {
// clear the selection (if there is any)
current_view->getScreen()->ToggleSelection(false);
- current_view->currentBuffer()->text->
+ current_view->buffer()->text->
ReplaceSelectionWithString(replacestring.c_str());
- current_view->currentBuffer()->text->
+ current_view->buffer()->text->
SetSelectionOverString(replacestring.c_str());
- current_view->currentBuffer()->update(1);
+ current_view->buffer()->update(1);
}
// jump to next match:
if (!current_view->getScreen())
return;
- if (current_view->currentBuffer()->isReadonly())
+ if (current_view->buffer()->isReadonly())
return;
// CutSelection cannot cut a single space, so we have to stop
current_view->getScreen()->HideCursor();
// start at top
- current_view->currentBuffer()->text->ClearSelection();
- current_view->currentBuffer()->text->CursorTop();
+ current_view->buffer()->text->ClearSelection();
+ current_view->buffer()->text->CursorTop();
int replace_count = 0;
do {
- ltCur = current_view->currentBuffer()->text;
+ ltCur = current_view->buffer()->text;
if (ltCur->selection) {
- current_view->currentBuffer()->update(-2);
+ current_view->buffer()->update(-2);
current_view->getScreen()->ToggleSelection(false);
- current_view->currentBuffer()->text->
+ current_view->buffer()->text->
ReplaceSelectionWithString(replacestring.c_str());
- current_view->currentBuffer()->text->
+ current_view->buffer()->text->
SetSelectionOverString(replacestring.c_str());
- current_view->currentBuffer()->update(1);
+ current_view->buffer()->update(1);
replace_count++;
}
} while( SearchCB(true) );
return(false);
current_view->getScreen()->HideCursor();
- current_view->currentBuffer()->update(-2);
- ltCur = current_view->currentBuffer()->text;
+ current_view->buffer()->update(-2);
+ ltCur = current_view->buffer()->text;
if (ltCur->selection)
ltCur->cursor = fForward ? ltCur->sel_end_cursor :
ltCur->sel_start_cursor;
if (!ValidSearchData() ||
(fForward ? SearchForward(ltCur) : SearchBackward(ltCur))) {
- current_view->currentBuffer()->update(-2);
+ current_view->buffer()->update(-2);
// clear the selection (if there is any)
current_view->getScreen()->ToggleSelection();
- current_view->currentBuffer()->text->ClearSelection();
+ current_view->buffer()->text->ClearSelection();
// set the new selection
- SetSelectionOverLenChars(current_view->currentBuffer()->text, iLenSelected);
+ SetSelectionOverLenChars(current_view->buffer()->text, iLenSelected);
current_view->getScreen()->ToggleSelection(false);
minibuffer->Set(_("Found."));
result = true;
bool LyXFindReplace1::SearchForward(LyXText * lt)
{
LyXParagraph * par = lt->cursor.par;
-#ifdef NEW_TEXT
LyXParagraph::size_type pos = lt->cursor.pos;
-#else
- int pos = lt->cursor.pos;
-#endif
- while (par && !IsSearchStringInText(par,pos)) {
+ while (par && !IsSearchStringInText(par, pos)) {
if (pos<par->Last()-1)
pos++;
else {
}
}
if (par) {
- lt->SetCursor(par,pos);
+ lt->SetCursor(par, pos);
return true;
} else
return false;
pos = par->Last()-1;
} while (par && pos<0);
}
- } while (par && !IsSearchStringInText(par,pos));
+ } while (par && !IsSearchStringInText(par, pos));
if (par) {
- lt->SetCursor(par,pos);
+ lt->SetCursor(par, pos);
return true;
} else
return false;
// returns true if the search string is at the specified position
// (Copied from the original "LyXText::IsStringInText" in text2.C )
-#ifdef NEW_TEXT
bool LyXFindReplace1::IsSearchStringInText(LyXParagraph * par,
LyXParagraph::size_type pos)
-#else
-bool LyXFindReplace1::IsSearchStringInText(LyXParagraph * par,
- int pos)
-#endif
{
char chSrch = 0;
char chText;