!= labels.end()) {
beforeChange(text);
text->SetCursor(this, it.getPar(), it.getPos());
- text->sel_cursor = text->cursor;
+ text->selection.cursor = text->cursor;
update(text, BufferView::SELECT|BufferView::FITCUR);
return true;
}
}
}
update(text, BufferView::SELECT|BufferView::FITCUR);
- text->sel_cursor = text->cursor;
+ text->selection.cursor = text->cursor;
}
if (bv_->text) {
par = bv_->text->cursor.par();
pos = bv_->text->cursor.pos();
- selstartpar = bv_->text->sel_start_cursor.par();
- selstartpos = bv_->text->sel_start_cursor.pos();
- selendpar = bv_->text->sel_end_cursor.par();
- selendpos = bv_->text->sel_end_cursor.pos();
- selection = bv_->text->selection;
- mark_set = bv_->text->mark_set;
+ selstartpar = bv_->text->selection.start.par();
+ selstartpos = bv_->text->selection.start.pos();
+ selendpar = bv_->text->selection.end.par();
+ selendpos = bv_->text->selection.end.pos();
+ selection = bv_->text->selection.set();
+ mark_set = bv_->text->selection.mark();
the_locking_inset = bv_->text->the_locking_inset;
delete bv_->text;
bv_->text = new LyXText(bv_);
updateScreen();
if (par) {
- bv_->text->selection = true;
+ bv_->text->selection.set(true);
/* at this point just to avoid the Delete-Empty-Paragraph
* Mechanism when setting the cursor */
- bv_->text->mark_set = mark_set;
+ bv_->text->selection.mark(mark_set);
if (selection) {
bv_->text->SetCursor(bv_, selstartpar, selstartpos);
- bv_->text->sel_cursor = bv_->text->cursor;
+ bv_->text->selection.cursor = bv_->text->cursor;
bv_->text->SetCursor(bv_, selendpar, selendpos);
bv_->text->SetSelection(bv_);
bv_->text->SetCursor(bv_, par, pos);
} else {
bv_->text->SetCursor(bv_, par, pos);
- bv_->text->sel_cursor = bv_->text->cursor;
- bv_->text->selection = false;
+ bv_->text->selection.cursor = bv_->text->cursor;
+ bv_->text->selection.set(false);
}
// remake the inset locking
bv_->text->the_locking_inset = the_locking_inset;
bv_->text->SetCursorFromCoordinates(bv_, x, y + bv_->text->first);
- if (!bv_->text->selection)
+ if (!bv_->text->selection.set())
update(bv_->text, BufferView::UPDATE); // Maybe an empty line was deleted
bv_->text->SetSelection(bv_);
// Middle button press pastes if we have a selection
bool paste_internally = false;
if (button == 2
- && bv_->text->selection) {
+ && bv_->text->selection.set()) {
owner_->getLyXFunc()->Dispatch(LFUN_COPY);
paste_internally = true;
}
if (!inset_hit) // otherwise it was already set in checkInsetHit(...)
bv_->text->SetCursorFromCoordinates(bv_, xpos, ypos + screen_first);
bv_->text->FinishUndo();
- bv_->text->sel_cursor = bv_->text->cursor;
+ bv_->text->selection.cursor = bv_->text->cursor;
bv_->text->cursor.x_fix(bv_->text->cursor.x());
owner_->updateLayoutChoice();
screen_->HideCursor();
screen_->ToggleSelection(text, bv_);
text->CursorHome(bv_);
- text->sel_cursor = text->cursor;
+ text->selection.cursor = text->cursor;
text->CursorEnd(bv_);
text->SetSelection(bv_);
screen_->ToggleSelection(text, bv_, false);
{
owner_->updateLayoutChoice();
- if (!text->selection && (f & SELECT)) {
- text->sel_cursor = text->cursor;
+ if (!text->selection.set() && (f & SELECT)) {
+ text->selection.cursor = text->cursor;
}
text->FullRebreak(bv_);
{
LyXText * lt = bv_->getLyXText();
- if (selecting || lt->mark_set) {
+ if (selecting || lt->selection.mark()) {
lt->SetSelection(bv_);
if (lt->bv_owner)
bv_->toggleToggle();
LyXText * lt = bv_->getLyXText();
bool is_rtl = lt->cursor.par()->isRightToLeftPar(buffer_->params);
- if (!lt->mark_set)
+ if (!lt->selection.mark())
beforeChange(lt);
update(lt, BufferView::SELECT|BufferView::FITCUR);
if (is_rtl)
// it simpler? (Lgb)
LyXText * lt = bv_->getLyXText();
bool is_rtl = lt->cursor.par()->isRightToLeftPar(buffer_->params);
- if (!lt->mark_set)
+ if (!lt->selection.mark())
beforeChange(lt);
update(lt, BufferView::SELECT|BufferView::FITCUR);
LyXCursor const & cur = lt->cursor;
{
LyXText * lt = bv_->getLyXText();
- if (!lt->mark_set)
+ if (!lt->selection.mark())
beforeChange(lt);
update(lt, BufferView::UPDATE);
lt->CursorUp(bv_);
{
LyXText * lt = bv_->getLyXText();
- if (!lt->mark_set)
+ if (!lt->selection.mark())
beforeChange(lt);
update(lt, BufferView::UPDATE);
lt->CursorDown(bv_);
{
LyXText * lt = bv_->getLyXText();
- if (!lt->mark_set)
+ if (!lt->selection.mark())
beforeChange(lt);
update(lt, BufferView::UPDATE);
lt->CursorUpParagraph(bv_);
{
LyXText * lt = bv_->getLyXText();
- if (!lt->mark_set)
+ if (!lt->selection.mark())
beforeChange(lt);
update(lt, BufferView::UPDATE);
lt->CursorDownParagraph(bv_);
{
LyXText * lt = bv_->getLyXText();
- if (!lt->mark_set)
+ if (!lt->selection.mark())
beforeChange(lt);
update(lt, BufferView::UPDATE);
cursorPrevious(lt);
{
LyXText * lt = bv_->getLyXText();
- if (!lt->mark_set)
+ if (!lt->selection.mark())
beforeChange(lt);
update(lt, BufferView::UPDATE);
cursorNext(lt);
{
LyXText * lt = bv_->getLyXText();
- if (!lt->mark_set)
+ if (!lt->selection.mark())
beforeChange(lt);
update(lt, BufferView::SELECT|BufferView::FITCUR);
lt->CursorHome(bv_);
{
LyXText * lt = bv_->getLyXText();
- if (!lt->mark_set)
+ if (!lt->selection.mark())
beforeChange(lt);
update(lt,
BufferView::SELECT|BufferView::FITCUR);
{
LyXText * lt = bv_->getLyXText();
- if (!lt->mark_set)
+ if (!lt->selection.mark())
beforeChange(lt);
update(lt,
BufferView::SELECT|BufferView::FITCUR);
{
LyXText * lt = bv_->getLyXText();
- if (!lt->mark_set)
+ if (!lt->selection.mark())
beforeChange(lt);
update(lt, BufferView::SELECT|BufferView::FITCUR);
if (lt->cursor.par()->isRightToLeftPar(buffer_->params))
{
LyXText * lt = bv_->getLyXText();
- if (!lt->mark_set)
+ if (!lt->selection.mark())
beforeChange(lt);
update(lt, BufferView::SELECT|BufferView::FITCUR);
if (lt->cursor.par()->isRightToLeftPar(buffer_->params))
{
LyXText * lt = bv_->getLyXText();
- if (!lt->mark_set)
+ if (!lt->selection.mark())
beforeChange(lt);
update(lt,
BufferView::SELECT|BufferView::FITCUR);
{
LyXText * lt = bv_->getLyXText();
- if (!lt->mark_set)
+ if (!lt->selection.mark())
beforeChange(lt);
update(lt,
BufferView::SELECT|BufferView::FITCUR);
{
LyXText * lt = bv_->getLyXText();
- if (lt->mark_set) {
+ if (lt->selection.mark()) {
beforeChange(lt);
update(lt,
BufferView::SELECT
owner_->getLyXFunc()->setMessage(N_("Mark removed"));
} else {
beforeChange(lt);
- lt->mark_set = 1;
+ lt->selection.mark(true);
update(lt,
BufferView::SELECT
| BufferView::FITCUR);
owner_->getLyXFunc()->setMessage(N_("Mark set"));
}
- lt->sel_cursor = lt->cursor;
+ lt->selection.cursor = lt->cursor;
}
break;
{
LyXText * lt = bv_->getLyXText();
- if (!lt->selection) {
+ if (!lt->selection.set()) {
lt->Delete(bv_);
- lt->sel_cursor = lt->cursor;
+ lt->selection.cursor = lt->cursor;
update(lt,
BufferView::SELECT
| BufferView::FITCUR
LyXCursor cursor = lt->cursor;
- if (!lt->selection) {
+ if (!lt->selection.set()) {
if (cursor.pos() == cursor.par()->size()) {
lt->CursorRight(bv_);
cursor = lt->cursor;
} else {
lt->CursorLeft(bv_);
lt->Delete(bv_);
- lt->sel_cursor = lt->cursor;
+ lt->selection.cursor = lt->cursor;
update(lt,
BufferView::SELECT
| BufferView::FITCUR
}
} else {
lt->Delete(bv_);
- lt->sel_cursor = lt->cursor;
+ lt->selection.cursor = lt->cursor;
update(lt,
BufferView::SELECT
| BufferView::FITCUR
/* -------> Delete word backward. */
case LFUN_DELETE_WORD_BACKWARD:
- update(bv_->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
- bv_->getLyXText()->DeleteWordBackward(bv_);
- update(bv_->getLyXText(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+ {
+ LyXText * lt = bv_->getLyXText();
+
+ update(lt, BufferView::SELECT|BufferView::FITCUR);
+ lt->DeleteWordBackward(bv_);
+ update(lt,
+ BufferView::SELECT
+ | BufferView::FITCUR
+ | BufferView::CHANGE);
moveCursorUpdate(false);
owner_->showState();
- break;
+ }
+ break;
/* -------> Kill to end of line. */
case LFUN_DELETE_LINE_FORWARD:
- update(bv_->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
- bv_->getLyXText()->DeleteLineForward(bv_);
- update(bv_->getLyXText(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+ {
+ LyXText * lt = bv_->getLyXText();
+
+ update(lt, BufferView::SELECT|BufferView::FITCUR);
+ lt->DeleteLineForward(bv_);
+ update(lt,
+ BufferView::SELECT
+ | BufferView::FITCUR
+ | BufferView::CHANGE);
moveCursorUpdate(false);
- break;
+ }
+ break;
/* -------> Set mark off. */
case LFUN_MARK_OFF:
- beforeChange(bv_->getLyXText());
- update(bv_->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
- bv_->getLyXText()->sel_cursor = bv_->getLyXText()->cursor;
+ {
+ LyXText * lt = bv_->getLyXText();
+
+ beforeChange(lt);
+ update(lt, BufferView::SELECT|BufferView::FITCUR);
+ lt->selection.cursor = lt->cursor;
owner_->getLyXFunc()->setMessage(N_("Mark off"));
- break;
+ }
+ break;
/* -------> Set mark on. */
case LFUN_MARK_ON:
- beforeChange(bv_->getLyXText());
- bv_->getLyXText()->mark_set = 1;
- update(bv_->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
- bv_->getLyXText()->sel_cursor = bv_->getLyXText()->cursor;
+ {
+ LyXText * lt = bv_->getLyXText();
+
+ beforeChange(lt);
+ lt->selection.mark(true);
+ update(lt, BufferView::SELECT|BufferView::FITCUR);
+ lt->selection.cursor = lt->cursor;
owner_->getLyXFunc()->setMessage(N_("Mark on"));
- break;
+ }
+ break;
case LFUN_BACKSPACE:
{
LyXText * lt = bv_->getLyXText();
- if (!lt->selection) {
+ if (!lt->selection.set()) {
if (owner_->getIntl()->getTrans().backspace()) {
lt->Backspace(bv_);
- lt->sel_cursor = lt->cursor;
+ lt->selection.cursor = lt->cursor;
update(lt,
BufferView::SELECT
| BufferView::FITCUR
LyXCursor cursor = lt->cursor;
- if (!lt->selection) {
+ if (!lt->selection.set()) {
if (cursor.pos() == 0
&& !(cursor.par()->params.spaceTop()
== VSpace (VSpace::NONE))) {
| BufferView::CHANGE);
} else {
lt->Backspace(bv_);
- lt->sel_cursor = cursor;
+ lt->selection.cursor = cursor;
update(lt,
BufferView::SELECT
| BufferView::FITCUR
BufferView::SELECT
| BufferView::FITCUR
| BufferView::CHANGE);
- lt->sel_cursor = lt->cursor;
+ lt->selection.cursor = lt->cursor;
setState();
owner_->showState();
break;
BufferView::SELECT
| BufferView::FITCUR
| BufferView::CHANGE);
- lt->sel_cursor = lt->cursor;
+ lt->selection.cursor = lt->cursor;
setState();
owner_->showState();
break;
BufferView::SELECT
| BufferView::FITCUR
| BufferView::CHANGE);
- lt->sel_cursor = cursor;
+ lt->selection.cursor = cursor;
setState();
owner_->showState();
}
LyXText * lt = bv_->getLyXText();
if (lyxrc.auto_region_delete) {
- if (lt->selection){
+ if (lt->selection.set()) {
lt->CutSelection(bv_, false);
bv_->update(lt,
BufferView::SELECT
| BufferView::FITCUR
| BufferView::CHANGE);
- lt->sel_cursor = lt->cursor;
+ lt->selection.cursor = lt->cursor;
moveCursorUpdate(false);
// real_current_font.number can change so we need to
char datetmp[32];
int const datetmp_len =
::strftime(datetmp, 32, arg.c_str(), now_tm);
+
+ LyXText * lt = bv_->getLyXText();
+
for (int i = 0; i < datetmp_len; i++) {
- bv_->getLyXText()->InsertChar(bv_, datetmp[i]);
- update(bv_->getLyXText(),
- BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+ lt->InsertChar(bv_, datetmp[i]);
+ update(lt,
+ BufferView::SELECT
+ | BufferView::FITCUR
+ | BufferView::CHANGE);
}
- bv_->getLyXText()->sel_cursor = bv_->getLyXText()->cursor;
+ lt->selection.cursor = lt->cursor;
moveCursorUpdate(false);
}
break;
+2001-05-31 Lars Gullik Bjønnes <larsbj@birdstep.com>
+
+ * text2.C: adjust
+ * text.C: adjust
+
+
+ * tabular.C (getTokenValue): add std::
+
+ * tabular-old.C (getTokenValue): add std::
+ (getTokenValue): ditto
+ (getTokenValue): ditto
+
+ * screen.C (ToggleSelection): adjust
+
+ * lyxtext.h: put selection cursors inside a Selection struct.
+
+ * lyxfunc.C (moveCursorUpdate): adjust
+
+ * lyxfont.C (latexWriteStartChanges): add std::
+
+ * lyxfind.C: adjust
+
+ * font.h: delete with(char const *, LyXFont const &)
+
+ * buffer.C (parseSingleLyXformat2Token): use contains instead of strstr
+
+ * FontInfo.C (getFontname): add std::
+
+ * BufferView_pimpl.C (resizeCurrentBuffer): adjust
+ (workAreaButtonPress): adjust
+ (tripleClick): adjust
+ (update): adjust
+ (moveCursorUpdate): adjust
+ (Dispatch): adjust
+
+ * BufferView2.C (gotoInset): adjust
+
2001-05-30 Juergen Vigna <jug@sad.it>
* spellchecker.C (USE_ORIGINAL_MANAGER_FUNCS): as it seems only I use
lyxerr[Debug::FONT] << "Exact font match with\n"
<< strings[i] << endl;
return strings[i];
- } else if (fabs(sizes[i] - size - 0.1) < error) {
- error = fabs(sizes[i] - size - 0.1);
+ } else if (std::fabs(sizes[i] - size - 0.1) < error) {
+ error = std::fabs(sizes[i] - size - 0.1);
closestind = i;
}
}
if (scalable && lyxrc.use_scalable_fonts) {
// We can use scalable
- string font = resize(strings[scaleindex], size);
+ string const font = resize(strings[scaleindex], size);
lyxerr[Debug::FONT] << "Using scalable font to get\n"
<< font << endl;
return font;
} else if (tmp == "Enumerate") {
ltype = 2;
ltype_depth = depth + 1;
- } else if (strstr(tmp.c_str(), "ection")) {
+ } else if (contains(tmp, "ection")) {
ltype = 3;
ltype_depth = depth + 1;
- } else if (strstr(tmp.c_str(), "aragraph")) {
+ } else if (contains(tmp, "aragraph")) {
ltype = 4;
ltype_depth = depth + 1;
} else if (tmp == "Description") {
return width(s.c_str(), s.length(), f);
}
///
- static
- int width(char const * s, LyXFont const & f) {
- return width(s, strlen(s), f);
- }
+ //static
+ //int width(char const * s, LyXFont const & f) {
+ // return width(s, strlen(s), f);
+ //}
///
static
int signedWidth(string const & s, LyXFont const & f);
+2001-05-31 Lars Gullik Bjønnes <larsbj@birdstep.com>
+
+ * MathsSymbols.C (pixmapFromBitmapData): add std::
+
+ * FormMathsMatrix.C (AlignFilter): add std::
+
2001-05-22 Adrien Rebollo <rebollo@iaf.cnrs-gif.fr>
* FormDocument.C (build): add iso8859-15 support.
#include <cstdlib>
#include <pwd.h>
#include <grp.h>
-#include <cstring>
+//#include <cstring>
#include <map>
#include <algorithm>
int FormMathsMatrix::AlignFilter(char const * cur, int c)
{
- int n = int(fl_get_slider_value(dialog_->slider_columns)+0.5) -
- int(strlen(cur));
+ int const n = int(fl_get_slider_value(dialog_->slider_columns) + 0.5) -
+ int(std::strlen(cur));
if (n < 0)
return FL_INVALID;
XpmCreateDataFromImage(fl_get_display(), const_cast<char***>(&data), sbima, sbima, 0);
// Dirty hack to get blue symbols quickly
- char * sx = const_cast<char*>(strstr(data[2], "FFFFFFFF"));
+ char * sx = const_cast<char*>(std::strstr(data[2], "FFFFFFFF"));
if (sx) {
for (int k = 0; k < 8; ++k) sx[k] = '0';
}
#endif
#include "combox.h"
-#include <cstring>
+//#include <cstring>
#include "debug.h"
+2001-05-31 Lars Gullik Bjønnes <larsbj@birdstep.com>
+
+ * insettext.C: adjust
+
+ * insetgraphics.[Ch] (statusMessage): change to return string
+ (width): adjust
+ (draw): adjust
+
+ * figinset.C (runqueue): add std::
+ (Recompute): ditto
+
2001-05-28 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* insetcite.C (Ascii): add std:: qualifier
env[0] = new char[tmp.size() + 1];
std::copy(tmp.begin(), tmp.end(), env[0]);
env[0][tmp.size()] = '\0';
- ::memcpy(&env[1], environ, sizeof(char*) * (ne + 1));
+ std::memcpy(&env[1], environ,
+ sizeof(char*) * (ne + 1));
environ = env;
// now make gs command
wid + 1, hgh + 1);
} else {
- char const * msg = 0;
+ //char const * msg = 0;
+ string msg;
string lfname = fname;
if (!fname.empty() && GetExtension(fname).empty())
lfname += ".eps";
else if (lyxrc.ps_command.empty())
msg = _("[no ghostscript]");
- if (!msg) msg = _("[unknown error]");
+ if (msg.empty()) msg = _("[unknown error]");
font.setFamily(LyXFont::SANS_FAMILY);
font.setSize(LyXFont::SIZE_FOOTNOTE);
- string justname = OnlyFilename (fname);
+ string const justname = OnlyFilename (fname);
pain.text(int(x + 8), baseline - lyxfont::maxAscent(font) - 4,
justname, font);
font.setSize(LyXFont::SIZE_TINY);
- pain.text(int(x + 8), baseline - 4, msg, strlen(msg), font);
+ pain.text(int(x + 8), baseline - 4, msg, font);
}
x += width(bv, font); // ?
}
if (changed) GetPSSizes();
- float sin_a = sin (angle / DEG2PI); /* rotation; H. Zeller 021296 */
- float cos_a = cos (angle / DEG2PI);
- int frame_wid = int(ceil(fabs(cos_a * pswid) + fabs(sin_a * pshgh)));
- int frame_hgh= int(ceil(fabs(cos_a * pshgh) + fabs(sin_a * pswid)));
+ float sin_a = std::sin (angle / DEG2PI); /* rotation; H. Zeller 021296 */
+ float cos_a = std::cos (angle / DEG2PI);
+ int frame_wid = int(ceil(std::fabs(cos_a * pswid) + std::fabs(sin_a * pshgh)));
+ int frame_hgh= int(ceil(std::fabs(cos_a * pshgh) + std::fabs(sin_a * pswid)));
string lfname = fname;
if (GetExtension(fname).empty())
}
-char const *
+string const
InsetGraphics::statusMessage() const
{
- char const * msg = 0;
+ string msg;
if (cacheHandle.get()) {
switch (cacheHandle->getImageStatus()) {
if (cacheHandle.get() && (pixmap = cacheHandle->getImage()))
return pixmap->getWidth();
else {
- char const * msg = statusMessage();
+ string const msg = statusMessage();
int font_width = 0;
- if (msg)
+ if (!msg.empty())
font_width = lyxfont::width(msg, font);
return std::max(50, font_width + 15);
return;
}
- char const * msg = statusMessage();
+ string const msg = statusMessage();
paint.rectangle(int(old_x) + 2, baseline - lascent,
lwidth - 4,
lascent + ldescent);
- if (msg) {
+ if (!msg.empty()) {
// Print the message.
LyXFont msgFont(font);
msgFont.setFamily(LyXFont::SANS_FAMILY);
msgFont.setSize(LyXFont::SIZE_TINY);
paint.text(int(old_x) + 8, baseline - 4,
- msg, strlen(msg), msgFont);
+ msg, msgFont);
}
}
}
/// Update the inset after parameter change.
void updateInset() const;
/// Get the status message, depends on the image loading status.
- char const * statusMessage() const;
+ string const statusMessage() const;
/// Create the options for the latex command.
string const createLatexOptions() const;
/// Convert the file if needed, and return the location of the file.
inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset;
}
- if (!cleared && (need_update == CURSOR) && !TEXT(bv)->selection) {
+ if (!cleared && (need_update == CURSOR) && !TEXT(bv)->selection.set()) {
drawFrame(pain, cleared);
x += width(bv, f);
need_update = NONE;
if (need_update & CURSOR) {
bv->screen()->ToggleSelection(TEXT(bv), bv, true, y_offset,int(x));
TEXT(bv)->ClearSelection(bv);
- TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+ TEXT(bv)->selection.cursor = TEXT(bv)->cursor;
}
bv->screen()->Update(TEXT(bv), bv, y_offset, int(x));
} else {
else if (need_update & CURSOR) {
bv->screen()->ToggleSelection(TEXT(bv), bv, true, y_offset,int(x));
TEXT(bv)->ClearSelection(bv);
- TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+ TEXT(bv)->selection.cursor = TEXT(bv)->cursor;
}
bv->screen()->Update(TEXT(bv), bv, y_offset, int(x));
locked = true;
TEXT(bv)->FullRebreak(bv);
SetUpdateStatus(bv, what);
if ((need_update != CURSOR) || (TEXT(bv)->status != LyXText::UNCHANGED) ||
- TEXT(bv)->selection)
+ TEXT(bv)->selection.set())
bv->updateInset(this, mark_dirty);
bv->owner()->showState();
if (old_par != cpar(bv)) {
if (!checkAndActivateInset(bv, x, tmp_y, button))
TEXT(bv)->SetCursorFromCoordinates(bv, x - drawTextXOffset,
y + insetAscent);
- TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+ TEXT(bv)->selection.cursor = TEXT(bv)->cursor;
bv->text->FinishUndo();
ShowInsetCursor(bv);
UpdateLocal(bv, CURSOR, false);
no_selection = false;
locked = false;
int code = CURSOR|CLEAR_FRAME;
- if (TEXT(bv)->selection) {
+ if (TEXT(bv)->selection.set()) {
TEXT(bv)->ClearSelection(bv);
code = FULL;
} else if (owner())
}
if (!inset) { // && (button == 2)) {
bool paste_internally = false;
- if ((button == 2) && TEXT(bv)->selection) {
+ if ((button == 2) && TEXT(bv)->selection.set()) {
LocalDispatch(bv, LFUN_COPY, "");
paste_internally = true;
}
TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset,
y + insetAscent);
- TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+ TEXT(bv)->selection.cursor = TEXT(bv)->cursor;
UpdateLocal(bv, CURSOR, false);
bv->owner()->setLayout(cpar(bv)->GetLayout());
old_par = cpar(bv);
bv->text->cursor.par()->next());
bv->setState();
if (lyxrc.auto_region_delete) {
- if (TEXT(bv)->selection){
+ if (TEXT(bv)->selection.set()) {
TEXT(bv)->CutSelection(bv, false);
}
}
}
}
}
- TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+ TEXT(bv)->selection.cursor = TEXT(bv)->cursor;
UpdateLocal(bv, CURSOR_PAR, true);
result=DISPATCHED_NOUPDATE;
break;
bv->text->SetUndo(bv->buffer(), Undo::DELETE,
bv->text->cursor.par()->previous(),
bv->text->cursor.par()->next());
- if (TEXT(bv)->selection)
+ if (TEXT(bv)->selection.set())
TEXT(bv)->CutSelection(bv);
else
TEXT(bv)->Backspace(bv);
bv->text->SetUndo(bv->buffer(), Undo::DELETE,
bv->text->cursor.par()->previous(),
bv->text->cursor.par()->next());
- if (TEXT(bv)->selection)
+ if (TEXT(bv)->selection.set())
TEXT(bv)->CutSelection(bv);
else
TEXT(bv)->Delete(bv);
return DISPATCHED;
TEXT(bv)->CursorRight(bv);
if (!selecting)
- TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+ TEXT(bv)->selection.cursor = TEXT(bv)->cursor;
return DISPATCHED_NOUPDATE;
}
return FINISHED;
TEXT(bv)->CursorLeft(bv);
if (!selecting)
- TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+ TEXT(bv)->selection.cursor = TEXT(bv)->cursor;
if (activate_inset && checkAndActivateInset(bv, behind))
return DISPATCHED;
return DISPATCHED_NOUPDATE;
void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall,
bool selectall)
{
- if (TEXT(bv)->selection) {
+ if (TEXT(bv)->selection.set()) {
bv->text->SetUndo(bv->buffer(), Undo::EDIT,
bv->text->cursor.par()->previous(),
bv->text->cursor.par()->next());
if (selectall)
TEXT(bv)->ClearSelection(bv);
bv->fitCursor(TEXT(bv));
- if (selectall || TEXT(bv)->selection)
+ if (selectall || TEXT(bv)->selection.set())
UpdateLocal(bv, FULL, true);
else
UpdateLocal(bv, CURSOR_PAR, true);
bool boundary = false;
bool selstartboundary = false;
bool selendboundary = false;
- int selection = 0;
- int mark_set = 0;
+ bool selection = false;
+ bool mark_set = false;
// ProhibitInput(bv);
lpar = TEXT(bv)->cursor.par();
pos = TEXT(bv)->cursor.pos();
boundary = TEXT(bv)->cursor.boundary();
- selstartpar = TEXT(bv)->sel_start_cursor.par();
- selstartpos = TEXT(bv)->sel_start_cursor.pos();
- selstartboundary = TEXT(bv)->sel_start_cursor.boundary();
- selendpar = TEXT(bv)->sel_end_cursor.par();
- selendpos = TEXT(bv)->sel_end_cursor.pos();
- selendboundary = TEXT(bv)->sel_end_cursor.boundary();
- selection = TEXT(bv)->selection;
- mark_set = TEXT(bv)->mark_set;
+ selstartpar = TEXT(bv)->selection.start.par();
+ selstartpos = TEXT(bv)->selection.start.pos();
+ selstartboundary = TEXT(bv)->selection.start.boundary();
+ selendpar = TEXT(bv)->selection.end.par();
+ selendpos = TEXT(bv)->selection.end.pos();
+ selendboundary = TEXT(bv)->selection.end.boundary();
+ selection = TEXT(bv)->selection.set();
+ mark_set = TEXT(bv)->selection.mark();
}
deleteLyXText(bv, (the_locking_inset == 0));
if (lpar) {
- TEXT(bv)->selection = true;
+ TEXT(bv)->selection.set(true);
/* at this point just to avoid the Delete-Empty-Paragraph
* Mechanism when setting the cursor */
- TEXT(bv)->mark_set = mark_set;
+ TEXT(bv)->selection.mark(mark_set);
if (selection) {
TEXT(bv)->SetCursor(bv, selstartpar, selstartpos,
true, selstartboundary);
- TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+ TEXT(bv)->selection.cursor = TEXT(bv)->cursor;
TEXT(bv)->SetCursor(bv, selendpar, selendpos,
true, selendboundary);
TEXT(bv)->SetSelection(bv);
TEXT(bv)->SetCursor(bv, lpar, pos);
} else {
TEXT(bv)->SetCursor(bv, lpar, pos, true, boundary);
- TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
- TEXT(bv)->selection = false;
+ TEXT(bv)->selection.cursor = TEXT(bv)->cursor;
+ TEXT(bv)->selection.set(false);
}
}
if (bv->screen())
void InsetText::selectAll(BufferView * bv)
{
TEXT(bv)->CursorTop(bv);
- TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+ TEXT(bv)->selection.cursor = TEXT(bv)->cursor;
TEXT(bv)->CursorBottom(bv);
TEXT(bv)->SetSelection(bv);
}
#include <config.h>
-#include <cstring>
+//#include <cstring>
#include <X11/Xlib.h>
#ifdef __GNUG__
* ====================================================== */
#include <config.h>
-#include <cstring>
+//#include <cstring>
#include <X11/Xlib.h>
#include "gettext.h"
bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR);
LyXText * ltCur = bv->text;
- if (ltCur->selection)
- ltCur->cursor = forward ? ltCur->sel_end_cursor
- : ltCur->sel_start_cursor;
+ if (ltCur->selection.set())
+ ltCur->cursor = forward ? ltCur->selection.end
+ : ltCur->selection.start;
if (forward
? SearchForward(bv, searchstr, casesens, matchwrd)
os << '\\'
<< LaTeXFamilyNames[f.family()]
<< '{';
- count += strlen(LaTeXFamilyNames[f.family()]) + 2;
+ count += std::strlen(LaTeXFamilyNames[f.family()]) + 2;
env = true; //We have opened a new environment
}
if (f.series() != INHERIT_SERIES) {
os << '\\'
<< LaTeXSeriesNames[f.series()]
<< '{';
- count += strlen(LaTeXSeriesNames[f.series()]) + 2;
+ count += std::strlen(LaTeXSeriesNames[f.series()]) + 2;
env = true; //We have opened a new environment
}
if (f.shape() != INHERIT_SHAPE) {
os << '\\'
<< LaTeXShapeNames[f.shape()]
<< '{';
- count += strlen(LaTeXShapeNames[f.shape()]) + 2;
+ count += std::strlen(LaTeXShapeNames[f.shape()]) + 2;
env = true; //We have opened a new environment
}
if (f.color() != LColor::inherit && f.color() != LColor::ignore) {
os << '\\'
<< LaTeXSizeNames[f.size()]
<< ' ';
- count += strlen(LaTeXSizeNames[f.size()]) + 2;
+ count += std::strlen(LaTeXSizeNames[f.size()]) + 2;
}
return count;
}
#include <cstdlib>
#include <cctype>
-#include <cstring>
+//#include <cstring>
#ifdef __GNUG__
#pragma implementation
inline
void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
{
- if (selecting || TEXT(flag)->mark_set) {
+ if (selecting || TEXT(flag)->selection.mark()) {
TEXT(flag)->SetSelection(owner->view());
if (TEXT(flag)->bv_owner)
owner->view()->toggleToggle();
// copied verbatim from do_accent_char
owner->view()->update(TEXT(false),
BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
- TEXT(false)->sel_cursor = TEXT(false)->cursor;
+ TEXT(false)->selection.cursor = TEXT(false)->cursor;
}
#include <config.h>
-#include <cstring>
+//#include <cstring>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
it should not be absolutely needed to move the cursor...
*/
mutable LyXCursor cursor;
-
+
+#if 0
/* the selection cursor */
///
mutable bool selection;
mutable LyXCursor sel_start_cursor;
///
mutable LyXCursor sel_end_cursor;
+#else
+ /** The structrue that keeps track of the selections set. */
+ struct Selection {
+ bool set() const {
+ return set_;
+ }
+ void set(bool s) {
+ set_ = s;
+ }
+ bool mark() const {
+ return mark_;
+ }
+ void mark(bool m) {
+ mark_ = m;
+ }
+ LyXCursor cursor;
+ LyXCursor start;
+ LyXCursor end;
+ private:
+ bool set_; // former selection
+ bool mark_; // former mark_set
+
+ };
+ mutable Selection selection;
+#endif
/// needed for the toggling
LyXCursor last_sel_cursor;
///
+2001-05-31 Lars Gullik Bjønnes <larsbj@birdstep.com>
+
+ * math_parser.C (yylex): use contains instead of strchr
+ (parse_align): remove last arg, change to take string const & as
+ first arg.
+ (mathed_parse): use string for ar2 and ar, adjust
+
+ * math_decorationinset.C (Write): use compare instead of strcmp
+
+ * formula.C (LocalDispatch): change arg2 to string, adjust for this
+ (LocalDispatch): add std::
+ (LocalDispatch): use contains instead of strchr
+
+ * array.C (move): add std::
+
2001-05-02 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* matriz.C: add using directives when needed for C functions
{
if (p <= last_) {
need_size(last_ + shift);
- memmove(&bf_[p + shift], &bf_[p], last_ - p);
+ std::memmove(&bf_[p + shift], &bf_[p], last_ - p);
last_ += shift;
bf_[last_] = 0;
}
{
bv->lockedInsetStoreUndo(Undo::INSERT);
char s[80];
- char arg2[80];
+ //char arg2[80];
+
// This is just so that too long args won't ooze out of s.
- strncpy(arg2, arg.c_str(), 80);
- arg2[79]= '\0';
+ //strncpy(arg2, arg.c_str(), 80);
+ //arg2[79]= '\0';
+ string arg2(arg, 0, 80);
+
int m;
int n;
- int const k = sscanf(arg2, "%d %d %s", &m, &n, s);
+ int const k = sscanf(arg2.c_str(), "%d %d %s", &m, &n, s);
s[79] = '\0';
if (k < 1) {
if (mathcursor) {
MathMatrixInset * p = new MathMatrixInset(m, n);
- if (k > 2 && int(strlen(s)) > m)
+ if (k > 2 && int(std::strlen(s)) > m)
p->SetAlign(s[0], &s[1]);
mathcursor->insertInset(p, LM_TC_ACTIVE_INSET);
// Andre:
bv->lockedInsetStoreUndo(Undo::INSERT);
char lf[40];
char rg[40];
- char arg2[40];
+ //char arg2[40];
int ilf = '(';
int irg = '.';
latexkeys const * l;
if (arg.empty())
break;
- ::strncpy(arg2, arg.c_str(), 40);
- arg2[39]= '\0';
- int const n = sscanf(arg2, "%s %s", lf, rg);
+ //::strncpy(arg2, arg.c_str(), 40);
+ //arg2[39]= '\0';
+ string arg2(arg, 0, 40);
+
+ int const n = sscanf(arg2.c_str(), "%s %s", lf, rg);
lf[39] = '\0';
rg[39] = '\0';
if (greek_kb_flag < 2)
greek_kb_flag = 0;
-
+#if 0
} else if (strchr("!,:;{}", c) && (varcode == LM_TC_TEX||was_macro)) {
+#else
+ } else if (contains("!,:;{}", c)
+ && (varcode == LM_TC_TEX||was_macro)) {
+#endif
mathcursor->Insert(c, LM_TC_TEX);
if (c == '{') {
mathcursor->Insert('}', LM_TC_TEX);
mathcursor->MacroModeOpen();
mathcursor->clearLastCode();
mathcursor->Insert(c, LM_TC_MIN);
- } else if (('0'<= c && c<= '9') || strchr(";:!|[]().,?", c)) {
+ } else if (('0'<= c && c<= '9') ||
+#if 0
+ strchr(";:!|[]().,?", c)
+#else
+ contains(";:!|[]().,?", c)
+#endif
+ ) {
mathcursor->Insert(c, LM_TC_CONST);
- } else if (strchr("+/-*<>=", c)) {
+ } else if (
+#if 0
+ strchr("+/-*<>=", c)
+#else
+ contains("+/-*<>=", c)
+#endif
+ ) {
mathcursor->Insert(c, LM_TC_BOP);
- } else if (strchr(latex_special_chars, c) && c!= '_') {
+ } else if (
+#if 0
+ strchr(latex_special_chars, c)
+#else
+ contains(latex_special_chars, c)
+#endif
+ && c!= '_') {
mathcursor->Insert(c, LM_TC_SPECIAL);
} else if (c == '_' || c == '^') {
char s[2];
#include "mathed/support.h"
#include "math_parser.h"
#include "support/LOstream.h"
+#include "support/lstrings.h"
+
using std::ostream;
{
latexkeys const * l = lm_get_key_by_id(deco_, LM_TK_WIDE);
if (fragile &&
- (strcmp(l->name, "overbrace") == 0 ||
- strcmp(l->name, "underbrace") == 0 ||
- strcmp(l->name, "overleftarrow") == 0 ||
- strcmp(l->name, "overrightarrow") == 0))
+ (compare(l->name, "overbrace") == 0 ||
+ compare(l->name, "underbrace") == 0 ||
+ compare(l->name, "overleftarrow") == 0 ||
+ compare(l->name, "overrightarrow") == 0))
os << "\\protect";
os << '\\' << l->name << '{';
MathParInset::Write(os, fragile);
yylval.i = LM_OT_PAR;
return LM_TK_END;
}
- if (strchr(latex_special_chars, c)) {
+ if (
+#if 0
+ strchr(latex_special_chars, c)
+#else
+ contains(latex_special_chars, c)
+#endif
+ ) {
yylval.i = c;
return LM_TK_SPECIAL;
}
}
-int parse_align(char * hor, char *)
+#if 0
+int parse_align(char const * hor)
{
int nc = 0;
for (char * c = hor; c && *c > ' '; ++c) ++nc;
return nc;
}
-
+#else
+int parse_align(string const & hor)
+{
+ int nc = 0;
+ string::const_iterator cit = hor.begin();
+ string::const_iterator end = hor.end();
+ for (; cit != end; ++cit)
+ if (*cit > ' ') ++nc;
+ return nc;
+}
+#endif
// Accent hacks only for 0.12. Stolen from Cursor.
int accent = 0;
case LM_TK_BEGIN:
if (yylval.i == LM_OT_MATRIX) {
//lyxerr << "###### Reading LM_OT_MATRIX \n";
+#if 0
char ar[120];
char ar2[8];
- ar[0] = ar2[0] = '\0';
+ ar[0] = ar2[0] = '\0';
+#endif
char rg = LexGetArg(0);
+#if 1
+ string ar2;
+#endif
if (rg == ']') {
+#if 0
strcpy(ar2, yytext.data());
+#else
+ ar2 = yytext.data();
+#endif
rg = LexGetArg('{');
}
+#if 0
strcpy(ar, yytext.data());
- int const nc = parse_align(ar, ar2);
+ int const nc = parse_align(ar);
+#else
+ string ar(yytext.data());
+ int const nc = parse_align(ar);
+#endif
MathParInset * mm = new MathMatrixInset(nc, 0);
mm->SetAlign(ar2[0], ar);
#include <config.h>
-#include <cstring>
+#include <cstring> // memcpy
#include "matriz.h"
int y_offset, int x_offset)
{
// only if there is a selection
- if (!text->selection) return;
+ if (!text->selection.set()) return;
int const bottom = min(
- max(static_cast<int>(text->sel_end_cursor.y()
- - text->sel_end_cursor.row()->baseline()
- + text->sel_end_cursor.row()->height()),
+ max(static_cast<int>(text->selection.end.y()
+ - text->selection.end.row()->baseline()
+ + text->selection.end.row()->height()),
text->first),
static_cast<int>(text->first + owner.height()));
int const top = min(
- max(static_cast<int>(text->sel_start_cursor.y() -
- text->sel_start_cursor.row()->baseline()),
+ max(static_cast<int>(text->selection.start.y() -
+ text->selection.start.row()->baseline()),
text->first),
static_cast<int>(text->first + owner.height()));
if (kill_selection)
- text->selection = 0;
+ text->selection.set(false);
DrawFromTo(text, bv, top - text->first, bottom - text->first,
y_offset, x_offset);
expose(0, top - text->first,
#include <unistd.h>
#include <fcntl.h>
#include <cstdlib>
-#include <cstring>
+//#include <cstring>
#include <csignal>
#include <sys/wait.h>
#include <sys/types.h>
+2001-05-31 Lars Gullik Bjønnes <larsbj@birdstep.com>
+
+ * syscontr.C: add std::
+
+ * syscall.C: add std::
+
+ * lstrings.h (compare): add std::
+
+ * lstrings.C (prefixIs): add std::
+ (suffixIs): ditto
+ (subst): ditto
+
+ * LSubstring.C (LSubstring): add std::
+
2001-05-30 Lars Gullik Bjønnes <larsbj@birdstep.com>
* lyxsum.C (sum): use istreambuf_iterator when available.
LSubstring::LSubstring(string & s, string::value_type const * p)
: ps(&s)
{
- n = strlen(p);
+ n = std::strlen(p);
pos = s.find(p);
}
{
lyx::Assert(pre);
- size_t const l = strlen(pre);
+ size_t const l = std::strlen(pre);
string::size_type const alen = a.length();
if (l > alen || a.empty())
{
lyx::Assert(suf);
- size_t const suflen = strlen(suf);
+ size_t const suflen = std::strlen(suf);
string::size_type const alen = a.length();
if (suflen > alen)
string lstr(a);
string::size_type i = 0;
- string::size_type olen = strlen(oldstr);
+ string::size_type olen = std::strlen(oldstr);
while((i = lstr.find(oldstr, i)) != string::npos) {
lstr.replace(i, olen, newstr);
i += newstr.length(); // We need to be sure that we dont
#pragma interface
#endif
-#include <cstring>
+//#include <cstring>
#include <cctype>
#include "Lsstream.h"
inline
int compare(char const * a, char const * b)
{
- return strcmp(a, b);
+ return std::strcmp(a, b);
}
///
inline
int compare(char const * a, char const * b, unsigned int len)
{
- return strncmp(a, b, len);
+ return std::strncmp(a, b, len);
}
///
while (wait) {
pid_t waitrpid = waitpid(pid, &status, WUNTRACED);
if (waitrpid == -1) {
- lyxerr << "LyX: Error waiting for child:" << strerror(errno) << endl;
+ lyxerr << "LyX: Error waiting for child:"
+ << std::strerror(errno) << endl;
wait = false;
} else if (WIFEXITED(status)) {
// Child exited normally. Update return value.
#ifndef __EMX__
execvp(syscmd, argv);
// If something goes wrong, we end up here:
- lyxerr << "LyX: execvp failed: " << strerror(errno) << endl;
+ lyxerr << "LyX: execvp failed: "
+ << std::strerror(errno) << endl;
} else if (cpid < 0) { // error
#else
pid_t cpid = spawnvp(P_SESSION|P_DEFAULT|P_MINIMIZE|P_BACKGROUND, syscmd, argv);
if (cpid < 0) { // error
#endif
- lyxerr << "LyX: Could not fork: " << strerror(errno) << endl;
+ lyxerr << "LyX: Could not fork: "
+ << std::strerror(errno) << endl;
} else { // parent
return cpid;
}
int waitrpid = waitpid(pid, &stat_loc, WNOHANG);
if (waitrpid == -1) {
lyxerr << "LyX: Error waiting for child:"
- << strerror(errno) << endl;
+ << std::strerror(errno) << endl;
} else if (WIFEXITED(stat_loc) || WIFSIGNALED(stat_loc)) {
if (WIFEXITED(stat_loc)) {
// Ok, the return value goes into retval.
bool getTokenValue(string const & str, const char * token, string & ret)
{
- size_t token_length = strlen(token);
+ size_t token_length = std::strlen(token);
string::size_type pos = str.find(token);
- if (pos == string::npos || pos+token_length+1 >= str.length()
- || str[pos+token_length] != '=')
+ if (pos == string::npos || pos + token_length + 1 >= str.length()
+ || str[pos + token_length] != '=')
return false;
ret.erase();
pos += token_length + 1;
bool getTokenValue(string const & str, const char * token, int & num)
{
string::size_type pos = str.find(token);
- char ch = str[pos + strlen(token)];
+ char ch = str[pos + std::strlen(token)];
if ((pos == string::npos) || (ch != '='))
return false;
string ret;
- pos += strlen(token) + 1;
+ pos += std::strlen(token) + 1;
ch = str[pos];
if ((ch != '"') && (ch != '\'')) { // only read till next space
if (!isdigit(ch))
bool getTokenValue(string const & str, const char * token, bool & flag)
{
string::size_type pos = str.find(token);
- char ch = str[pos + strlen(token)];
+ char ch = str[pos + std::strlen(token)];
if ((pos == string::npos) || (ch != '='))
return false;
string ret;
- pos += strlen(token) + 1;
+ pos += std::strlen(token) + 1;
ch = str[pos];
if ((ch != '"') && (ch != '\'')) { // only read till next space
if (!isdigit(ch))
bool getTokenValue(string const & str, const char * token, string & ret)
{
- size_t token_length = strlen(token);
+ size_t token_length = std::strlen(token);
string::size_type pos = str.find(token);
- if (pos == string::npos || pos+token_length+1 >= str.length()
- || str[pos+token_length] != '=')
+ if (pos == string::npos || pos + token_length + 1 >= str.length()
+ || str[pos + token_length] != '=')
return false;
ret.erase();
pos += token_length + 1;
CursorLeftOneWord(bview);
// set the sel cursor
+#if 0
sel_cursor = cursor;
-
+#else
+ selection.cursor = cursor;
+#endif
+
while (cursor.pos() < cursor.par()->size()
&& !cursor.par()->IsSeparator(cursor.pos())
&& !cursor.par()->IsKomma(cursor.pos()) )
bool LyXText::SelectWordWhenUnderCursor(BufferView * bview)
{
+#if 0
if (!selection &&
+#else
+ if (!selection.set() &&
+#endif
cursor.pos() > 0 && cursor.pos() < cursor.par()->size()
&& !cursor.par()->IsSeparator(cursor.pos())
&& !cursor.par()->IsKomma(cursor.pos())
}
// Start the selection from here
+#if 0
sel_cursor = cursor;
-
+#else
+ selection.cursor = cursor;
+#endif
+
std::ostringstream latex;
// and find the end of the word
// Finally, we copy the word to a string and return it
string str;
+#if 0
if (sel_cursor.pos() < cursor.pos()) {
LyXParagraph::size_type i;
for (i = sel_cursor.pos(); i < cursor.pos(); ++i) {
str += cursor.par()->GetChar(i);
}
}
+#else
+ if (selection.cursor.pos() < cursor.pos()) {
+ LyXParagraph::size_type i;
+ for (i = selection.cursor.pos(); i < cursor.pos(); ++i) {
+ if (cursor.par()->GetChar(i) != LyXParagraph::META_INSET)
+ str += cursor.par()->GetChar(i);
+ }
+ }
+#endif
return str;
}
// This one is also only for the spellchecker
void LyXText::SelectSelectedWord(BufferView * bview)
{
+#if 0
// move cursor to the beginning
SetCursor(bview, sel_cursor.par(), sel_cursor.pos());
// set the sel cursor
sel_cursor = cursor;
-
+#else
+ // move cursor to the beginning
+ SetCursor(bview, selection.cursor.par(), selection.cursor.pos());
+
+ // set the sel cursor
+ selection.cursor = cursor;
+#endif
std::ostringstream latex;
// now find the end of the word
else {
LyXCursor tmpcursor = cursor;
tmpcursor.row(0); // ??
- selection = true; // to avoid deletion
+#if 0
+ selection = true; // to avoid deletion
+#else
+ selection.set(true); // to avoid deletion
+#endif
CursorRightOneWord(bview);
SetCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos());
+#if 0
sel_cursor = cursor;
+#else
+ selection.cursor = cursor;
+#endif
cursor = tmpcursor;
SetSelection(bview);
else {
LyXCursor tmpcursor = cursor;
tmpcursor.row(0); // ??
- selection = true; // to avoid deletion
+#if 0
+ selection = true; // to avoid deletion
+#else
+ selection.set(true); // to avoid deletion
+#endif
CursorLeftOneWord(bview);
SetCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos());
+#if 0
sel_cursor = cursor;
+#else
+ selection.cursor = cursor;
+#endif
cursor = tmpcursor;
SetSelection(bview);
CutSelection(bview);
// We can't store the row over a regular SetCursor
// so we set it to 0 and reset it afterwards.
tmpcursor.row(0); // ??
- selection = true; // to avoid deletion
+#if 0
+ selection = true; // to avoid deletion
+#else
+ selection.set(true); // to avoid deletion
+#endif
CursorEnd(bview);
SetCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos());
+#if 0
sel_cursor = cursor;
+#else
+ selection.cursor = cursor;
+#endif
cursor = tmpcursor;
SetSelection(bview);
// What is this test for ??? (JMarc)
+#if 0
if (!selection) {
+#else
+ if (!selection.set()) {
+#endif
DeleteWordForward(bview);
} else {
CutSelection(bview);
pain.fillRectangle(w, y_offset, ww - w, row_ptr->height());
}
}
-
- if (selection) {
+
+ if (selection.set()) {
int const w = (inset_owner ?
inset_owner->width(bview, font) : ww);
// selection code
if (bidi_same_direction) {
- if (sel_start_cursor.row() == row_ptr &&
- sel_end_cursor.row() == row_ptr) {
- if (sel_start_cursor.x() < sel_end_cursor.x())
- pain.fillRectangle(x_offset + sel_start_cursor.x(),
+ if (selection.start.row() == row_ptr &&
+ selection.end.row() == row_ptr) {
+ if (selection.start.x() < selection.end.x())
+ pain.fillRectangle(x_offset + selection.start.x(),
y_offset,
- sel_end_cursor.x() - sel_start_cursor.x(),
+ selection.end.x() - selection.start.x(),
row_ptr->height(),
LColor::selection);
else
- pain.fillRectangle(x_offset + sel_end_cursor.x(),
+ pain.fillRectangle(x_offset + selection.end.x(),
y_offset,
- sel_start_cursor.x() - sel_end_cursor.x(),
+ selection.start.x() - selection.end.x(),
row_ptr->height(),
LColor::selection);
- } else if (sel_start_cursor.row() == row_ptr) {
+ } else if (selection.start.row() == row_ptr) {
if (is_rtl)
pain.fillRectangle(x_offset, y_offset,
- sel_start_cursor.x(),
+ selection.start.x(),
row_ptr->height(),
LColor::selection);
else
- pain.fillRectangle(x_offset + sel_start_cursor.x(),
+ pain.fillRectangle(x_offset + selection.start.x(),
y_offset,
- w - sel_start_cursor.x(),
+ w - selection.start.x(),
row_ptr->height(),
LColor::selection);
- } else if (sel_end_cursor.row() == row_ptr) {
+ } else if (selection.end.row() == row_ptr) {
if (is_rtl)
- pain.fillRectangle(x_offset + sel_end_cursor.x(),
+ pain.fillRectangle(x_offset + selection.end.x(),
y_offset,
- w - sel_end_cursor.x(),
+ w - selection.end.x(),
row_ptr->height(),
LColor::selection);
else
pain.fillRectangle(x_offset, y_offset,
- sel_end_cursor.x(),
+ selection.end.x(),
row_ptr->height(),
LColor::selection);
- } else if (y > sel_start_cursor.y()
- && y < sel_end_cursor.y()) {
+ } else if (y > selection.start.y()
+ && y < selection.end.y()) {
pain.fillRectangle(x_offset, y_offset, w,
row_ptr->height(),
LColor::selection);
}
- } else if (sel_start_cursor.row() != row_ptr &&
- sel_end_cursor.row() != row_ptr &&
- y > sel_start_cursor.y()
- && y < sel_end_cursor.y()) {
+ } else if (selection.start.row() != row_ptr &&
+ selection.end.row() != row_ptr &&
+ y > selection.start.y()
+ && y < selection.end.y()) {
pain.fillRectangle(x_offset, y_offset, w,
row_ptr->height(),
LColor::selection);
- } else if (sel_start_cursor.row() == row_ptr ||
- sel_end_cursor.row() == row_ptr) {
+ } else if (selection.start.row() == row_ptr ||
+ selection.end.row() == row_ptr) {
float tmpx = x;
- if ((sel_start_cursor.row() != row_ptr && !is_rtl) ||
- (sel_end_cursor.row() != row_ptr && is_rtl))
+ if ((selection.start.row() != row_ptr && !is_rtl) ||
+ (selection.end.row() != row_ptr && is_rtl))
pain.fillRectangle(x_offset, y_offset,
int(tmpx),
row_ptr->height(),
} else
tmpx += SingleWidth(bview, row_ptr->par(), pos);
- if ((sel_start_cursor.row() != row_ptr ||
- sel_start_cursor.pos() <= pos) &&
- (sel_end_cursor.row() != row_ptr ||
- pos < sel_end_cursor.pos()) )
+ if ((selection.start.row() != row_ptr ||
+ selection.start.pos() <= pos) &&
+ (selection.end.row() != row_ptr ||
+ pos < selection.end.pos()) )
// Here we do not use x_offset as x_offset was
// added to x.
pain.fillRectangle(int(old_tmpx),
LColor::selection);
}
- if ((sel_start_cursor.row() != row_ptr && is_rtl) ||
- (sel_end_cursor.row() != row_ptr && !is_rtl) )
+ if ((selection.start.row() != row_ptr && is_rtl) ||
+ (selection.end.row() != row_ptr && !is_rtl) )
pain.fillRectangle(x_offset + int(tmpx),
y_offset,
int(ww - tmpx),
width = 0;
first = 0;
status = LyXText::UNCHANGED;
+
// set cursor at the very top position
+#if 0
selection = true; /* these setting is necessary
because of the delete-empty-
paragraph mechanism in
SetCursor */
+#else
+ selection.set(true); /* these setting is necessary
+ because of the delete-empty-
+ paragraph mechanism in
+ SetCursor */
+#endif
if (bv_owner) {
LyXParagraph * par = OwnerParagraph();
current_font = GetFont(bv_owner->buffer(), par, 0);
} else
current_font = LyXFont(LyXFont::ALL_SANE);
+#if 0
sel_cursor = cursor;
selection = false;
mark_set = false;
-
+#else
+ selection.cursor = cursor;
+ selection.set(false);
+ selection.mark(false);
+#endif
+
// no rebreak necessary
need_break_row = 0;
par = par->next();
}
SetCursorIntern(bview, firstrow->par(), 0);
+#if 0
sel_cursor = cursor;
+#else
+ selection.cursor = cursor;
+#endif
#if 0
printf("TP = %x\n",inset_owner->owner());
// Dump all rowinformation:
// set layout over selection and make a total rebreak of those paragraphs
void LyXText::SetLayout(BufferView * bview, LyXTextClass::size_type layout)
{
+#if 0
LyXCursor tmpcursor = cursor; /* store the current cursor */
// if there is no selection just set the layout
ClearSelection(bview);
SetSelection(bview);
SetCursor(bview, tmpcursor.par(), tmpcursor.pos(), true);
+#else
+ LyXCursor tmpcursor = cursor; /* store the current cursor */
+
+ // if there is no selection just set the layout
+ // of the current paragraph */
+ if (!selection.set()) {
+ selection.start = cursor; // dummy selection
+ selection.end = cursor;
+ }
+ LyXParagraph * endpar = SetLayout(bview, cursor, selection.start,
+ selection.end, layout);
+ RedoParagraphs(bview, selection.start, endpar);
+
+ // we have to reset the selection, because the
+ // geometry could have changed
+ SetCursor(bview, selection.start.par(),
+ selection.start.pos(), false);
+ selection.cursor = cursor;
+ SetCursor(bview, selection.end.par(), selection.end.pos(),
+ false);
+ UpdateCounters(bview, cursor.row());
+ ClearSelection(bview);
+ SetSelection(bview);
+ SetCursor(bview, tmpcursor.par(), tmpcursor.pos(), true);
+#endif
}
+#if 0
// increment depth over selection and
// make a total rebreak of those paragraphs
void LyXText::IncDepth(BufferView * bview)
SetSelection(bview);
SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
}
+#else
+// increment depth over selection and
+// make a total rebreak of those paragraphs
+void LyXText::IncDepth(BufferView * bview)
+{
+ // If there is no selection, just use the current paragraph
+ if (!selection.set()) {
+ selection.start = cursor; // dummy selection
+ selection.end = cursor;
+ }
+
+ // We end at the next paragraph with depth 0
+ LyXParagraph * endpar = selection.end.par()->next();
+
+ LyXParagraph * undoendpar = endpar;
+
+ if (endpar && endpar->GetDepth()) {
+ while (endpar && endpar->GetDepth()) {
+ endpar = endpar->next();
+ undoendpar = endpar;
+ }
+ }
+ else if (endpar) {
+ endpar = endpar->next(); // because of parindents etc.
+ }
+
+ SetUndo(bview->buffer(), Undo::EDIT,
+ selection.start.par()->previous(),
+ undoendpar);
+
+ LyXCursor tmpcursor = cursor; // store the current cursor
+
+ // ok we have a selection. This is always between sel_start_cursor
+ // and sel_end cursor
+ cursor = selection.start;
+
+ bool anything_changed = false;
+
+ while (true) {
+ // NOTE: you can't change the depth of a bibliography entry
+ if (
+ textclasslist.Style(bview->buffer()->params.textclass,
+ cursor.par()->GetLayout()
+ ).labeltype != LABEL_BIBLIO) {
+ LyXParagraph * prev = cursor.par()->previous();
+
+ if (prev
+ && (prev->GetDepth() - cursor.par()->GetDepth() > 0
+ || (prev->GetDepth() == cursor.par()->GetDepth()
+ && textclasslist.Style(bview->buffer()->params.textclass,
+ prev->GetLayout()).isEnvironment()))) {
+ cursor.par()->params.depth(cursor.par()->params.depth() + 1);
+ anything_changed = true;
+ }
+ }
+ if (cursor.par() == selection.end.par())
+ break;
+ cursor.par(cursor.par()->next());
+ }
+
+ // if nothing changed set all depth to 0
+ if (!anything_changed) {
+ cursor = selection.start;
+ while (cursor.par() != selection.end.par()) {
+ cursor.par()->params.depth(0);
+ cursor.par(cursor.par()->next());
+ }
+ cursor.par()->params.depth(0);
+ }
+
+ RedoParagraphs(bview, selection.start, endpar);
+
+ // we have to reset the selection, because the
+ // geometry could have changed
+ SetCursor(bview, selection.start.par(), selection.start.pos());
+ selection.cursor = cursor;
+ SetCursor(bview, selection.end.par(), selection.end.pos());
+ UpdateCounters(bview, cursor.row());
+ ClearSelection(bview);
+ SetSelection(bview);
+ SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
+}
+#endif
// decrement depth over selection and
{
// if there is no selection just set the layout
// of the current paragraph
- if (!selection) {
- sel_start_cursor = cursor; // dummy selection
- sel_end_cursor = cursor;
+ if (!selection.set()) {
+ selection.start = cursor; // dummy selection
+ selection.end = cursor;
}
- LyXParagraph * endpar = sel_end_cursor.par()->next();
+ LyXParagraph * endpar = selection.end.par()->next();
LyXParagraph * undoendpar = endpar;
if (endpar && endpar->GetDepth()) {
endpar = endpar->next();
undoendpar = endpar;
}
- }
- else if (endpar) {
+ } else if (endpar) {
endpar = endpar->next(); // because of parindents etc.
}
SetUndo(bview->buffer(), Undo::EDIT,
- sel_start_cursor.par()->previous(),
+ selection.start.par()->previous(),
undoendpar);
LyXCursor tmpcursor = cursor; // store the current cursor
// ok we have a selection. This is always between sel_start_cursor
// and sel_end cursor
- cursor = sel_start_cursor;
+ cursor = selection.start;
while (true) {
if (cursor.par()->params.depth())
cursor.par()->params.depth(cursor.par()->params.depth() - 1);
- if (cursor.par() == sel_end_cursor.par())
+ if (cursor.par() == selection.end.par())
break;
cursor.par(cursor.par()->next());
}
- RedoParagraphs(bview, sel_start_cursor, endpar);
+ RedoParagraphs(bview, selection.start, endpar);
// we have to reset the selection, because the
// geometry could have changed
- SetCursor(bview, sel_start_cursor.par(),
- sel_start_cursor.pos());
- sel_cursor = cursor;
- SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
+ SetCursor(bview, selection.start.par(),
+ selection.start.pos());
+ selection.cursor = cursor;
+ SetCursor(bview, selection.end.par(), selection.end.pos());
UpdateCounters(bview, cursor.row());
ClearSelection(bview);
SetSelection(bview);
void LyXText::SetFont(BufferView * bview, LyXFont const & font, bool toggleall)
{
// if there is no selection just set the current_font
- if (!selection) {
+ if (!selection.set()) {
// Determine basis font
LyXFont layoutfont;
if (cursor.pos() < BeginningOfMainBody(bview->buffer(),
// and sel_end cursor
SetUndo(bview->buffer(), Undo::EDIT,
- sel_start_cursor.par()->previous(),
- sel_end_cursor.par()->next());
+ selection.start.par()->previous(),
+ selection.end.par()->next());
FreezeUndo();
- cursor = sel_start_cursor;
- while (cursor.par() != sel_end_cursor.par() ||
- (cursor.pos() < sel_end_cursor.pos())) {
+ cursor = selection.start;
+ while (cursor.par() != selection.end.par() ||
+ (cursor.pos() < selection.end.pos())) {
if (cursor.pos() < cursor.par()->size()) {
// an open footnote should behave
// like a closed one
}
UnFreezeUndo();
- RedoParagraphs(bview, sel_start_cursor, sel_end_cursor.par()->next());
+ RedoParagraphs(bview, selection.start, selection.end.par()->next());
// we have to reset the selection, because the
// geometry could have changed
- SetCursor(bview, sel_start_cursor.par(), sel_start_cursor.pos());
- sel_cursor = cursor;
- SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
+ SetCursor(bview, selection.start.par(), selection.start.pos());
+ selection.cursor = cursor;
+ SetCursor(bview, selection.end.par(), selection.end.pos());
ClearSelection(bview);
SetSelection(bview);
SetCursor(bview, tmpcursor.par(), tmpcursor.pos(), true,
// need the selection cursor:
void LyXText::SetSelection(BufferView * bview)
{
- const bool lsel = selection;
+ bool const lsel = selection.set();
- if (!selection) {
- last_sel_cursor = sel_cursor;
- sel_start_cursor = sel_cursor;
- sel_end_cursor = sel_cursor;
+ if (!selection.set()) {
+ last_sel_cursor = selection.cursor;
+ selection.start = selection.cursor;
+ selection.end = selection.cursor;
}
- selection = true;
+ selection.set(true);
// first the toggling area
if (cursor.y() < last_sel_cursor.y()
// and now the whole selection
- if (sel_cursor.par() == cursor.par())
- if (sel_cursor.pos() < cursor.pos()) {
- sel_end_cursor = cursor;
- sel_start_cursor = sel_cursor;
+ if (selection.cursor.par() == cursor.par())
+ if (selection.cursor.pos() < cursor.pos()) {
+ selection.end = cursor;
+ selection.start = selection.cursor;
} else {
- sel_end_cursor = sel_cursor;
- sel_start_cursor = cursor;
+ selection.end = selection.cursor;
+ selection.start = cursor;
}
- else if (sel_cursor.y() < cursor.y() ||
- (sel_cursor.y() == cursor.y() && sel_cursor.x() < cursor.x())) {
- sel_end_cursor = cursor;
- sel_start_cursor = sel_cursor;
+ else if (selection.cursor.y() < cursor.y() ||
+ (selection.cursor.y() == cursor.y() && selection.cursor.x() < cursor.x())) {
+ selection.end = cursor;
+ selection.start = selection.cursor;
}
else {
- sel_end_cursor = sel_cursor;
- sel_start_cursor = cursor;
+ selection.end = selection.cursor;
+ selection.start = cursor;
}
// a selection with no contents is not a selection
- if (sel_start_cursor.par() == sel_end_cursor.par() &&
- sel_start_cursor.pos() == sel_end_cursor.pos())
- selection = false;
+ if (selection.start.par() == selection.end.par() &&
+ selection.start.pos() == selection.end.pos())
+ selection.set(false);
- if (inset_owner && (selection || lsel))
+ if (inset_owner && (selection.set() || lsel))
inset_owner->SetUpdateStatus(bview, InsetText::SELECTION);
}
string const LyXText::selectionAsString(Buffer const * buffer) const
{
- if (!selection) return string();
+ if (!selection.set()) return string();
string result;
// Special handling if the whole selection is within one paragraph
- if (sel_start_cursor.par() == sel_end_cursor.par()) {
- result += sel_start_cursor.par()->String(buffer,
- sel_start_cursor.pos(),
- sel_end_cursor.pos());
+ if (selection.start.par() == selection.end.par()) {
+ result += selection.start.par()->String(buffer,
+ selection.start.pos(),
+ selection.end.pos());
return result;
}
// The selection spans more than one paragraph
// First paragraph in selection
- result += sel_start_cursor.par()->String(buffer,
- sel_start_cursor.pos(),
- sel_start_cursor.par()->size())
+ result += selection.start.par()->String(buffer,
+ selection.start.pos(),
+ selection.start.par()->size())
+ "\n\n";
// The paragraphs in between (if any)
- LyXCursor tmpcur(sel_start_cursor);
+ LyXCursor tmpcur(selection.start);
tmpcur.par(tmpcur.par()->next());
- while (tmpcur.par() != sel_end_cursor.par()) {
+ while (tmpcur.par() != selection.end.par()) {
result += tmpcur.par()->String(buffer, 0, tmpcur.par()->size()) + "\n\n";
tmpcur.par(tmpcur.par()->next()); // Or NextAfterFootnote??
}
// Last paragraph in selection
- result += sel_end_cursor.par()->String(buffer, 0, sel_end_cursor.pos());
+ result += selection.end.par()->String(buffer, 0, selection.end.pos());
return result;
}
void LyXText::ClearSelection(BufferView * /*bview*/) const
{
- selection = false;
- mark_set = false;
- sel_end_cursor = sel_start_cursor = cursor;
+ selection.set(false);
+ selection.mark(false);
+ selection.end = selection.start = cursor;
}
ClearSelection(bview);
cursor = resetCursor;
SetCursor(bview, cursor.par(), cursor.pos());
- sel_cursor = cursor;
+ selection.cursor = cursor;
}
if (inset_owner)
inset_owner->SetUpdateStatus(bview, InsetText::CURSOR_PAR);
bool noindent)
{
LyXCursor tmpcursor = cursor;
- if (!selection) {
- sel_start_cursor = cursor;
- sel_end_cursor = cursor;
+ if (!selection.set()) {
+ selection.start = cursor;
+ selection.end = cursor;
}
// make sure that the depth behind the selection are restored, too
- LyXParagraph * endpar = sel_end_cursor.par()->next();
+ LyXParagraph * endpar = selection.end.par()->next();
LyXParagraph * undoendpar = endpar;
if (endpar && endpar->GetDepth()) {
}
SetUndo(bview->buffer(), Undo::EDIT,
- sel_start_cursor.par()->previous(),
+ selection.start.par()->previous(),
undoendpar);
- LyXParagraph * tmppar = sel_end_cursor.par();
- while (tmppar != sel_start_cursor.par()->previous()) {
+ LyXParagraph * tmppar = selection.end.par();
+ while (tmppar != selection.start.par()->previous()) {
SetCursor(bview, tmppar, 0);
status = LyXText::NEED_MORE_REFRESH;
refresh_row = cursor.row();
tmppar = cursor.par()->previous();
}
- RedoParagraphs(bview, sel_start_cursor, endpar);
+ RedoParagraphs(bview, selection.start, endpar);
ClearSelection(bview);
- SetCursor(bview, sel_start_cursor.par(), sel_start_cursor.pos());
- sel_cursor = cursor;
- SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
+ SetCursor(bview, selection.start.par(), selection.start.pos());
+ selection.cursor = cursor;
+ SetCursor(bview, selection.end.par(), selection.end.pos());
SetSelection(bview);
SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
if (inset_owner)
bview->stuffClipboard(selectionAsString(bview->buffer()));
// This doesn't make sense, if there is no selection
- if (!selection)
+ if (!selection.set())
return;
- // OK, we have a selection. This is always between sel_start_cursor
- // and sel_end_cursor
+ // OK, we have a selection. This is always between selection.start
+ // and selection.end
// make sure that the depth behind the selection are restored, too
- LyXParagraph * endpar = sel_end_cursor.par()->next();
+ LyXParagraph * endpar = selection.end.par()->next();
LyXParagraph * undoendpar = endpar;
if (endpar && endpar->GetDepth()) {
}
SetUndo(bview->buffer(), Undo::DELETE,
- sel_start_cursor.par()->previous(),
+ selection.start.par()->previous(),
undoendpar);
CutAndPaste cap;
// there are two cases: cut only within one paragraph or
// more than one paragraph
- if (sel_start_cursor.par() == sel_end_cursor.par()) {
+ if (selection.start.par() == selection.end.par()) {
// only within one paragraph
- endpar = sel_end_cursor.par();
- int pos = sel_end_cursor.pos();
- cap.cutSelection(sel_start_cursor.par(), &endpar,
- sel_start_cursor.pos(), pos,
+ endpar = selection.end.par();
+ int pos = selection.end.pos();
+ cap.cutSelection(selection.start.par(), &endpar,
+ selection.start.pos(), pos,
bview->buffer()->params.textclass, doclear);
- sel_end_cursor.pos(pos);
+ selection.end.pos(pos);
} else {
- endpar = sel_end_cursor.par();
- int pos = sel_end_cursor.pos();
- cap.cutSelection(sel_start_cursor.par(), &endpar,
- sel_start_cursor.pos(), pos,
+ endpar = selection.end.par();
+ int pos = selection.end.pos();
+ cap.cutSelection(selection.start.par(), &endpar,
+ selection.start.pos(), pos,
bview->buffer()->params.textclass, doclear);
cursor.par(endpar);
- sel_end_cursor.par(endpar);
- sel_end_cursor.pos(pos);
- cursor.pos(sel_end_cursor.pos());
+ selection.end.par(endpar);
+ selection.end.pos(pos);
+ cursor.pos(selection.end.pos());
}
endpar = endpar->next();
// sometimes necessary
if (doclear)
- sel_start_cursor.par()->StripLeadingSpaces(bview->buffer()->params.textclass);
+ selection.start.par()->StripLeadingSpaces(bview->buffer()->params.textclass);
- RedoParagraphs(bview, sel_start_cursor, endpar);
+ RedoParagraphs(bview, selection.start, endpar);
// cutSelection can invalidate the cursor so we need to set
// it anew. (Lgb)
- cursor = sel_start_cursor;
+ cursor = selection.start;
// need a valid cursor. (Lgb)
ClearSelection(bview);
SetCursor(bview, cursor.par(), cursor.pos());
- sel_cursor = cursor;
+ selection.cursor = cursor;
UpdateCounters(bview, cursor.row());
}
bview->stuffClipboard(selectionAsString(bview->buffer()));
// this doesnt make sense, if there is no selection
- if (!selection)
+ if (!selection.set())
return;
- // ok we have a selection. This is always between sel_start_cursor
+ // ok we have a selection. This is always between selection.start
// and sel_end cursor
// copy behind a space if there is one
- while (sel_start_cursor.par()->size() > sel_start_cursor.pos()
- && sel_start_cursor.par()->IsLineSeparator(sel_start_cursor.pos())
- && (sel_start_cursor.par() != sel_end_cursor.par()
- || sel_start_cursor.pos() < sel_end_cursor.pos()))
- sel_start_cursor.pos(sel_start_cursor.pos() + 1);
+ while (selection.start.par()->size() > selection.start.pos()
+ && selection.start.par()->IsLineSeparator(selection.start.pos())
+ && (selection.start.par() != selection.end.par()
+ || selection.start.pos() < selection.end.pos()))
+ selection.start.pos(selection.start.pos() + 1);
CutAndPaste cap;
- cap.copySelection(sel_start_cursor.par(), sel_end_cursor.par(),
- sel_start_cursor.pos(), sel_end_cursor.pos(),
+ cap.copySelection(selection.start.par(), selection.end.par(),
+ selection.start.pos(), selection.end.pos(),
bview->buffer()->params.textclass);
}
SetCursor(bview, cursor.par(), cursor.pos());
ClearSelection(bview);
- sel_cursor = cursor;
+ selection.cursor = cursor;
SetCursor(bview, actpar, pos);
SetSelection(bview);
UpdateCounters(bview, cursor.row());
// sets the selection over the number of characters of string, no check!!
void LyXText::SetSelectionOverString(BufferView * bview, string const & str)
{
- sel_cursor = cursor;
+ selection.cursor = cursor;
for (int i = 0; str[i]; ++i)
CursorRight(bview);
SetSelection(bview);
SetCursorParUndo(bview->buffer());
FreezeUndo();
- if (!selection) { // create a dummy selection
- sel_end_cursor = cursor;
- sel_start_cursor = cursor;
+ if (!selection.set()) { // create a dummy selection
+ selection.end = cursor;
+ selection.start = cursor;
}
// Get font setting before we cut
- LyXParagraph::size_type pos = sel_end_cursor.pos();
- LyXFont const font = sel_start_cursor.par()
+ LyXParagraph::size_type pos = selection.end.pos();
+ LyXFont const font = selection.start.par()
->GetFontSettings(bview->buffer()->params,
- sel_start_cursor.pos());
+ selection.start.pos());
// Insert the new string
for (string::const_iterator cit = str.begin(); cit != str.end(); ++cit) {
- sel_end_cursor.par()->InsertChar(pos, (*cit), font);
+ selection.end.par()->InsertChar(pos, (*cit), font);
++pos;
}
RedoParagraphs(bview, cursor, endpar);
SetCursor(bview, cursor.par(), cursor.pos());
- sel_cursor = cursor;
+ selection.cursor = cursor;
SetCursor(bview, par, pos);
SetSelection(bview);
}
// dangling pointers are possible
SetCursor(bview, cursor.par(), cursor.pos(),
false, cursor.boundary());
- sel_cursor = cursor;
+ selection.cursor = cursor;
return;
}
}
// set the cursor again. Otherwise dangling pointers are possible
// also set the selection
- if (selection) {
+ if (selection.set()) {
tmpcursor = cursor;
- SetCursorIntern(bview, sel_cursor.par(), sel_cursor.pos(),
- false, sel_cursor.boundary());
- sel_cursor = cursor;
- SetCursorIntern(bview, sel_start_cursor.par(),
- sel_start_cursor.pos(),
- false, sel_start_cursor.boundary());
- sel_start_cursor = cursor;
- SetCursorIntern(bview, sel_end_cursor.par(),
- sel_end_cursor.pos(),
- false, sel_end_cursor.boundary());
- sel_end_cursor = cursor;
+ SetCursorIntern(bview, selection.cursor.par(), selection.cursor.pos(),
+ false, selection.cursor.boundary());
+ selection.cursor = cursor;
+ SetCursorIntern(bview, selection.start.par(),
+ selection.start.pos(),
+ false, selection.start.boundary());
+ selection.start = cursor;
+ SetCursorIntern(bview, selection.end.par(),
+ selection.end.pos(),
+ false, selection.end.boundary());
+ selection.end = cursor;
SetCursorIntern(bview, last_sel_cursor.par(),
last_sel_cursor.pos(),
false, last_sel_cursor.boundary());
LyXCursor const & old_cursor) const
{
// Would be wrong to delete anything if we have a selection.
- if (selection) return;
+ if (selection.set()) return;
// We allow all kinds of "mumbo-jumbo" when freespacing.
if (textclasslist.Style(bview->buffer()->params.textclass,
SetCursorIntern(bview, cursor.par(), cursor.pos());
- if (sel_cursor.par() == old_cursor.par()
- && sel_cursor.pos() == sel_cursor.pos()) {
+ if (selection.cursor.par() == old_cursor.par()
+ && selection.cursor.pos() == selection.cursor.pos()) {
// correct selection
- sel_cursor = cursor;
+ selection.cursor = cursor;
}
}
if (!deleted) {
RedoParagraphs(bview, old_cursor, old_cursor.par()->next());
// correct cursor y
SetCursorIntern(bview, cursor.par(), cursor.pos());
- sel_cursor = cursor;
+ selection.cursor = cursor;
}
}
}