+1999-12-10 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * src/buffer.h: removed the two friends from Buffer. Some changes
+ because of this. Buffer::getFileName and Buffer::setFileName
+ renamed to Buffer::fileName() and Buffer::fileName(...).
+
+1999-12-09 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * buffer.[Ch], BufferView.[Ch] + other files: Moved Buffer::text
+ and Buffer::update(short) to BufferView. This move is currently
+ controlled by a define MOVE_TEXT, this will be removed when all
+ shows to be ok. This move paves the way for better separation
+ between buffer contents and buffer view. One side effect is that
+ the BufferView needs a rebreak when swiching buffers, if we want
+ to avoid this we can add a cache that holds pointers to LyXText's
+ that is not currently in use.
+
+ * buffer.[Ch], lyx_main.C: small changes to the "-export" patch by
+ André Pönitz.
+
+1999-11-18 André Pönitz <poenitz@mathematik.tu-chemnitz.de>
+
+ * buffer.[Ch]: Dispatch() - new dispatcher on the buffer level
+
+ * lyx_main.C: new command line option -x (or --execute) and
+ -e (or --export). Now direct conversion from .lyx to .tex
+ (.dvi, .ps, ...) is possible ('lyx file.lyx --export latex')
+ Unfortunately, X is still needed and the GUI pops up during the
+ process...
+
1999-12-07 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/Spacing.C: add a using directive to bring stream stuff into
* lib/reLyX/configure.in: make sure that the prefix is set
correctly in LYX_DIR.
-1999-11-18 Andre' Poenitz <poenitz@mathematik.tu-chemnitz.de>
+1999-11-18 André Pönitz <poenitz@mathematik.tu-chemnitz.de>
* src/commandtags.h: introduction of a new tag 'LFUN_SEQUENCE' to
be used by 'command-sequence' this allows to bind a key to a
elif test $ac_cv_prog_cxx_g = yes; then
case $gxx_version in
2.7*) CXXFLAGS="$lyx_opt";;
+ 2.95.1) CXXFLAGS="-g $lyx_opt -fpermissive";;
2.95.*) CXXFLAGS="-g $lyx_opt";;
*) CXXFLAGS="-g $lyx_opt -fno-exceptions -fno-rtti";;
esac
extern void MenuPasteSelection(char at);
extern InsetUpdateStruct *InsetUpdateList;
extern void UpdateInsetUpdateList();
+extern void FreeUpdateTimer();
// This is _very_ temporary
FL_OBJECT * figinset_canvas;
: owner_(o)
{
buffer_ = 0;
-
+#ifdef MOVE_TEXT
+ text = 0;
+#endif
screen = 0;
work_area = 0;
figinset_canvas = 0;
}
+BufferView::~BufferView()
+{
+#ifdef MOVE_TEXT
+ delete text;
+#endif
+}
+
+
void BufferView::buffer(Buffer *b)
{
lyxerr[Debug::INFO] << "Setting buffer in BufferView" << endl;
if (buffer_) {
buffer_->InsetSleep();
buffer_->delUser(this);
+ delete text;
+ text = 0;
}
// Set current buffer
buffer_->addUser(this);
owner_->getMenus()->showMenus();
// If we don't have a text object for this, we make one
+#ifdef MOVE_TEXT
+ if (text == 0)
+ resizeCurrentBuffer();
+ else {
+ updateScreen();
+ updateScrollbar();
+ }
+#else
if (buffer_->text == 0)
resizeCurrentBuffer();
else {
updateScreen();
updateScrollbar();
}
+#endif
screen->first = screen->TopCursorVisible();
redraw();
updateAllVisibleBufferRelatedPopups();
// Regenerate the screen.
if (screen)
delete screen;
+#ifdef MOVE_TEXT
+ screen = new LyXScreen(FL_ObjWin(work_area),
+ work_area->w,
+ work_area->h,
+ work_area->x,
+ work_area->y,
+ text);
+#else
screen = new LyXScreen(FL_ObjWin(work_area),
work_area->w,
work_area->h,
work_area->x,
work_area->y,
buffer_->text);
+#endif
}
long cbth = 0;
long cbsf = 0;
+#ifdef MOVE_TEXT
+ if (text)
+ cbth = text->height;
+#else
if (buffer_->text)
cbth = buffer_->text->height;
+#endif
if (screen)
cbsf = screen->first;
fl_set_slider_bounds(scrollbar, 0,
maximum_height - work_area->h);
#if FL_REVISION > 85
+#ifdef MOVE_TEXT
+ double lineh = text->DefaultHeight();
+#else
double lineh = buffer_->text->DefaultHeight();
+#endif
fl_set_slider_increment(scrollbar, work_area->h-lineh, lineh);
#endif
- if (maxfloat>0){
- if ((hfloat/maxfloat) * float(height2) < 3)
+ if (maxfloat > 0){
+ if ((hfloat / maxfloat) * float(height2) < 3)
fl_set_slider_size(scrollbar,
- 3/float(height2));
+ 3 / float(height2));
else
fl_set_slider_size(scrollbar,
- hfloat/maxfloat);
+ hfloat / maxfloat);
} else
fl_set_slider_size(scrollbar, hfloat);
fl_set_slider_precision(scrollbar, 0);
void BufferView::redoCurrentBuffer()
{
lyxerr[Debug::INFO] << "BufferView::redoCurrentBuffer" << endl;
+#ifdef MOVE_TEXT
+ if (text) {
+ resize();
+ owner_->updateLayoutChoice();
+ }
+#else
if (buffer_ && buffer_->text) {
resize();
owner_->updateLayoutChoice();
}
+#endif
}
owner_->getMiniBuffer()->Set(_("Formatting document..."));
+#ifdef MOVE_TEXT
+ if (text) {
+ par = text->cursor.par;
+ pos = text->cursor.pos;
+ selstartpar = text->sel_start_cursor.par;
+ selstartpos = text->sel_start_cursor.pos;
+ selendpar = text->sel_end_cursor.par;
+ selendpos = text->sel_end_cursor.pos;
+ selection = text->selection;
+ mark_set = text->mark_set;
+ delete text;
+ }
+ text = new LyXText(work_area->w, buffer_);
+#else
if (buffer_->text) {
par = buffer_->text->cursor.par;
pos = buffer_->text->cursor.pos;
delete buffer_->text;
}
buffer_->text = new LyXText(work_area->w, buffer_);
+#endif
updateScreen();
-
+
+#ifdef MOVE_TEXT
+ if (par) {
+ text->selection = true;
+ /* at this point just
+ * to avoid the Delete-
+ * Empty-Paragraph
+ * Mechanism when
+ * setting the cursor */
+ text->mark_set = mark_set;
+ if (selection) {
+ text->SetCursor(selstartpar, selstartpos);
+ text->sel_cursor = text->cursor;
+ text->SetCursor(selendpar, selendpos);
+ text->SetSelection();
+ text->SetCursor(par, pos);
+ } else {
+ text->SetCursor(par, pos);
+ text->sel_cursor = text->cursor;
+ text->selection = false;
+ }
+ }
+#else
if (par) {
buffer_->text->selection = true;
/* at this point just
buffer_->text->selection = false;
}
}
+#endif
screen->first = screen->TopCursorVisible(); /* this will scroll the
* screen such that the
* cursor becomes
screen->HideCursor();
BeforeChange();
+#ifdef MOVE_TEXT
+ update(-2);
+#else
buffer_->update(-2);
+#endif
LyXCursor tmp;
-
+
+#ifdef MOVE_TEXT
+ if (!text->GotoNextError()) {
+ if (text->cursor.pos
+ || text->cursor.par != text->FirstParagraph()) {
+ tmp = text->cursor;
+ text->cursor.par = text->FirstParagraph();
+ text->cursor.pos = 0;
+ if (!text->GotoNextError()) {
+ text->cursor = tmp;
+ owner_->getMiniBuffer()->Set(_("No more errors"));
+ LyXBell();
+ }
+ } else {
+ owner_->getMiniBuffer()->Set(_("No more errors"));
+ LyXBell();
+ }
+ }
+ update(0);
+ text->sel_cursor = text->cursor;
+#else
if (!buffer_->text->GotoNextError()) {
if (buffer_->text->cursor.pos
|| buffer_->text->cursor.par !=
buffer_->update(0);
buffer_->text->sel_cursor =
buffer_->text->cursor;
+#endif
}
view->screen->Draw(view->current_scrollbar_value);
if (cursor_follows_scrollbar) {
+#ifdef MOVE_TEXT
+ LyXText * vbt = view->text;
+#else
LyXText * vbt = view->buffer_->text;
+#endif
int height = vbt->DefaultHeight();
if (vbt->cursor.y < view->screen->first + height) {
if (value == 0)
return 0;
+
+#ifdef MOVE_TEXT
+ float add_value = (text->DefaultHeight()
+ + float(time) * float(time) * 0.125);
+ if (add_value > work_area->h)
+ add_value = float(work_area->h -
+ text->DefaultHeight());
+#else
float add_value = (buffer_->text->DefaultHeight()
+ float(time) * float(time) * 0.125);
if (add_value > work_area->h)
add_value = float(work_area->h -
buffer_->text->DefaultHeight());
+#endif
value -= add_value;
if (value == max)
return 0;
+
+#ifdef MOVE_TEXT
+ float add_value = (text->DefaultHeight()
+ + float(time) * float(time) * 0.125);
+ if (add_value > work_area->h)
+ add_value = float(work_area->h -
+ text->DefaultHeight());
+#else
float add_value = (buffer_->text->DefaultHeight()
+ float(time) * float(time) * 0.125);
if (add_value > work_area->h)
add_value = float(work_area->h -
buffer_->text->DefaultHeight());
+#endif
value += add_value;
long y = screen->first;
if (!y) return;
-
- Row* row = buffer_->text->GetRowNearY(y);
+#ifdef MOVE_TEXT
+ Row * row = text->GetRowNearY(y);
+#else
+ Row * row = buffer_->text->GetRowNearY(y);
+#endif
y = y - work_area->h + row->height;
fl_set_slider_value(scrollbar, y);
double min, max;
fl_get_slider_bounds(scrollbar, &min, &max);
long y = screen->first;
+
+#ifdef MOVE_TEXT
+ if (y > text->height - work_area->h)
+ return;
+ y += work_area->h;
+ text->GetRowNearY(y);
+#else
if (y > buffer_->text->height - work_area->h)
return;
y += work_area->h;
buffer_->text->GetRowNearY(y);
-
+#endif
fl_set_slider_value(scrollbar, y);
ScrollCB(scrollbar, 0);
if (view->buffer_ && !view->buffer_->the_locking_inset) {
if (view->screen && ev->xbutton.button == 1) {
view->screen->HideCursor();
- view->screen->ToggleSelection();
+ view->screen->ToggleSelection();
+#ifdef MOVE_TEXT
+ view->text->SelectWord();
+#else
view->buffer_->text->SelectWord();
+#endif
view->screen->ToggleSelection(false);
/* This will fit the cursor on the screen
- * if necessary */
- view->buffer_->update(0);
+ * if necessary */
+#ifdef MOVE_TEXT
+ view->update(0);
+#else
+ view->buffer_->update(0);
+#endif
}
}
break;
// select a line
if (view->buffer_ && view->screen && ev->xbutton.button == 1) {
view->screen->HideCursor();
- view->screen->ToggleSelection();
+ view->screen->ToggleSelection();
+#ifdef MOVE_TEXT
+ view->text->CursorHome();
+ view->text->sel_cursor = view->text->cursor;
+ view->text->CursorEnd();
+ view->text->SetSelection();
+#else
view->buffer_->text->CursorHome();
view->buffer_->text->sel_cursor =
view->buffer_->text->cursor;
view->buffer_->text->CursorEnd();
view->buffer_->text->SetSelection();
+#endif
view->screen->ToggleSelection(false);
/* This will fit the cursor on the screen
- * if necessary */
- view->buffer_->update(0);
+ * if necessary */
+#ifdef MOVE_TEXT
+ view->update(0);
+#else
+ view->buffer_->update(0);
+#endif
}
break;
case FL_OTHER:
// Check for inset locking
if (buffer_->the_locking_inset) {
+#ifdef MOVE_TEXT
+ LyXCursor cursor = text->cursor;
+#else
LyXCursor cursor = buffer_->text->cursor;
+#endif
buffer_->the_locking_inset->
InsetMotionNotify(ev->xbutton.x - ob->x - cursor.x,
ev->xbutton.y - ob->y -
if (selection_possible) {
screen->HideCursor();
+#ifdef MOVE_TEXT
+ text->SetCursorFromCoordinates(ev->xbutton.x - ob->x,
+ ev->xbutton.y - ob->y +
+ screen->first);
+
+ if (!text->selection)
+ update(-3); // Maybe an empty line was deleted
+
+ text->SetSelection();
+#else
buffer_->text->
SetCursorFromCoordinates(ev->xbutton.x - ob->x,
ev->xbutton.y - ob->y +
buffer_->update(-3); // Maybe an empty line was deleted
buffer_->text->SetSelection();
+#endif
screen->ToggleToggle();
if (screen->FitCursor())
updateScrollbar();
extern int bibitemMaxWidth(LyXFont const &);
+#ifdef MOVE_TEXT
+// Single-click on work area
+int BufferView::WorkAreaButtonPress(FL_OBJECT *ob, Window,
+ int /*w*/, int /*h*/, XEvent *ev, void */*d*/)
+{
+ last_click_x = -1;
+ last_click_y = -1;
+
+ if (buffer_ == 0) return 0;
+ if (!screen) return 0;
+
+ int const x = ev->xbutton.x - ob->x;
+ int const y = ev->xbutton.y - ob->y;
+ // If we hit an inset, we have the inset coordinates in these
+ // and inset_hit points to the inset. If we do not hit an
+ // inset, inset_hit is 0, and inset_x == x, inset_y == y.
+ int inset_x = x;
+ int inset_y = y;
+ Inset * inset_hit = checkInsetHit(inset_x, inset_y);
+
+ // ok ok, this is a hack.
+ int button = ev->xbutton.button;
+ if (button == 4 || button == 5) goto wheel;
+
+ {
+
+ if (buffer_->the_locking_inset) {
+ // We are in inset locking mode
+
+ /* Check whether the inset was hit. If not reset mode,
+ otherwise give the event to the inset */
+ if (inset_hit != 0) {
+ buffer_->the_locking_inset->
+ InsetButtonPress(inset_x, inset_y, button);
+ return 0;
+ } else {
+ UnlockInset(buffer_->the_locking_inset);
+ }
+ }
+
+ selection_possible = true;
+ screen->HideCursor();
+
+ // Right button mouse click on a table
+ if (button == 3 &&
+ (text->cursor.par->table ||
+ text->MouseHitInTable(x, y + screen->first))) {
+ // Set the cursor to the press-position
+ text->SetCursorFromCoordinates(x, y + screen->first);
+ bool doit = true;
+
+ // Only show the table popup if the hit is in the table, too
+ if (!text->HitInTable(text->cursor.row, x))
+ doit = false;
+
+ // Hit above or below the table?
+ if (doit) {
+ if (!text->selection) {
+ screen->ToggleSelection();
+ text->ClearSelection();
+ text->FullRebreak();
+ screen->Update();
+ updateScrollbar();
+ }
+ // Popup table popup when on a table.
+ // This is obviously temporary, since we should be
+ // able to
+ // popup various context-sensitive-menus with the
+ // the right mouse. So this should be done more
+ // general in the future. Matthias.
+ selection_possible = false;
+ owner_->getLyXFunc()->Dispatch(LFUN_LAYOUT_TABLE,
+ "true");
+ return 0;
+ }
+ }
+
+ int screen_first = screen->first;
+
+ // Middle button press pastes if we have a selection
+ bool paste_internally = false;
+ if (button == 2 // && !buffer_->the_locking_inset
+ && text->selection) {
+ owner_->getLyXFunc()->Dispatch(LFUN_COPY);
+ paste_internally = true;
+ }
+
+ // Clear the selection
+ screen->ToggleSelection();
+ text->ClearSelection();
+ text->FullRebreak();
+ screen->Update();
+ updateScrollbar();
+
+ // Single left click in math inset?
+ if (inset_hit != 0 && inset_hit->Editable() == 2) {
+ // Highly editable inset, like math
+ selection_possible = false;
+ owner_->updateLayoutChoice();
+ owner_->getMiniBuffer()->Set(inset_hit->EditMessage());
+ inset_hit->Edit(inset_x, inset_y);
+ return 0;
+ }
+
+ // Right click on a footnote flag opens float menu
+ if (button == 3) {
+ selection_possible = false;
+ return 0;
+ }
+
+ text->SetCursorFromCoordinates(x, y + screen_first);
+ text->FinishUndo();
+ text->sel_cursor = text->cursor;
+ text->cursor.x_fix = text->cursor.x;
+
+ owner_->updateLayoutChoice();
+ if (screen->FitCursor()){
+ updateScrollbar();
+ selection_possible = false;
+ }
+
+ // Insert primary selection with middle mouse
+ // if there is a local selection in the current buffer, insert this
+ if (button == 2) { // && !buffer_->the_locking_inset){
+ if (paste_internally)
+ owner_->getLyXFunc()->Dispatch(LFUN_PASTE);
+ else
+ owner_->getLyXFunc()->Dispatch(LFUN_PASTESELECTION,
+ "paragraph");
+ selection_possible = false;
+ return 0;
+ }
+ }
+ goto out;
+ wheel: {
+ // I am not quite sure if this is the correct place to put this,
+ // but it will not cause any harm.
+ // Patch from Mark Huang (markman@mit.edu) to make LyX recognise
+ // button 4 and 5. This enables LyX use use the scrollwhell on
+ // certain mice for something useful. (Lgb)
+ // Added wheel acceleration detection code. (Rvdk)
+ static Time lastTime = 0;
+ int diff = ev->xbutton.time - lastTime;
+ int scroll = int(1.0 + (4.0/(abs(diff)+1.0))*200.0);
+ switch (button) {
+ case 4:
+ ScrollUp(scroll);
+ break;
+ case 5:
+ ScrollDown(scroll);
+ break;
+ }
+ lastTime = ev->xbutton.time;
+ return 0;
+ }
+ out:
+ last_click_x = x;
+ last_click_y = y;
+
+ return 0;
+}
+#else
// Single-click on work area
int BufferView::WorkAreaButtonPress(FL_OBJECT *ob, Window,
int /*w*/, int /*h*/, XEvent *ev, void */*d*/)
return 0;
}
+#endif
+
+#ifdef MOVE_TEXT
+int BufferView::WorkAreaButtonRelease(FL_OBJECT * ob, Window ,
+ int /*w*/, int /*h*/, XEvent * ev, void * /*d*/)
+{
+ if (buffer_ == 0 || screen == 0) return 0;
+
+ int const x = ev->xbutton.x - ob->x;
+ int const y = ev->xbutton.y - ob->y;
+
+ // If we hit an inset, we have the inset coordinates in these
+ // and inset_hit points to the inset. If we do not hit an
+ // inset, inset_hit is 0, and inset_x == x, inset_y == y.
+ int inset_x = x;
+ int inset_y = y;
+ Inset * inset_hit = checkInsetHit(inset_x, inset_y);
+
+ if (buffer_->the_locking_inset) {
+ // We are in inset locking mode.
+
+ /* LyX does a kind of work-area grabbing for insets.
+ Only a ButtonPress Event outside the inset will
+ force a InsetUnlock. */
+ buffer_->the_locking_inset->
+ InsetButtonRelease(inset_x, inset_y,
+ ev->xbutton.button);
+ return 0;
+ }
+
+ selection_possible = false;
+ if (text->cursor.par->table) {
+ int cell = text->
+ NumberOfCell(text->cursor.par,
+ text->cursor.pos);
+ if (text->cursor.par->table->IsContRow(cell) &&
+ text->cursor.par->table->
+ CellHasContRow(text->cursor.par->table->
+ GetCellAbove(cell))<0) {
+ text->CursorUp();
+ }
+ }
+
+ if (ev->xbutton.button >= 2)
+ return 0;
+
+ // Make sure that the press was not far from the release
+ if ((abs(last_click_x - x) >= 5) ||
+ (abs(last_click_y - y) >= 5)) {
+ return 0;
+ }
+
+ // Did we hit an editable inset?
+ if (inset_hit != 0) {
+ // Inset like error, notes and figures
+ selection_possible = false;
+#ifdef WITH_WARNINGS
+#warning fix this proper in 0.13
+#endif
+ // Following a ref shouldn't issue
+ // a push on the undo-stack
+ // anylonger, now that we have
+ // keybindings for following
+ // references and returning from
+ // references. IMHO though, it
+ // should be the inset's own business
+ // to push or not push on the undo
+ // stack. They don't *have* to
+ // alter the document...
+ // (Joacim)
+ // ...or maybe the SetCursorParUndo()
+ // below isn't necessary at all anylonger?
+ if (inset_hit->LyxCode() == Inset::REF_CODE) {
+ text->SetCursorParUndo();
+ }
+
+ owner_->getMiniBuffer()->Set(inset_hit->EditMessage());
+ inset_hit->Edit(inset_x, inset_y);
+ return 0;
+ }
+
+ // check whether we want to open a float
+ if (text) {
+ bool hit = false;
+ char c = ' ';
+ if (text->cursor.pos <
+ text->cursor.par->Last()) {
+ c = text->cursor.par->
+ GetChar(text->cursor.pos);
+ }
+ if (c == LyXParagraph::META_FOOTNOTE
+ || c == LyXParagraph::META_MARGIN
+ || c == LyXParagraph::META_FIG
+ || c == LyXParagraph::META_TAB
+ || c == LyXParagraph::META_WIDE_FIG
+ || c == LyXParagraph::META_WIDE_TAB
+ || c == LyXParagraph::META_ALGORITHM){
+ hit = true;
+ } else if (text->cursor.pos - 1 >= 0) {
+ c = text->cursor.par->
+ GetChar(text->cursor.pos - 1);
+ if (c == LyXParagraph::META_FOOTNOTE
+ || c == LyXParagraph::META_MARGIN
+ || c == LyXParagraph::META_FIG
+ || c == LyXParagraph::META_TAB
+ || c == LyXParagraph::META_WIDE_FIG
+ || c == LyXParagraph::META_WIDE_TAB
+ || c == LyXParagraph::META_ALGORITHM){
+ // We are one step too far to the right
+ text->CursorLeft();
+ hit = true;
+ }
+ }
+ if (hit == true) {
+ ToggleFloat();
+ selection_possible = false;
+ return 0;
+ }
+ }
+ // Do we want to close a float? (click on the float-label)
+ if (text->cursor.row->par->footnoteflag ==
+ LyXParagraph::OPEN_FOOTNOTE
+ && text->cursor.pos == 0
+ && text->cursor.row->previous &&
+ text->cursor.row->previous->par->
+ footnoteflag != LyXParagraph::OPEN_FOOTNOTE){
+ LyXFont font (LyXFont::ALL_SANE);
+ font.setSize(LyXFont::SIZE_SMALL);
+
+ int box_x = 20; // LYX_PAPER_MARGIN;
+ box_x += font.textWidth("Mwide-figM", 10);
+ int screen_first = screen->first;
+
+ if (x < box_x
+ && y + screen_first > text->cursor.y -
+ text->cursor.row->baseline
+ && y + screen_first < text->cursor.y -
+ text->cursor.row->baseline
+ + font.maxAscent()*1.2 + font.maxDescent()*1.2) {
+ ToggleFloat();
+ selection_possible = false;
+ return 0;
+ }
+ }
+
+ // Maybe we want to edit a bibitem ale970302
+ if (text->cursor.par->bibkey && x < 20 +
+ bibitemMaxWidth(textclasslist.TextClass(buffer_->
+ params.textclass).defaultfont())) {
+ text->cursor.par->bibkey->Edit(0, 0);
+ }
+
+ return 0;
+}
+#else
int BufferView::WorkAreaButtonRelease(FL_OBJECT *ob, Window ,
int /*w*/, int /*h*/, XEvent *ev, void */*d*/)
{
return 0;
}
-
+#endif
/*
* Returns an inset if inset was hit. 0 otherwise.
* If hit, the coordinates are changed relative to the inset.
* Otherwise coordinates are not changed, and false is returned.
*/
+#ifdef MOVE_TEXT
+Inset * BufferView::checkInsetHit(int & x, int & y)
+{
+ if (!getScreen())
+ return 0;
+
+ int y_tmp = y + getScreen()->first;
+
+ LyXCursor cursor = text->cursor;
+ if (cursor.pos < cursor.par->Last()
+ && cursor.par->GetChar(cursor.pos) == LyXParagraph::META_INSET
+ && cursor.par->GetInset(cursor.pos)
+ && cursor.par->GetInset(cursor.pos)->Editable()) {
+
+ // Check whether the inset really was hit
+ Inset * tmpinset = cursor.par->GetInset(cursor.pos);
+ LyXFont font = text->GetFont(cursor.par, cursor.pos);
+ if (x > cursor.x
+ && x < cursor.x + tmpinset->Width(font)
+ && y_tmp > cursor.y - tmpinset->Ascent(font)
+ && y_tmp < cursor.y + tmpinset->Descent(font)) {
+ x = x - cursor.x;
+ // The origin of an inset is on the baseline
+ y = y_tmp - (cursor.y);
+ return tmpinset;
+ }
+ } else if (cursor.pos - 1 >= 0
+ && cursor.par->GetChar(cursor.pos - 1) == LyXParagraph::META_INSET
+ && cursor.par->GetInset(cursor.pos - 1)
+ && cursor.par->GetInset(cursor.pos - 1)->Editable()) {
+ text->CursorLeft();
+ Inset * result = checkInsetHit(x, y);
+ if (result == 0) {
+ text->CursorRight();
+ return 0;
+ } else {
+ return result;
+ }
+ }
+ return 0;
+}
+#else
Inset * BufferView::checkInsetHit(int & x, int & y)
{
if (!getScreen())
&& cursor.par->GetInset(cursor.pos)->Editable()) {
// Check whether the inset really was hit
- Inset* tmpinset = cursor.par->GetInset(cursor.pos);
+ Inset * tmpinset = cursor.par->GetInset(cursor.pos);
LyXFont font = buffer_->text->GetFont(cursor.par, cursor.pos);
if (x > cursor.x
&& x < cursor.x + tmpinset->Width(font)
}
return 0;
}
-
+#endif
int BufferView::workAreaExpose()
{
XFlush(fl_display);
if (uc){
+#ifdef MOVE_TEXT
+ if (!ascii_type) {
+ text->InsertStringA(reinterpret_cast<char*>(uc));
+ } else {
+ text->InsertStringB(reinterpret_cast<char*>(uc));
+ }
+#else
if (!ascii_type) {
buffer_->text->
InsertStringA(reinterpret_cast<char*>(uc));
buffer_->text->
InsertStringB(reinterpret_cast<char*>(uc));
}
+#endif
free(uc);
uc = 0;
}
-
+
+#ifdef MOVE_TEXT
+ update(1);
+#else
buffer_->update(1);
+#endif
}
return 0;
}
+#ifdef MOVE_TEXT
+void BufferView::cursorPrevious()
+{
+ if (!text->cursor.row->previous) return;
+
+ long y = getScreen()->first;
+ Row * cursorrow = text->cursor.row;
+ text->SetCursorFromCoordinates(text->cursor.x_fix, y);
+ text->FinishUndo();
+ // this is to allow jumping over large insets
+ if ((cursorrow == text->cursor.row))
+ text->CursorUp();
+
+ if (text->cursor.row->height < work_area->h)
+ getScreen()->Draw(text->cursor.y
+ - text->cursor.row->baseline
+ + text->cursor.row->height
+ - work_area->h +1 );
+}
+
+
+void BufferView::cursorNext()
+{
+ if (!text->cursor.row->next) return;
+
+ long y = getScreen()->first;
+ text->GetRowNearY(y);
+ Row * cursorrow = text->cursor.row;
+ text->SetCursorFromCoordinates(text->cursor.x_fix, y + work_area->h);
+ text->FinishUndo();
+ /* this is to allow jumping over large insets */
+ if ((cursorrow == text->cursor.row))
+ text->CursorDown();
+
+ if (text->cursor.row->height < work_area->h)
+ getScreen()->Draw(text->cursor.y
+ - text->cursor.row->baseline);
+}
+#else
void BufferView::cursorPrevious()
{
if (!buffer()->text->cursor.row->previous) return;
getScreen()->Draw(buffer()->text->cursor.y
- buffer()->text->cursor.row->baseline);
}
-
+#endif
bool BufferView::available() const
{
+#ifdef MOVE_TEXT
+ if (buffer_ && text) return true;
+#else
if (buffer_ && buffer_->text) return true;
+#endif
return false;
}
void BufferView::savePosition()
{
+#ifdef MOVE_TEXT
+ backstack.push(buffer()->fileName(),
+ text->cursor.x,
+ text->cursor.y);
+#else
backstack.push(buffer()->getFileName(),
buffer()->text->cursor.x,
buffer()->text->cursor.y);
+#endif
}
Buffer * b = (bufferlist.exists(fname)) ? bufferlist.getBuffer(fname):
bufferlist.loadLyXFile(fname); // don't ask, just load it
buffer(b);
+#ifdef MOVE_TEXT
+ text->SetCursorFromCoordinates(x, y);
+ update(0);
+#else
buffer()->text->SetCursorFromCoordinates(x, y);
buffer()->update(0);
+#endif
}
+
+
+#ifdef MOVE_TEXT
+// candidate for move to BufferView
+void BufferView::update(signed char f)
+{
+ owner()->updateLayoutChoice();
+
+ if (!text->selection && f > -3)
+ text->sel_cursor = text->cursor;
+
+ FreeUpdateTimer();
+ text->FullRebreak();
+
+ update();
+
+ if (f != 3 && f != -3) {
+ fitCursor();
+ updateScrollbar();
+ }
+
+ if (f == 1 || f == -1) {
+ if (buffer()->isLyxClean()) {
+ buffer()->markDirty();
+ owner()->getMiniBuffer()->setTimer(4);
+ } else {
+ buffer()->markDirty();
+ }
+ }
+}
+#endif
#include FORMS_H_LOCATION
#include "BackStack.h"
+#include "lyxtext.h"
+
+#define MOVE_TEXT 1
class LyXView;
class Buffer;
///
BufferView(LyXView *owner, int , int , int, int);
///
+ ~BufferView();
+ ///
Buffer * buffer() const { return buffer_; }
///
FL_OBJECT * getWorkArea() { return work_area; }
void fitCursor();
///
void update();
+#ifdef MOVE_TEXT
+ ///
+ void update(signed char f);
+#endif
///
void updateScrollbar();
///
void savePosition();
///
void restorePosition();
+#ifdef MOVE_TEXT
+ /** This holds the mapping between buffer paragraphs and screen rows.
+ This should be private...but not yet. (Lgb)
+ */
+ LyXText * text;
+#endif
private:
/// Update pixmap of screen
void updateScreen();
command = subst(command, "$$FName", fname);
command += " &"; // execute in background
// push directorypath, if necessary
- string path = OnlyPath(buffer->getFileName());
+ string path = OnlyPath(buffer->fileName());
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
path = buffer->tmppath;
}
return;
view->view()->getScreen()->HideCursor();
+#ifdef MOVE_TEXT
+ view->view()->update(-2);
+#else
view->buffer()->update(-2);
+#endif
/* This update can happen, even when the work area has lost
* the focus. So suppress the cursor in that case */
updatetimer = 0;
}
// we need to do this.
toolbar->combox->Redraw();
-
+
+#ifdef MOVE_TEXT
+ char layout = bufferview->text->cursor.par->GetLayout();
+#else
char layout = buffer()->text->cursor.par->GetLayout();
+#endif
if (layout != current_layout){
toolbar->combox->select(layout + 1);
string title = "LyX";
if (view()->available()) {
- string cur_title = buffer()->getFileName();
+ string cur_title = buffer()->fileName();
if (!cur_title.empty()){
title += ": " + OnlyFilename(cur_title);
if (!buffer()->isLyxClean())
bool update = false;
if (current_view->getScreen() && current_view->available()) {
update = true;
+#ifdef MOVE_TEXT
+ LyXParagraph * par = current_view->text->cursor.par;
+#else
LyXParagraph * par = current_view->buffer()->text->cursor.par;
+#endif
EnableParagraphExtra();
FD_form_paragraph_extra const * fd = fd_form_paragraph_extra;
char const * width = fl_get_input(fd->input_pextra_width);
char const * widthp = fl_get_input(fd->input_pextra_widthp);
+#ifdef MOVE_TEXT
+ LyXText * text = current_view->text;
+#else
LyXText * text = current_view->buffer()->text;
+#endif
int type = LyXParagraph::PEXTRA_NONE;
LyXParagraph::MINIPAGE_ALIGNMENT alignment =
LyXParagraph::MINIPAGE_ALIGN_TOP;
}
text->SetParagraphExtraOpt(type, width, widthp, alignment, hfill,
start_minipage);
+#ifdef MOVE_TEXT
+ current_view->update(1);
+#else
current_view->buffer()->update(1);
+#endif
minibuffer->Set(_("ParagraphExtra layout set"));
}
return;
static int extra_multicol_cursor_x;
// Joacim
+#ifdef MOVE_TEXT
+bool UpdateLayoutTable(int flag)
+{
+ bool update = true;
+ if (!current_view->getScreen() || !current_view->available())
+ update = false;
+
+ if (update && current_view->text->cursor.par->table) {
+ char buf[12];
+ string pwidth, special;
+
+ LyXTable * table = current_view->text->cursor.par->table;
+
+ int cell = current_view->text->
+ NumberOfCell(current_view->text->cursor.par,
+ current_view->text->cursor.pos);
+ ActCell = cell;
+ int column = table->column_of_cell(cell)+1;
+ fl_set_object_label(fd_form_table_options->text_warning, "");
+ Confirmed = false;
+ fl_activate_object(fd_form_table_extra->input_special_alignment);
+ fl_activate_object(fd_form_table_extra->input_special_multialign);
+ fl_activate_object(fd_form_table_options->input_column_width);
+ sprintf(buf, "%d", column);
+ fl_set_input(fd_form_table_options->input_table_column, buf);
+ fl_deactivate_object(fd_form_table_options->input_table_column);
+ int row = table->row_of_cell(cell)+1;
+ sprintf(buf, "%d", row);
+ fl_set_input(fd_form_table_options->input_table_row, buf);
+ fl_deactivate_object(fd_form_table_options->input_table_row);
+ if (table->IsMultiColumn(cell))
+ fl_set_button(fd_form_table_options->radio_multicolumn, 1);
+ else
+ fl_set_button(fd_form_table_options->radio_multicolumn, 0);
+ if (table->RotateCell(cell))
+ fl_set_button(fd_form_table_options->radio_rotate_cell, 1);
+ else
+ fl_set_button(fd_form_table_options->radio_rotate_cell, 0);
+ if (table->TopLine(cell))
+ fl_set_button(fd_form_table_options->radio_border_top, 1);
+ else
+ fl_set_button(fd_form_table_options->radio_border_top, 0);
+ if (table->BottomLine(cell))
+ fl_set_button(fd_form_table_options->radio_border_bottom, 1);
+ else
+ fl_set_button(fd_form_table_options->radio_border_bottom, 0);
+ if (table->LeftLine(cell))
+ fl_set_button(fd_form_table_options->radio_border_left, 1);
+ else
+ fl_set_button(fd_form_table_options->radio_border_left, 0);
+ if (table->RightLine(cell))
+ fl_set_button(fd_form_table_options->radio_border_right, 1);
+ else
+ fl_set_button(fd_form_table_options->radio_border_right, 0);
+ int align = table->GetAlignment(cell);
+ fl_set_button(fd_form_table_options->radio_align_left, 0);
+ fl_set_button(fd_form_table_options->radio_align_right, 0);
+ fl_set_button(fd_form_table_options->radio_align_center, 0);
+ special = table->GetAlignSpecial(cell, LyXTable::SET_SPECIAL_COLUMN);
+ if (flag)
+ {
+ fl_set_input(fd_form_table_extra->input_special_alignment,
+ special.c_str());
+ fl_set_input_cursorpos(fd_form_table_extra->input_special_alignment,
+ extra_col_cursor_x, 0); // restore the cursor
+ }
+ if (current_view->buffer()->isReadonly())
+ fl_deactivate_object(fd_form_table_extra->input_special_alignment);
+ special = table->GetAlignSpecial(cell, LyXTable::SET_SPECIAL_MULTI);
+ if (flag)
+ {
+ fl_set_input(fd_form_table_extra->input_special_multialign,
+ special.c_str());
+ fl_set_input_cursorpos(fd_form_table_extra->input_special_multialign,
+ extra_multicol_cursor_x, 0); // restore the cursor
+ }
+ if (current_view->buffer()->isReadonly())
+ fl_deactivate_object(fd_form_table_extra->input_special_multialign);
+ pwidth = table->GetPWidth(cell);
+ if (flag)
+ fl_set_input(fd_form_table_options->input_column_width, pwidth.c_str());
+ if (current_view->buffer()->isReadonly())
+ fl_deactivate_object(fd_form_table_options->input_column_width);
+ if (!pwidth.empty()) {
+ fl_activate_object(fd_form_table_options->radio_linebreak_cell);
+ fl_set_object_lcol(fd_form_table_options->radio_linebreak_cell,
+ FL_BLACK);
+ fl_set_button(fd_form_table_options->radio_linebreak_cell,
+ table->Linebreaks(table->FirstVirtualCell(cell)));
+ } else {
+ fl_deactivate_object(fd_form_table_options->radio_linebreak_cell);
+ fl_set_object_lcol(fd_form_table_options->radio_linebreak_cell,
+ FL_INACTIVE);
+ fl_set_button(fd_form_table_options->radio_linebreak_cell, 0);
+ }
+ if ((!pwidth.empty() && !table->IsMultiColumn(cell)) ||
+ (align == LYX_ALIGN_LEFT))
+ fl_set_button(fd_form_table_options->radio_align_left, 1);
+ else if (align == LYX_ALIGN_RIGHT)
+ fl_set_button(fd_form_table_options->radio_align_right, 1);
+ else
+ fl_set_button(fd_form_table_options->radio_align_center, 1);
+ if (!pwidth.empty() && !table->IsMultiColumn(cell)) {
+ fl_deactivate_object(fd_form_table_options->radio_align_left);
+ fl_deactivate_object(fd_form_table_options->radio_align_right);
+ fl_deactivate_object(fd_form_table_options->radio_align_center);
+ fl_set_object_lcol(fd_form_table_options->radio_align_left,
+ FL_INACTIVE);
+ fl_set_object_lcol(fd_form_table_options->radio_align_right,
+ FL_INACTIVE);
+ fl_set_object_lcol(fd_form_table_options->radio_align_center,
+ FL_INACTIVE);
+ } else {
+ fl_activate_object(fd_form_table_options->radio_align_left);
+ fl_activate_object(fd_form_table_options->radio_align_right);
+ fl_activate_object(fd_form_table_options->radio_align_center);
+ fl_set_object_lcol(fd_form_table_options->radio_align_left,
+ FL_BLACK);
+ fl_set_object_lcol(fd_form_table_options->radio_align_right,
+ FL_BLACK);
+ fl_set_object_lcol(fd_form_table_options->radio_align_center,
+ FL_BLACK);
+ }
+ fl_set_button(fd_form_table_options->radio_longtable, table->IsLongTable());
+ if (table->IsLongTable()) {
+ fl_activate_object(fd_form_table_options->radio_lt_firsthead);
+ fl_activate_object(fd_form_table_options->radio_lt_head);
+ fl_activate_object(fd_form_table_options->radio_lt_foot);
+ fl_activate_object(fd_form_table_options->radio_lt_lastfoot);
+ fl_activate_object(fd_form_table_options->radio_lt_newpage);
+ fl_set_object_lcol(fd_form_table_options->radio_lt_firsthead,
+ FL_BLACK);
+ fl_set_object_lcol(fd_form_table_options->radio_lt_head,
+ FL_BLACK);
+ fl_set_object_lcol(fd_form_table_options->radio_lt_foot,
+ FL_BLACK);
+ fl_set_object_lcol(fd_form_table_options->radio_lt_lastfoot,
+ FL_BLACK);
+ fl_set_object_lcol(fd_form_table_options->radio_lt_newpage,
+ FL_BLACK);
+ fl_set_button(fd_form_table_options->radio_lt_firsthead,
+ table->RowOfLTFirstHead(cell));
+ fl_set_button(fd_form_table_options->radio_lt_head,
+ table->RowOfLTHead(cell));
+ fl_set_button(fd_form_table_options->radio_lt_foot,
+ table->RowOfLTFoot(cell));
+ fl_set_button(fd_form_table_options->radio_lt_lastfoot,
+ table->RowOfLTLastFoot(cell));
+ fl_set_button(fd_form_table_options->radio_lt_newpage,
+ table->LTNewPage(cell));
+ } else {
+ fl_deactivate_object(fd_form_table_options->radio_lt_firsthead);
+ fl_deactivate_object(fd_form_table_options->radio_lt_head);
+ fl_deactivate_object(fd_form_table_options->radio_lt_foot);
+ fl_deactivate_object(fd_form_table_options->radio_lt_lastfoot);
+ fl_deactivate_object(fd_form_table_options->radio_lt_newpage);
+ fl_set_button(fd_form_table_options->radio_lt_firsthead, 0);
+ fl_set_button(fd_form_table_options->radio_lt_head, 0);
+ fl_set_button(fd_form_table_options->radio_lt_foot, 0);
+ fl_set_button(fd_form_table_options->radio_lt_lastfoot, 0);
+ fl_set_button(fd_form_table_options->radio_lt_newpage, 0);
+ fl_set_object_lcol(fd_form_table_options->radio_lt_firsthead,
+ FL_INACTIVE);
+ fl_set_object_lcol(fd_form_table_options->radio_lt_head,
+ FL_INACTIVE);
+ fl_set_object_lcol(fd_form_table_options->radio_lt_foot,
+ FL_INACTIVE);
+ fl_set_object_lcol(fd_form_table_options->radio_lt_lastfoot,
+ FL_INACTIVE);
+ fl_set_object_lcol(fd_form_table_options->radio_lt_newpage,
+ FL_INACTIVE);
+ }
+ fl_set_button(fd_form_table_options->radio_rotate_table,
+ table->RotateTable());
+ fl_set_focus_object(fd_form_table_options->form_table_options,
+ fd_form_table_options->button_table_delete);
+ } else if (fd_form_table_options->form_table_options->visible) {
+ fl_set_focus_object(fd_form_table_options->form_table_options,
+ fd_form_table_options->button_table_delete);
+ fl_hide_form(fd_form_table_options->form_table_options);
+ }
+ return update;
+}
+#else
bool UpdateLayoutTable(int flag)
{
bool update = true;
}
return update;
}
-
+#endif
void OpenLayoutTableExtra()
{
void TableOptionsCB(FL_OBJECT * ob, long)
{
LyXTable * table = 0;
- int
- s,
- num = 0;
- string
- special,
- str;
+ int s, num = 0;
+ string special, str;
+#ifdef MOVE_TEXT
+ if (!current_view->available()
+ || !(table = current_view->text->cursor.par->table)) {
+ MenuLayoutTable(0);
+ return;
+ }
+ int cell = current_view->text->
+ NumberOfCell(current_view->text->cursor.par,
+ current_view->text->cursor.pos);
+ if (ActCell != cell) {
+ MenuLayoutTable(0);
+ fl_set_object_label(fd_form_table_options->text_warning,
+ _("Warning: Wrong Cursor position, updated window"));
+ fl_show_object(fd_form_table_options->text_warning);
+ extra_col_cursor_x = 0; // would rather place it at the end, but...
+ extra_multicol_cursor_x = 0;
+ return;
+ }
+#else
if (!current_view->available()
||
!(table = current_view->buffer()->text->cursor.par->table)) {
extra_multicol_cursor_x = 0;
return;
}
+#endif
// No point in processing directives that you can't do anything with
// anyhow, so exit now if the buffer is read-only.
if (current_view->buffer()->isReadonly()) {
return;
if (current_view->available()){
current_view->getScreen()->HideCursor();
+#ifdef MOVE_TEXT
+ if (!current_view->text->selection){
+ BeforeChange();
+ current_view->update(-2);
+ }
+ if ((num == LyXTable::SET_SPECIAL_COLUMN) ||
+ (num == LyXTable::SET_SPECIAL_MULTI))
+ current_view->text->TableFeatures(num, special);
+ else
+ current_view->text->TableFeatures(num);
+ current_view->update(1);
+#else
if (!current_view->buffer()->text->selection){
BeforeChange();
current_view->buffer()->update(-2);
else
current_view->buffer()->text->TableFeatures(num);
current_view->buffer()->update(1);
+#endif
}
if (num == LyXTable::DELETE_TABLE) {
fl_set_focus_object(fd_form_table_options->form_table_options,
}
if (current_view->available()){
current_view->getScreen()->HideCursor();
+#ifdef MOVE_TEXT
+ if (!current_view->text->selection){
+ BeforeChange();
+ current_view->update(-2);
+ }
+ current_view->text->TableFeatures(LyXTable::SET_PWIDTH, str);
+ current_view->update(1);
+#else
if (!current_view->buffer()->text->selection){
BeforeChange();
current_view->buffer()->update(-2);
}
current_view->buffer()->text->TableFeatures(LyXTable::SET_PWIDTH, str);
current_view->buffer()->update(1);
+#endif
}
MenuLayoutTable(0); // update for alignment
}
#include "bufferlist.h"
#include "lyx_main.h"
#include "lyx_gui_misc.h"
+#include "LyXAction.h"
#include "lyxrc.h"
#include "lyxlex.h"
#include "tex-strings.h"
extern unsigned char GetCurrentTextClass();
extern void BeforeChange();
+extern void MenuMakeLaTeX(Buffer *);
+extern void MenuMakeLinuxDoc(Buffer *);
+extern void MenuMakeDocBook(Buffer *);
+extern void MenuRunLaTeX(Buffer *);
+extern void MenuPrint(Buffer *);
+extern void MenuMakeAscii(Buffer *);
+extern void MenuSendto();
+extern LyXAction lyxaction;
+
+
static const float LYX_FORMAT = 2.15;
extern int tex_code_break_column;
filename = file;
filepath = OnlyPath(file);
paragraph = 0;
+#ifndef MOVE_TEXT
text = 0;
+#endif
the_locking_inset = 0;
lyx_clean = true;
bak_clean = true;
par = tmppar;
}
paragraph = 0;
+#ifndef MOVE_TEXT
delete text;
+#endif
}
}
-void Buffer::setFileName(string const & newfile)
+void Buffer::fileName(string const & newfile)
{
filename = MakeAbsPath(newfile);
filepath = OnlyPath(filename);
updateTitles();
}
+
+// candidate for move to BufferView
void Buffer::InsetUnlock()
{
if (the_locking_inset) {
if (!inset_slept) the_locking_inset->InsetUnlock();
the_locking_inset = 0;
+#ifdef MOVE_TEXT
+ users->text->FinishUndo();
+#else
text->FinishUndo();
+#endif
inset_slept = false;
}
}
+// candidate for move to BufferView
// Inserts a file into current document
bool Buffer::insertLyXFile(string const & filen)
//
bool res = true;
+#ifdef MOVE_TEXT
+ if (c == '#') {
+ lyxerr.debug() << "Will insert file with header" << endl;
+ res = readFile(lex, users->text->cursor.par);
+ } else {
+ lyxerr.debug() << "Will insert file without header" << endl;
+ res = readLyXformat2(lex, users->text->cursor.par);
+ }
+#else
if (c == '#') {
lyxerr.debug() << "Will insert file with header" << endl;
res = readFile(lex, text->cursor.par);
lyxerr.debug() << "Will insert file without header" << endl;
res = readLyXformat2(lex, text->cursor.par);
}
+#endif
resize();
return res;
}
+// candidate for move to BufferView
+// (at least some parts in the beginning of the func)
//
// Uwe C. Schroeder
// changed to be public and have one parameter
if(!par) {
par = new LyXParagraph;
} else {
+#ifdef MOVE_TEXT
+ users->text->BreakParagraph();
+ return_par = users->text->FirstParagraph();
+#else
text->BreakParagraph();
return_par = text->FirstParagraph();
+#endif
pos = 0;
markDirty();
// We don't want to adopt the parameters from the
break;
}
if (ltype_depth > depth) {
- for(j = ltype_depth-1; j>depth; j--)
+ for(j = ltype_depth - 1; j > depth; --j)
ofs << " ";
currlinelen += (ltype_depth-depth)*2;
}
if (par->table) {
- for(j = 0;j<cells;j++) {
+ for(j = 0; j < cells; ++j) {
ofs << '+';
- for(h = 0; h < (clen[j]+1); h++)
+ for(h = 0; h < (clen[j] + 1);
+ ++h)
ofs << '-';
}
ofs << "+\n";
- for(j = 0; j<depth; j++)
+ for(j = 0; j < depth; ++j)
ofs << " ";
- currlinelen = depth*2;
+ currlinelen = depth * 2;
if (ltype_depth > depth) {
- for(j = ltype_depth; j>depth; j--)
+ for(j = ltype_depth;
+ j > depth; --j)
ofs << " ";
currlinelen += (ltype_depth-depth)*2;
}
for(j = actpos; j < clen[cell-1];j++)
ofs << ' ';
ofs << " |\n";
- for(j = 0; j<depth; j++)
+ for(j = 0; j < depth; ++j)
ofs << " ";
currlinelen = depth*2;
if (ltype_depth > depth) {
- for(j = ltype_depth; j>depth; j--)
+ for(j = ltype_depth; j > depth; --j)
ofs << " ";
- currlinelen += (ltype_depth-depth)*2;
+ currlinelen += (ltype_depth-depth) * 2;
}
- for(j = 0;j<cells;j++) {
+ for(j = 0; j < cells; ++j) {
ofs << '+';
- for(h = 0; h < (clen[j]+1); ++h)
+ for(h = 0; h < (clen[j] + 1); ++h)
ofs << '-';
}
ofs << "+\n";
- for(j = 0; j<depth; j++)
+ for(j = 0; j < depth; ++j)
ofs << " ";
- currlinelen = depth*2;
+ currlinelen = depth * 2;
if (ltype_depth > depth) {
- for(j = ltype_depth; j>depth; j--)
+ for(j = ltype_depth;
+ j > depth; --j)
ofs << " ";
currlinelen += (ltype_depth-depth)*2;
}
ofs << "| ";
cell = 1;
} else {
- for(j = actpos; j<clen[cell-1]; j++)
+ for(j = actpos;
+ j < clen[cell - 1]; ++j)
ofs << ' ';
ofs << " | ";
++cell;
currlinelen = actpos = 0;
} else {
ofs << "\n";
- for(j = 0; j<depth; j++)
+ for(j = 0; j < depth; ++j)
ofs << " ";
currlinelen = depth * 2;
if (ltype_depth > depth) {
- for(j = ltype_depth; j>depth; j--)
+ for(j = ltype_depth;
+ j > depth; --j)
ofs << " ";
- currlinelen += (ltype_depth-depth)*2;
+ currlinelen += (ltype_depth - depth) * 2;
}
}
break;
for(j = actpos; j < clen[cell - 1]; ++j)
ofs << ' ';
ofs << " |\n";
- for(j = 0; j<depth; j++)
+ for(j = 0; j < depth; ++j)
ofs << " ";
currlinelen = depth * 2;
if (ltype_depth > depth) {
for(j = ltype_depth; j > depth; --j)
ofs << " ";
- currlinelen += (ltype_depth-depth)*2;
+ currlinelen += (ltype_depth - depth) * 2;
}
- for(j = 0;j<cells; ++j) {
+ for(j = 0; j < cells; ++j) {
ofs << '+';
for(h = 0; h < (clen[j] + 1); ++h)
ofs << '-';
options += "onecolumn,";
}
- if (!params.use_geometry && params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
+ if (!params.use_geometry
+ && params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
options += "landscape,";
// language should be a parameter to \documentclass
}
+// candidate for move to BufferView
bool Buffer::removeAutoInsets()
{
LyXParagraph *par = paragraph;
+#ifdef MOVE_TEXT
+ LyXCursor cursor = users->text->cursor;
+#else
LyXCursor cursor = text->cursor;
+#endif
LyXCursor tmpcursor = cursor;
cursor.par = tmpcursor.par->ParFromPos(tmpcursor.pos);
cursor.pos = tmpcursor.par->PositionInParFromPos(tmpcursor.pos);
if (par->AutoDeleteInsets()){
a = true;
if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE){
+#ifdef MOVE_TEXT
+ /* this is possible now, since SetCursor takes
+ care about footnotes */
+ users->text->SetCursorIntern(par, 0);
+ users->text->RedoParagraphs(users->text->cursor, users->text->cursor.par->Next());
+ users->text->FullRebreak();
+#else
/* this is possible now, since SetCursor takes
care about footnotes */
text->SetCursorIntern(par, 0);
text->RedoParagraphs(text->cursor, text->cursor.par->Next());
text->FullRebreak();
+#endif
}
}
par = par->next;
/* avoid forbidden cursor positions caused by error removing */
if (cursor.pos > cursor.par->Last())
cursor.pos = cursor.par->Last();
+#ifdef MOVE_TEXT
+ users->text->SetCursorIntern(cursor.par, cursor.pos);
+#else
text->SetCursorIntern(cursor.par, cursor.pos);
+#endif
return a;
}
int Buffer::runLaTeX()
{
+#ifdef MOVE_TEXT
+ if (!users->text) return 0;
+#else
if (!text) return 0;
+#endif
ProhibitInput();
int Buffer::runLiterate()
{
+#ifdef MOVE_TEXT
+ if (!users->text) return 0;
+#else
if (!text) return 0;
+#endif
ProhibitInput();
int Buffer::buildProgram()
{
+#ifdef MOVE_TEXT
+ if (!users->text) return 0;
+#else
if (!text) return 0;
+#endif
ProhibitInput();
// Other flags: -wall -v0 -x
int Buffer::runChktex()
{
+#ifdef MOVE_TEXT
+ if (!users->text) return 0;
+#else
if (!text) return 0;
+#endif
ProhibitInput();
extern void AllFloats(char, char);
+// candidate for move to BufferView
void Buffer::insertErrors(TeXErrors & terr)
{
+#ifdef MOVE_TEXT
+ // Save the cursor position
+ LyXCursor cursor = users->text->cursor;
+#else
// Save the cursor position
LyXCursor cursor = text->cursor;
+#endif
// This is drastic, but it's the only fix, I could find. (Asger)
AllFloats(1, 0);
texrow.getIdFromRow(errorrow, tmpid, tmppos);
- LyXParagraph* texrowpar;
+ LyXParagraph * texrowpar = 0;
+#ifdef MOVE_TEXT
+ if (tmpid == -1) {
+ texrowpar = users->text->FirstParagraph();
+ tmppos = 0;
+ } else {
+ texrowpar = users->text->GetParFromID(tmpid);
+ }
+#else
if (tmpid == -1) {
texrowpar = text->FirstParagraph();
tmppos = 0;
} else {
texrowpar = text->GetParFromID(tmpid);
}
+#endif
if (texrowpar == 0)
continue;
InsetError * new_inset = new InsetError(msgtxt);
-
+#ifdef MOVE_TEXT
+ users->text->SetCursorIntern(texrowpar, tmppos);
+ users->text->InsertInset(new_inset);
+ users->text->FullRebreak();
+ }
+ // Restore the cursor position
+ users->text->SetCursorIntern(cursor.par, cursor.pos);
+#else
text->SetCursorIntern(texrowpar, tmppos);
text->InsertInset(new_inset);
text->FullRebreak();
}
// Restore the cursor position
text->SetCursorIntern(cursor.par, cursor.pos);
+#endif
}
+// candidate for move to BufferView
void Buffer::setCursorFromRow (int row)
{
int tmpid = -1;
texrow.getIdFromRow(row, tmpid, tmppos);
- LyXParagraph* texrowpar;
+ LyXParagraph * texrowpar;
+#ifdef MOVE_TEXT
+ if (tmpid == -1) {
+ texrowpar = users->text->FirstParagraph();
+ tmppos = 0;
+ } else {
+ texrowpar = users->text->GetParFromID(tmpid);
+ }
+ users->text->SetCursor(texrowpar, tmppos);
+#else
if (tmpid == -1) {
texrowpar = text->FirstParagraph();
tmppos = 0;
texrowpar = text->GetParFromID(tmpid);
}
text->SetCursor(texrowpar, tmppos);
+#endif
}
}
+#ifndef MOVE_TEXT
+// candidate for move to BufferView
void Buffer::update(signed char f)
{
if (!users) return;
users->owner()->updateLayoutChoice();
-
if (!text->selection && f > -3)
text->sel_cursor = text->cursor;
FreeUpdateTimer();
text->FullRebreak();
+
users->update();
if (f != 3 && f != -3) {
}
}
}
-
+#endif
void Buffer::validate(LaTeXFeatures & features)
{
}
#endif
+#ifdef MOVE_TEXT
+// candidate for move to BufferView
+void Buffer::insertInset(Inset * inset, string const & lout,
+ bool no_table)
+{
+ // check for table/list in tables
+ if (no_table && users->text->cursor.par->table){
+ WriteAlert(_("Impossible Operation!"),
+ _("Cannot insert table/list in table."),
+ _("Sorry."));
+ return;
+ }
+ // not quite sure if we want this...
+ users->text->SetCursorParUndo();
+ users->text->FreezeUndo();
+
+ BeforeChange();
+ if (!lout.empty()) {
+ users->update(-2);
+ users->text->BreakParagraph();
+ users->update(-1);
+
+ if (users->text->cursor.par->Last()) {
+ users->text->CursorLeft();
+
+ users->text->BreakParagraph();
+ users->update(-1);
+ }
+
+ int lay = textclasslist.NumberOfLayout(params.textclass,
+ lout).second;
+ if (lay == -1) // layout not found
+ // use default layout "Standard" (0)
+ lay = 0;
+
+ users->text->SetLayout(lay);
+
+ users->text->SetParagraph(0, 0,
+ 0, 0,
+ VSpace(VSpace::NONE), VSpace(VSpace::NONE),
+ LYX_ALIGN_LAYOUT,
+ string(),
+ 0);
+ users->update(-1);
+
+ users->text->current_font.setLatex(LyXFont::OFF);
+ }
+
+ users->text->InsertInset(inset);
+ users->update(-1);
+
+ users->text->UnFreezeUndo();
+}
+#else
void Buffer::insertInset(Inset * inset, string const & lout,
bool no_table)
{
text->UnFreezeUndo();
}
-
+#endif
// Open and lock an updatable inset
+// candidate for move to BufferView
void Buffer::open_new_inset(UpdatableInset * new_inset)
{
+#ifdef MOVE_TEXT
+ BeforeChange();
+ users->text->FinishUndo();
+ insertInset(new_inset);
+ users->text->CursorLeft();
+ users->update(1);
+ new_inset->Edit(0, 0);
+#else
BeforeChange();
text->FinishUndo();
insertInset(new_inset);
text->CursorLeft();
update(1);
new_inset->Edit(0, 0);
+#endif
}
/// if this is a child document and the parent is already loaded
/// Use the parent's list instead [ale990407]
if (!params.parentname.empty() && bufferlist.exists(params.parentname)) {
- Buffer *tmp = bufferlist.getBuffer(params.parentname);
+ Buffer * tmp = bufferlist.getBuffer(params.parentname);
if (tmp)
return tmp->getReferenceList(delim);
}
- LyXParagraph *par = paragraph;
+ LyXParagraph * par = paragraph;
LyXParagraph::size_type pos;
Inset * inset;
string lst;
/// if this is a child document and the parent is already loaded
/// Use the parent's list instead [ale990412]
if (!params.parentname.empty() && bufferlist.exists(params.parentname)) {
- Buffer *tmp = bufferlist.getBuffer(params.parentname);
+ Buffer * tmp = bufferlist.getBuffer(params.parentname);
if (tmp)
return tmp->getBibkeyList(delim);
}
}
+// candidate for move to BufferView
/* This is also a buffer property (ale) */
// Not so sure about that. a goto Label function can not be buffer local, just
// think how this will work in a multiwindo/buffer environment, all the
while ((inset = par->ReturnNextInsetPointer(pos))){
for (int i = 0; i < inset->GetNumberOfLabels(); i++) {
if (label == inset->getLabel(i)) {
+#ifdef MOVE_TEXT
+ BeforeChange();
+ users->text->SetCursor(par, pos);
+ users->text->sel_cursor = users->text->cursor;
+ users->update(0);
+ return true;
+#else
BeforeChange();
text->SetCursor(par, pos);
text->sel_cursor = text->cursor;
update(0);
return true;
+#endif
}
}
pos++;
}
}
}
+
+void Buffer::Dispatch(const string & command)
+{
+ // Split command string into command and argument
+ string cmd, line = frontStrip(command);
+ string arg = strip(frontStrip(split(line, cmd, ' ')));
+
+ return Dispatch(lyxaction.LookupFunc(cmd.c_str()), arg.c_str());
+}
+
+void Buffer::Dispatch(int action, const string & argument)
+{
+ switch (action) {
+ case LFUN_EXPORT: {
+ // latex
+ if (argument == "latex") {
+ // make sure that this buffer is not linuxdoc
+ MenuMakeLaTeX(this);
+ }
+ // linuxdoc
+ else if (argument == "linuxdoc") {
+ // make sure that this buffer is not latex
+ MenuMakeLinuxDoc(this);
+ }
+ // docbook
+ else if (argument == "docbook") {
+ // make sure that this buffer is not latex or linuxdoc
+ MenuMakeDocBook(this);
+ }
+ // dvi
+ else if (argument == "dvi") {
+ // Run LaTeX as "Update dvi..." Bernhard.
+ // We want the dvi in the current directory. This
+ // is achieved by temporarily disabling use of
+ // temp directory. As a side-effect, we get
+ // *.log and *.aux files also. (Asger)
+ bool flag = lyxrc->use_tempdir;
+ lyxrc->use_tempdir = false;
+ MenuRunLaTeX(this);
+ lyxrc->use_tempdir = flag;
+ }
+ // postscript
+ else if (argument == "postscript") {
+ // Start Print-dialog. Not as good as dvi... Bernhard.
+ MenuPrint(this);
+ // Since the MenuPrint is a pop-up, we can't use
+ // the same trick as above. (Asger)
+ // MISSING: Move of ps-file :-|
+ }
+ // ascii
+ else if (argument == "ascii") {
+ MenuMakeAscii(this);
+ }
+ else if (argument == "custom") {
+ MenuSendto();
+ break;
+ }
+ // HTML
+ else if (argument == "html" && lyxrc->html_command != "none") {
+ // First, create LaTeX file
+ MenuMakeLaTeX(this);
+
+ // And now, run the converter
+ string file = fileName();
+ Path path(OnlyPath(file));
+ // the tex file name has to be correct for
+ // latex, but the html file name can be
+ // anything.
+ string result = ChangeExtension(file, ".html", false);
+ file = ChangeExtension(MakeLatexName(file), ".tex", false);
+ string tmp = lyxrc->html_command;
+ tmp = subst(tmp, "$$FName", file);
+ tmp = subst(tmp, "$$OutName", result);
+ Systemcalls one;
+ /*int res = */ one.startscript(Systemcalls::System, tmp);
+ //
+ // Hi, Asger. This time I plead guilty and I promise to clean it up
+ //
+ // if (res == 0) {
+ // setMessage(N_("Document exported as HTML to file `")
+ // + MakeDisplayPath(result) +'\ '');
+ // } else {
+ // setErrorMessage(N_("Unable to convert to HTML the file `")
+ // + MakeDisplayPath(file)
+ // + '\'');
+ // }
+ }
+ else {
+ // setErrorMessage(N_("Unknown export type: ")
+ // + argument);
+ }
+ }
+ break;
+
+ default:
+ lyxerr << "A truly unknown func!" << endl;
+ break;
+
+ } // end of switch
+
+}
#include "lyxtext.h"
#include "support/filetools.h"
+#define MOVE_TEXT 1
class LyXRC;
class TeXErrors;
*/
bool saveParamsAsDefaults();
+ /** high-level interface to buffer functionality
+ This function parses a command string and executes it
+ */
+ void Dispatch(const string & command);
+
+ /// Maybe we know the function already by number...
+ void Dispatch(int ac, const string & argument);
+
/// should be changed to work for a list.
void resize()
{
if (users) {
users->resize();
- } else if (text) {
+ }
+#ifndef MOVE_TEXT
+ else if (text) {
delete text;
text = 0;
}
+#endif
}
/// Update window titles of all users
Since we only can have one at the moment, we just reset it.
*/
void delUser(BufferView *){ users = 0; }
-
+
+#ifndef MOVE_TEXT
///
void update(signed char f);
+#endif
///
void redraw() {
}
///
- string getFileName() const { return filename; }
+ string const & fileName() const { return filename; }
/// A transformed version of the file name, adequate for LaTeX
string getLatexName() const {
}
/// Change name of buffer. Updates "read-only" flag.
- void setFileName(string const & newfile);
+ void fileName(string const & newfile);
/// Name of the document's parent
void setParentName(string const &);
/** is a list of paragraphs.
*/
LyXParagraph * paragraph;
-
+
+#ifndef MOVE_TEXT
/** This holds the mapping between buffer paragraphs and screen rows.
Should be moved to BufferView. (Asger)
*/
LyXText * text;
-
- ///
+#endif
+ /// per view not per buffer?
UpdatableInset * the_locking_inset;
/// RCS object
/** While writing as LaTeX, tells whether we are
doing a 'nice' LaTeX file */
bool niceFile;
-protected:
+
///
void InsetUnlock();
///
void DocBookHandleCaption(ostream & os, string & inner_tag,
int const depth, int desc_on,
- LyXParagraph * &par);
+ LyXParagraph * & par);
///
void DocBookHandleFootnote(ostream & os,
LyXParagraph * & par, int const depth);
*/
BufferView * users;
- ///
- friend class BufferList;
- ///
- friend class BufferView;
-
/// Used when typesetting to place errorboxes.
TexRow texrow;
};
it != bstore.end(); ++it) {
if (!(*it)->isLyxClean()) {
switch(AskConfirmation(_("Changes in document:"),
- MakeDisplayPath((*it)->filename,
+ MakeDisplayPath((*it)->fileName(),
50),
_("Save document?"))) {
case 1: // Yes
break;
case 2: // No
askMoreConfirmation = true;
- unsaved += MakeDisplayPath((*it)->filename, 50);
+ unsaved += MakeDisplayPath((*it)->fileName(), 50);
unsaved += "\n";
break;
case 3: // Cancel
bool BufferList::write(Buffer * buf, bool makeBackup)
{
minibuffer->Set(_("Saving document"),
- MakeDisplayPath(buf->filename), "...");
+ MakeDisplayPath(buf->fileName()), "...");
// We don't need autosaves in the immediate future. (Asger)
buf->resetAutosaveTimers();
// make a backup
if (makeBackup) {
- string s = buf->filename + '~';
+ string s = buf->fileName() + '~';
// Rename is the wrong way of making a backup,
// this is the correct way.
/* truss cp fil fil2:
// Doing it this way, also makes the inodes stay the same.
// This is still not a very good solution, in particular we
// might loose the owner of the backup.
- FileInfo finfo(buf->filename);
+ FileInfo finfo(buf->fileName());
if (finfo.exist()) {
mode_t fmode = finfo.getMode();
times->modtime = finfo.getModificationTime();
long blksize = finfo.getBlockSize();
lyxerr.debug() << "BlockSize: " << blksize << endl;
- FilePtr fin(buf->filename, FilePtr::read);
+ FilePtr fin(buf->fileName(), FilePtr::read);
FilePtr fout(s, FilePtr::truncate);
if (fin() && fout()) {
char * cbuf = new char[blksize+1];
}
}
- if (buf->writeFile(buf->filename, false)) {
+ if (buf->writeFile(buf->fileName(), false)) {
buf->markLyxClean();
minibuffer->Set(_("Document saved as"),
- MakeDisplayPath(buf->filename));
+ MakeDisplayPath(buf->fileName()));
// now delete the autosavefile
- string a = OnlyPath(buf->filename);
+ string a = OnlyPath(buf->fileName());
a += '#';
- a += OnlyFilename(buf->filename);
+ a += OnlyFilename(buf->fileName());
a += '#';
FileInfo fileinfo(a);
if (fileinfo.exist()) {
} else {
// Saving failed, so backup is not backup
if (makeBackup) {
- string s = buf->filename + '~';
- rename(s.c_str(), buf->filename.c_str());
+ string s = buf->fileName() + '~';
+ rename(s.c_str(), buf->fileName().c_str());
}
minibuffer->Set(_("Save failed!"));
return false;
if (buf->paragraph && !buf->isLyxClean() && !quitting) {
ProhibitInput();
switch(AskConfirmation(_("Changes in document:"),
- MakeDisplayPath(buf->filename, 50),
+ MakeDisplayPath(buf->fileName(), 50),
_("Save document?"))){
case 1: // Yes
if (write(buf)) {
- lastfiles->newFile(buf->filename);
+ lastfiles->newFile(buf->fileName());
} else {
AllowInput();
return false;
int ant = 0;
for(BufferStorage::iterator it = bstore.begin();
it != bstore.end(); ++it) {
- string relbuf = MakeDisplayPath((*it)->filename, 30);
+ string relbuf = MakeDisplayPath((*it)->fileName(), 30);
fl_addtopup(pup, relbuf.c_str());
++ant;
}
{
for (BufferStorage::iterator it = bstore.begin();
it != bstore.end(); ++it) {
+#ifdef MOVE_TEXT
+ if ((*it)->getUser() && (*it)->getUser()->text->UpdateInset(inset)) {
+ if (mark_dirty)
+ (*it)->markDirty();
+ break;
+ }
+#else
if ((*it)->text && (*it)->text->UpdateInset(inset)) {
if (mark_dirty)
(*it)->markDirty();
break;
}
+#endif
}
}
if (!(*it)->isDepClean(mastertmpdir)) {
string writefile = mastertmpdir;
writefile += '/';
- writefile += ChangeExtension((*it)->getFileName(),
+ writefile += ChangeExtension((*it)->fileName(),
".tex", true);
(*it)->makeLaTeXFile(writefile, mastertmpdir,
false, true);
lyxerr <<_("lyx: Attempting to save"
" document ")
- << (*it)->filename
+ << (*it)->fileName()
<< _(" as...") << endl;
for (int i = 0; i < 3 && !madeit; ++i) {
// 2) In HOME directory.
// 3) In "/tmp" directory.
if (i == 0) {
- s = (*it)->filename;
+ s = (*it)->fileName();
} else if (i == 1) {
s = AddName(GetEnvPath("HOME"),
- (*it)->filename);
+ (*it)->fileName());
} else { // MakeAbsPath to prepend the current drive letter on OS/2
s = AddName(MakeAbsPath("/tmp/"),
- (*it)->filename);
+ (*it)->fileName());
}
s += ".emergency";
{
for (BufferStorage::iterator it = bstore.begin();
it != bstore.end(); ++it) {
- if ((*it)->filename == s)
+ if ((*it)->fileName() == s)
return true;
}
return false;
{
for(BufferStorage::iterator it = bstore.begin();
it != bstore.end(); ++it) {
- if ((*it)->filename == s)
+ if ((*it)->fileName() == s)
return (*it);
}
return 0;
}
if (b && tolastfiles)
- lastfiles->newFile(b->getFileName());
+ lastfiles->newFile(b->fileName());
return b;
}
Regenerate();
os << "Figure size " << wid << " " << hgh << "\n";
if (!fname.empty()) {
- string buf1 = OnlyPath(owner->getFileName());
+ string buf1 = OnlyPath(owner->fileName());
string fname2 = MakeRelPath(fname, buf1);
os << "file " << fname2 << "\n";
}
} else if (token == "file") {
if (lex.next()) {
buf = lex.GetString();
- string buf1 = OnlyPath(owner->getFileName());
+ string buf1 = OnlyPath(owner->fileName());
fname = MakeAbsPath(buf, buf1);
changedfname = true;
}
return;
}
- string buf1 = OnlyPath(owner->getFileName());
+ string buf1 = OnlyPath(owner->fileName());
string fname2 = MakeRelPath(fname, buf1);
string gcmd = "\\includegraphics{" + fname2 + '}';
return;
}
- string buf1 = OnlyPath(owner->getFileName());
+ string buf1 = OnlyPath(owner->fileName());
string fname2 = MakeRelPath(tfname, buf1);
// \includegraphics*[<llx,lly>][<urx,ury>]{file}
string gcmd = "\\includegraphics{" + fname2 + '}';
angle = atof(fl_get_input(form->Angle));
p = fl_get_input(form->EpsFile);
if (p && *p) {
- string buf1 = OnlyPath(owner->getFileName());
+ string buf1 = OnlyPath(owner->fileName());
fname = MakeAbsPath(p, buf1);
changedfname = true;
} else {
fl_hide_form(form->Figure);
#if FL_REVISION == 89
#warning Reactivate this free_form calls
+#warning Jug, is this still a problem?
#else
fl_free_form(form->Figure);
free(form);
sprintf(buf, "%g", angle);
fl_set_input(form->Angle, buf);
if (!fname.empty()){
- string buf1 = OnlyPath(owner->getFileName());
+ string buf1 = OnlyPath(owner->fileName());
string fname2 = MakeRelPath(fname, buf1);
fl_set_input(form->EpsFile, fname2.c_str());
}
return; // parent process
}
- string buf1 = OnlyPath(owner->getFileName());
+ string buf1 = OnlyPath(owner->fileName());
string buf2 = MakeAbsPath(p, buf1);
lyxerr << "Error during rendering "
if (lyxerr.debugging()) {
lyxerr << "Filename: "
- << owner->getFileName() << endl;
+ << owner->fileName() << endl;
}
string p = fl_get_input(form->EpsFile);
- string buf = MakeAbsPath(owner->getFileName());
+ string buf = MakeAbsPath(owner->fileName());
string buf2 = OnlyPath(buf);
if (!p.empty()) {
buf = MakeAbsPath(p, buf2);
buf = OnlyPath(buf);
} else {
- buf = OnlyPath(owner->getFileName().c_str());
+ buf = OnlyPath(owner->fileName().c_str());
}
// Does user clipart directory exist?
inset->setOptions(fl_get_input(bibitem_form->label));
fl_hide_form(bibitem_form->bibitem_form);
// Does look like a hack? It is! (but will change at 0.13)
+#ifdef MOVE_TEXT
+ current_view->text->RedoParagraph();
+ current_view->update(1);
+#else
current_view->buffer()->text->RedoParagraph();
current_view->buffer()->update(1);
+#endif
break;
} // fall through to Cancel on RO-mode
}
///
void setFilename(string const & n) { setContents(n); }
///
- string getMasterFilename() const { return master->getFileName(); }
+ string getMasterFilename() const { return master->fileName(); }
///
string getFileName() const {
return filename;
: InsetCommand("lyxparent")
{
if (owner)
- setContents(MakeAbsPath(fn, OnlyPath(owner->getFileName())));
+ setContents(MakeAbsPath(fn, OnlyPath(owner->fileName())));
else
setContents(fn);
}
}
-Intl::~Intl()
-{
-}
-
-
int Intl::SetPrimary(string const & lang)
{
if (lyxerr.debugging(Debug::KBMAP))
void Intl::KeyMapPrim()
{
- int i;
- string p;
-
fl_set_button(fd_form_keymap->KeyOffBtn, 0);
fl_set_button(fd_form_keymap->KeyOnBtn, 1);
fl_set_button(fd_form_keymap->KeyOnBtn2, 0);
/* read text from choice */
- i = Language->get();
+ int i = Language->get();
if (lyxerr.debugging(Debug::KBMAP))
lyxerr << "Table: " << tex_babel[i-1] << endl;
+ string p;
if (i == otherkeymap)
p = fl_get_input(fd_form_keymap->OtherKeymap);
else
public:
///
Intl();
- ///
- ~Intl();
/// show key mapping dialog
void MenuKeymap();
///
int SetSecondary(string const &);
- // insert correct stuff into paragraph
- //void TranslateAndInsert(char c, LyXText *text);
-
/// initialize key mapper
void InitKeyMapper(bool on);
/// Get the Translation Manager
- inline TransManager *getTrans();
+ inline TransManager * getTrans();
///
bool keymapon;
///
- char *chsetcode;
+ char * chsetcode;
///
- static void DispatchCallback(FL_OBJECT*, long);
+ static void DispatchCallback(FL_OBJECT *, long);
private:
- ///
- //int SelectCharset(char const *code);
///
void update();
///
int otherkeymap;
///
- FD_KeyMap *fd_form_keymap;
+ FD_KeyMap * fd_form_keymap;
///
- Combox *Language;
+ Combox * Language;
///
- Combox *Language2;
+ Combox * Language2;
///
string & prim_lang;
///
string & sec_lang;
///
- TransManager *trans;
+ TransManager * trans;
};
-TransManager* Intl::getTrans()
+TransManager * Intl::getTrans()
{
return trans;
}
}
+// candidate for move to BufferView
void BeforeChange()
{
current_view->getScreen()->ToggleSelection();
+#ifdef MOVE_TEXT
+ current_view->text->ClearSelection();
+#else
current_view->buffer()->text->ClearSelection();
+#endif
FreeUpdateTimer();
}
+// candidate for move to BufferView
void SmallUpdate(signed char f)
{
current_view->getScreen()->SmallUpdate();
if (current_view->getScreen()->TopCursorVisible()
!= current_view->getScreen()->first){
+#ifdef MOVE_TEXT
+ current_view->update(f);
+#else
current_view->buffer()->update(f);
+#endif
return;
}
current_view->fitCursor();
current_view->updateScrollbar();
-
+
+#ifdef MOVE_TEXT
+ if (!current_view->text->selection)
+ current_view->text->sel_cursor =
+ current_view->text->cursor;
+#else
if (!current_view->buffer()->text->selection)
current_view->buffer()->text->sel_cursor =
current_view->buffer()->text->cursor;
+#endif
if (f == 1 || f == -1) {
if (current_view->buffer()->isLyxClean()) {
{
XFlush(fl_display);
if (!bufferlist.write(buf)) {
- string fname = buf->getFileName();
+ string fname = buf->fileName();
string s = MakeAbsPath(fname);
if (AskQuestion(_("Save failed. Rename and try again?"),
MakeDisplayPath(s, 50),
MenuWriteAs(buf);
}
} else {
- lastfiles->newFile(buf->getFileName());
+ lastfiles->newFile(buf->fileName());
}
}
// should be moved to BufferView.C
void MenuWriteAs(Buffer * buffer)
{
+#ifdef MOVE_TEXT
+ if (!current_view->text) return;
+#else
if (!buffer->text) return;
+#endif
- string fname = buffer->getFileName();
+ string fname = buffer->fileName();
string oldname = fname;
LyXFileDlg fileDlg;
bufferlist.close(bufferlist.getBuffer(s));
// Ok, change the name of the buffer, but don't save!
- buffer->setFileName(s);
+ buffer->fileName(s);
buffer->markDirty();
minibuffer->Set(_("Document renamed to '"),
}
// Ok, change the name of the buffer
- buffer->setFileName(s);
+ buffer->fileName(s);
buffer->markDirty();
// And save
// Small bug: If the save fails, we have irreversible changed the name
int ret = 0;
if (buffer->isLinuxDoc())
- ret = RunLinuxDoc(1, buffer->getFileName());
+ ret = RunLinuxDoc(1, buffer->fileName());
else if (buffer->isLiterate())
ret = buffer->runLiterate();
else if (buffer->isDocBook())
- ret = RunDocBook(1, buffer->getFileName());
+ ret = RunDocBook(1, buffer->fileName());
else
ret = buffer->runLaTeX();
int MakeDVIOutput(Buffer * buffer)
{
+#ifdef MOVE_TEXT
+ if (!(current_view->text))
+ return 1;
+#else
if (!(buffer->text))
return 1;
+#endif
int ret = 0;
- string path = OnlyPath(buffer->getFileName());
+ string path = OnlyPath(buffer->fileName());
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
path = buffer->tmppath;
}
// Returns false if we fail
bool MenuRunDvips(Buffer * buffer, bool wait = false)
{
+#ifdef MOVE_TEXT
+ if (!current_view->text)
+ return false;
+#else
if (!buffer->text)
return false;
+#endif
ProhibitInput();
return false;
}
// Generate postscript file
- string psname = ChangeExtension (buffer->getFileName(),
+ string psname = ChangeExtension (buffer->fileName(),
".ps_tmp", true);
string paper;
command += lyxrc->print_landscape_flag;
}
// push directorypath, if necessary
- string path = OnlyPath(buffer->getFileName());
+ string path = OnlyPath(buffer->fileName());
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
path = buffer->tmppath;
}
// Returns false if we fail
bool MenuPreviewPS(Buffer * buffer)
{
+#ifdef MOVE_TEXT
+ if (!current_view->text)
+ return false;
+#else
if (!buffer->text)
return false;
+#endif
// Generate postscript file
if (!MenuRunDvips(buffer, true)) {
// Start postscript viewer
ProhibitInput();
- string ps = ChangeExtension (buffer->getFileName(),
+ string ps = ChangeExtension (buffer->fileName(),
".ps_tmp", true);
// push directorypath, if necessary
- string path = OnlyPath(buffer->getFileName());
+ string path = OnlyPath(buffer->fileName());
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
path = buffer->tmppath;
}
void MenuFax(Buffer * buffer)
{
+#ifdef MOVE_TEXT
+ if (!current_view->text)
+ return;
+#else
if (!buffer->text)
return;
+#endif
// Generate postscript file
if (!MenuRunDvips(buffer, true)) {
}
// Send fax
- string ps = ChangeExtension (buffer->getFileName(), ".ps_tmp", true);
- string path = OnlyPath (buffer->getFileName());
+ string ps = ChangeExtension (buffer->fileName(), ".ps_tmp", true);
+ string path = OnlyPath (buffer->fileName());
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
path = buffer->tmppath;
}
// Returns false if we fail
bool MenuPreview(Buffer * buffer)
{
+#ifdef MOVE_TEXT
+ if (!current_view->text)
+ return false;
+#else
if (!buffer->text)
return false;
-
+#endif
string paper;
char real_papersize = buffer->params.papersize;
}
// push directorypath, if necessary
- string path = OnlyPath(buffer->getFileName());
+ string path = OnlyPath(buffer->fileName());
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
path = buffer->tmppath;
}
void MenuMakeLaTeX(Buffer * buffer)
{
- if (buffer->text) {
- // Get LaTeX-Filename
- string s = buffer->getLatexName();
-
- FileInfo fi(s);
- if (fi.readable() &&
- !AskQuestion(_("File already exists:"),
- MakeDisplayPath(s, 50),
- _("Do you want to overwrite the file?"))) {
- minibuffer->Set(_("Canceled"));
- return;
- }
-
- if (buffer->isDocBook())
- minibuffer->Set(_("DocBook does not have a latex backend"));
- else {
- if (buffer->isLinuxDoc())
- RunLinuxDoc(0, buffer->getFileName());
- else
- buffer->makeLaTeXFile(s, string(), true);
- minibuffer->Set(_("Nice LaTeX file saved as"),
- MakeDisplayPath(s));
- buffer->markDviDirty();
+#ifdef MOVE_TEXT
+ if (!current_view->text)
+ return;
+#else
+ if (!buffer->text)
+ return;
+#endif
+
+ // Get LaTeX-Filename
+ string s = buffer->getLatexName();
+
+ FileInfo fi(s);
+ if (fi.readable() &&
+ !AskQuestion(_("File already exists:"),
+ MakeDisplayPath(s, 50),
+ _("Do you want to overwrite the file?"))) {
+ minibuffer->Set(_("Canceled"));
+ return;
}
+
+ if (buffer->isDocBook())
+ minibuffer->Set(_("DocBook does not have a latex backend"));
+ else {
+ if (buffer->isLinuxDoc())
+ RunLinuxDoc(0, buffer->fileName());
+ else
+ buffer->makeLaTeXFile(s, string(), true);
+ minibuffer->Set(_("Nice LaTeX file saved as"),
+ MakeDisplayPath(s));
+ buffer->markDviDirty();
}
}
void MenuMakeLinuxDoc(Buffer * buffer)
{
- if (buffer->text) {
- if (!buffer->isLinuxDoc()) {
- WriteAlert(_("Error!"), _("Document class must be linuxdoc."));
- return;
- }
-
- // Get LinuxDoc-Filename
- string s = ChangeExtension (buffer->getFileName(),
- ".sgml", false);
-
- FileInfo fi(s);
- if (fi.readable() &&
- !AskQuestion(_("File already exists:"),
- MakeDisplayPath(s, 50),
- _("Do you want to overwrite the file?"))) {
- minibuffer->Set(_("Canceled"));
- return;
- }
-
- minibuffer->Set(_("Building LinuxDoc SGML file `"),
- MakeDisplayPath(s), "'...");
-
- buffer->makeLinuxDocFile(s, 65);
- buffer->redraw();
- minibuffer->Set(_("LinuxDoc SGML file save as"),
- MakeDisplayPath(s));
+#ifdef MOVE_TEXT
+ if (!current_view->text) return;
+#else
+ if (!buffer->text) return;
+#endif
+
+ if (!buffer->isLinuxDoc()) {
+ WriteAlert(_("Error!"), _("Document class must be linuxdoc."));
+ return;
}
+
+ // Get LinuxDoc-Filename
+ string s = ChangeExtension (buffer->fileName(),
+ ".sgml", false);
+
+ FileInfo fi(s);
+ if (fi.readable() &&
+ !AskQuestion(_("File already exists:"),
+ MakeDisplayPath(s, 50),
+ _("Do you want to overwrite the file?"))) {
+ minibuffer->Set(_("Canceled"));
+ return;
+ }
+
+ minibuffer->Set(_("Building LinuxDoc SGML file `"),
+ MakeDisplayPath(s), "'...");
+
+ buffer->makeLinuxDocFile(s, 65);
+ buffer->redraw();
+ minibuffer->Set(_("LinuxDoc SGML file save as"),
+ MakeDisplayPath(s));
}
void MenuMakeDocBook(Buffer * buffer)
{
- if (buffer->text) {
- if (!buffer->isDocBook()) {
- WriteAlert(_("Error!"),
- _("Document class must be docbook."));
- return;
- }
-
- // Get DocBook-Filename
- string s = ChangeExtension (buffer->getFileName(),
- ".sgml", false);
-
- FileInfo fi(s);
- if (fi.readable() &&
- !AskQuestion(_("File already exists:"),
- MakeDisplayPath(s, 50),
- _("Do you want to overwrite the file?"))) {
- minibuffer->Set(_("Canceled"));
- return;
- }
-
- minibuffer->Set(_("Building DocBook SGML file `"),
- MakeDisplayPath(s), "'...");
-
- buffer->makeDocBookFile(s, 65);
- buffer->redraw();
- minibuffer->Set(_("DocBook SGML file save as"),
- MakeDisplayPath(s));
+#ifdef MOVE_TEXT
+ if (!current_view->text) return;
+#else
+ if (!buffer->text) return;
+#endif
+
+ if (!buffer->isDocBook()) {
+ WriteAlert(_("Error!"),
+ _("Document class must be docbook."));
+ return;
}
+
+ // Get DocBook-Filename
+ string s = ChangeExtension (buffer->fileName(),
+ ".sgml", false);
+
+ FileInfo fi(s);
+ if (fi.readable() &&
+ !AskQuestion(_("File already exists:"),
+ MakeDisplayPath(s, 50),
+ _("Do you want to overwrite the file?"))) {
+ minibuffer->Set(_("Canceled"));
+ return;
+ }
+
+ minibuffer->Set(_("Building DocBook SGML file `"),
+ MakeDisplayPath(s), "'...");
+
+ buffer->makeDocBookFile(s, 65);
+ buffer->redraw();
+ minibuffer->Set(_("DocBook SGML file save as"),
+ MakeDisplayPath(s));
}
void MenuMakeAscii(Buffer * buffer)
{
- if (buffer->text) {
- /* get LaTeX-Filename */
- string s = ChangeExtension (buffer->getFileName(),
- ".txt", false);
-
- FileInfo fi(s);
- if (fi.readable() &&
- !AskQuestion(_("File already exists:"),
- MakeDisplayPath(s, 50),
- _("Do you want to overwrite the file?"))) {
- minibuffer->Set(_("Canceled"));
- return;
- }
-
- buffer->writeFileAscii(s, lyxrc->ascii_linelen);
-
- minibuffer->Set(_("Ascii file saved as"), MakeDisplayPath(s));
+#ifdef MOVE_TEXT
+ if (!current_view->text) return;
+#else
+ if (!buffer->text) return;
+#endif
+
+ /* get LaTeX-Filename */
+ string s = ChangeExtension (buffer->fileName(),
+ ".txt", false);
+
+ FileInfo fi(s);
+ if (fi.readable() &&
+ !AskQuestion(_("File already exists:"),
+ MakeDisplayPath(s, 50),
+ _("Do you want to overwrite the file?"))) {
+ minibuffer->Set(_("Canceled"));
+ return;
}
+
+ buffer->writeFileAscii(s, lyxrc->ascii_linelen);
+
+ minibuffer->Set(_("Ascii file saved as"), MakeDisplayPath(s));
}
void MenuPrint(Buffer * buffer)
{
- if (!buffer->text)
+#ifdef MOVE_TEXT
+ if (!current_view->text)
return;
-
- string input_file = ChangeExtension(buffer->getFileName(),
+#else
+ if (!buffer->text)
+ return;
+#endif
+ string input_file = ChangeExtension(buffer->fileName(),
lyxrc->print_file_extension,
true);
fl_set_input(fd_form_print->input_file, input_file.c_str());
minibuffer->Set(_("Autosaving current document..."));
// create autosave filename
- string fname = OnlyPath(current_view->buffer()->getFileName());
+ string fname = OnlyPath(current_view->buffer()->fileName());
fname += "#";
- fname += OnlyFilename(current_view->buffer()->getFileName());
+ fname += OnlyFilename(current_view->buffer()->fileName());
fname += "#";
// tmp_ret will be located (usually) in /tmp
// find a free buffer
Buffer * tmpbuf = bufferlist.newFile(name, tmpname);
if (tmpbuf)
- lastfiles->newFile(tmpbuf->getFileName());
+ lastfiles->newFile(tmpbuf->fileName());
return tmpbuf;
}
// clear the selection
BeforeChange();
+#ifdef MOVE_TEXT
+ if (!asParagraph)
+ current_view->text->InsertStringA(tmppar->text);
+ else
+ current_view->text->InsertStringB(tmppar->text);
+ delete tmppar;
+ current_view->update(1);
+#else
if (!asParagraph)
current_view->buffer()->text->InsertStringA(tmppar->text);
else
current_view->buffer()->text->InsertStringB(tmppar->text);
delete tmppar;
current_view->buffer()->update(1);
+#endif
}
}
+// candidate for move to BufferView
extern "C" void FootCB(FL_OBJECT *, long)
{
if (!current_view->available())
minibuffer->Set(_("Inserting Footnote..."));
current_view->getScreen()->HideCursor();
+#ifdef MOVE_TEXT
+ current_view->update(-2);
+ current_view->text->InsertFootnoteEnvironment(LyXParagraph::FOOTNOTE);
+ current_view->update(1);
+#else
current_view->buffer()->update(-2);
current_view->buffer()->text->InsertFootnoteEnvironment(LyXParagraph::FOOTNOTE);
current_view->buffer()->update(1);
+#endif
}
+// candidate for move to LyXView
void LayoutsCB(int sel, void *)
{
string tmp = tostr(sel);
}
+// candidate for move to BufferView
void AllFloats(char flag, char figmar)
{
if (!current_view->available())
return;
-
+
+#ifdef MOVE_TEXT
+ LyXCursor cursor = current_view->text->cursor;
+#else
LyXCursor cursor = current_view->buffer()->text->cursor;
+#endif
if (!flag && cursor.par->footnoteflag != LyXParagraph::NO_FOOTNOTE
&& ((figmar
if (par->previous
&& par->previous->footnoteflag !=
LyXParagraph::CLOSED_FOOTNOTE){ /* should be */
+#ifdef MOVE_TEXT
+ current_view->text
+ ->SetCursorIntern(par
+ ->previous,
+ 0);
+ current_view->text->OpenFootnote();
+#else
current_view->buffer()->text->SetCursorIntern(par->previous,
0);
current_view->buffer()->text->OpenFootnote();
+#endif
}
}
}
)
)
){
+#ifdef MOVE_TEXT
+ current_view->text->SetCursorIntern(par, 0);
+ current_view->text->CloseFootnote();
+#else
current_view->buffer()->text->SetCursorIntern(par, 0);
current_view->buffer()->text->CloseFootnote();
+#endif
}
}
par = par->next;
}
+#ifdef MOVE_TEXT
+ current_view->text->SetCursorIntern(cursor.par, cursor.pos);
+#else
current_view->buffer()->text->SetCursorIntern(cursor.par, cursor.pos);
+#endif
current_view->redraw();
current_view->fitCursor();
current_view->updateScrollbar();
}
+#ifdef MOVE_TEXT
+bool UpdateLayoutParagraph()
+{
+ if (!current_view->getScreen() || !current_view->available()) {
+ if (fd_form_paragraph->form_paragraph->visible)
+ fl_hide_form(fd_form_paragraph->form_paragraph);
+ return false;
+ }
+
+ Buffer * buf = current_view->buffer();
+
+ fl_set_input(fd_form_paragraph->input_labelwidth,
+ current_view->text->cursor.par->GetLabelWidthString().c_str());
+ fl_set_button(fd_form_paragraph->radio_align_right, 0);
+ fl_set_button(fd_form_paragraph->radio_align_left, 0);
+ fl_set_button(fd_form_paragraph->radio_align_center, 0);
+ fl_set_button(fd_form_paragraph->radio_align_block, 0);
+
+ int align = current_view->text->cursor.par->GetAlign();
+ if (align == LYX_ALIGN_LAYOUT)
+ align = textclasslist.Style(buf->params.textclass,
+ current_view->text->cursor.par->GetLayout()).align;
+
+ switch (align) {
+ case LYX_ALIGN_RIGHT:
+ fl_set_button(fd_form_paragraph->radio_align_right, 1);
+ break;
+ case LYX_ALIGN_LEFT:
+ fl_set_button(fd_form_paragraph->radio_align_left, 1);
+ break;
+ case LYX_ALIGN_CENTER:
+ fl_set_button(fd_form_paragraph->radio_align_center, 1);
+ break;
+ default:
+ fl_set_button(fd_form_paragraph->radio_align_block, 1);
+ break;
+ }
+
+ fl_set_button(fd_form_paragraph->check_lines_top,
+ current_view->text->cursor.par->FirstPhysicalPar()->line_top);
+ fl_set_button(fd_form_paragraph->check_lines_bottom,
+ current_view->text->cursor.par->FirstPhysicalPar()->line_bottom);
+ fl_set_button(fd_form_paragraph->check_pagebreaks_top,
+ current_view->text->cursor.par->FirstPhysicalPar()->pagebreak_top);
+ fl_set_button(fd_form_paragraph->check_pagebreaks_bottom,
+ current_view->text->cursor.par->FirstPhysicalPar()->pagebreak_bottom);
+ fl_set_button(fd_form_paragraph->check_noindent,
+ current_view->text->cursor.par->FirstPhysicalPar()->noindent);
+ fl_set_input (fd_form_paragraph->input_space_above, "");
+
+ switch (current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.kind()) {
+ case VSpace::NONE:
+ fl_set_choice (fd_form_paragraph->choice_space_above, 1);
+ break;
+ case VSpace::DEFSKIP:
+ fl_set_choice (fd_form_paragraph->choice_space_above, 2);
+ break;
+ case VSpace::SMALLSKIP:
+ fl_set_choice (fd_form_paragraph->choice_space_above, 3);
+ break;
+ case VSpace::MEDSKIP:
+ fl_set_choice (fd_form_paragraph->choice_space_above, 4);
+ break;
+ case VSpace::BIGSKIP:
+ fl_set_choice (fd_form_paragraph->choice_space_above, 5);
+ break;
+ case VSpace::VFILL:
+ fl_set_choice (fd_form_paragraph->choice_space_above, 6);
+ break;
+ case VSpace::LENGTH:
+ fl_set_choice (fd_form_paragraph->choice_space_above, 7);
+ fl_set_input (fd_form_paragraph->input_space_above,
+ current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.length().asString().c_str());
+ break;
+ }
+ fl_set_button (fd_form_paragraph->check_space_above,
+ current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.keep());
+ fl_set_input (fd_form_paragraph->input_space_below, "");
+ switch (current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.kind()) {
+ case VSpace::NONE:
+ fl_set_choice (fd_form_paragraph->choice_space_below,
+ 1);
+ break;
+ case VSpace::DEFSKIP:
+ fl_set_choice (fd_form_paragraph->choice_space_below,
+ 2);
+ break;
+ case VSpace::SMALLSKIP:
+ fl_set_choice (fd_form_paragraph->choice_space_below,
+ 3);
+ break;
+ case VSpace::MEDSKIP:
+ fl_set_choice (fd_form_paragraph->choice_space_below,
+ 4);
+ break;
+ case VSpace::BIGSKIP:
+ fl_set_choice (fd_form_paragraph->choice_space_below,
+ 5);
+ break;
+ case VSpace::VFILL:
+ fl_set_choice (fd_form_paragraph->choice_space_below,
+ 6);
+ break;
+ case VSpace::LENGTH:
+ fl_set_choice (fd_form_paragraph->choice_space_below,
+ 7);
+ fl_set_input (fd_form_paragraph->input_space_below,
+ current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.length().asString().c_str());
+ break;
+ }
+ fl_set_button (fd_form_paragraph->check_space_below,
+ current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.keep());
+
+ fl_set_button(fd_form_paragraph->check_noindent,
+ current_view->text->cursor.par->FirstPhysicalPar()->noindent);
+
+ if (current_view->buffer()->isReadonly()) {
+ DisableParagraphLayout();
+ } else {
+ EnableParagraphLayout();
+ }
+ return true;
+}
+#else
bool UpdateLayoutParagraph()
{
if (!current_view->getScreen() || !current_view->available()) {
}
return true;
}
-
+#endif
void MenuLayoutParagraph()
{
}
+// candidate for move to BufferView
void NoteCB()
{
InsetInfo * new_inset = new InsetInfo();
}
+// candidate for move to BufferView
void OpenStuff()
{
if (current_view->available()) {
minibuffer->Set(_("Open/Close..."));
current_view->getScreen()->HideCursor();
BeforeChange();
+#ifdef MOVE_TEXT
+ current_view->update(-2);
+ current_view->text->OpenStuff();
+ current_view->update(0);
+#else
current_view->buffer()->update(-2);
current_view->buffer()->text->OpenStuff();
current_view->buffer()->update(0);
+#endif
}
}
+// candidate for move to BufferView
void ToggleFloat()
{
if (current_view->available()) {
minibuffer->Set(_("Open/Close..."));
current_view->getScreen()->HideCursor();
BeforeChange();
+#ifdef MOVE_TEXT
+ current_view->update(-2);
+ current_view->text->ToggleFootnote();
+ current_view->update(0);
+#else
current_view->buffer()->update(-2);
current_view->buffer()->text->ToggleFootnote();
current_view->buffer()->update(0);
+#endif
}
}
+// candidate for move to BufferView
void MenuUndo()
{
/* if (current_view->buffer()->the_locking_inset) {
minibuffer->Set(_("Undo"));
current_view->getScreen()->HideCursor();
BeforeChange();
+#ifdef MOVE_TEXT
+ current_view->update(-2);
+ if (!current_view->text->TextUndo())
+ minibuffer->Set(_("No further undo information"));
+ else
+ current_view->update(-1);
+#else
current_view->buffer()->update(-2);
if (!current_view->buffer()->text->TextUndo())
minibuffer->Set(_("No further undo information"));
else
current_view->buffer()->update(-1);
+#endif
}
}
+// candidate for move to BufferView
void MenuRedo()
{
if (current_view->buffer()->the_locking_inset) {
minibuffer->Set(_("Redo"));
current_view->getScreen()->HideCursor();
BeforeChange();
+#ifdef MOVE_TEXT
+ current_view->update(-2);
+ if (!current_view->text->TextRedo())
+ minibuffer->Set(_("No further redo information"));
+ else
+ current_view->update(-1);
+#else
current_view->buffer()->update(-2);
if (!current_view->buffer()->text->TextRedo())
minibuffer->Set(_("No further redo information"));
else
current_view->buffer()->update(-1);
+#endif
}
}
+// candidate for move to BufferView
void HyphenationPoint()
{
if (current_view->available()) {
current_view->getScreen()->HideCursor();
+#ifdef MOVE_TEXT
+ current_view->update(-2);
+#else
current_view->buffer()->update(-2);
+#endif
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::HYPHENATION);
current_view->buffer()->insertInset(new_inset);
}
+// candidate for move to BufferView
void Ldots()
{
if (current_view->available()) {
current_view->getScreen()->HideCursor();
+#ifdef MOVE_TEXT
+ current_view->update(-2);
+#else
current_view->buffer()->update(-2);
+#endif
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::LDOTS);
current_view->buffer()->insertInset(new_inset);
}
+// candidate for move to BufferView
void EndOfSentenceDot()
{
if (current_view->available()) {
current_view->getScreen()->HideCursor();
+#ifdef MOVE_TEXT
+ current_view->update(-2);
+#else
current_view->buffer()->update(-2);
+#endif
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::END_OF_SENTENCE);
current_view->buffer()->insertInset(new_inset);
}
+// candidate for move to BufferView
void MenuSeparator()
{
if (current_view->available()) {
current_view->getScreen()->HideCursor();
+#ifdef MOVE_TEXT
+ current_view->update(-2);
+#else
current_view->buffer()->update(-2);
+#endif
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::MENU_SEPARATOR);
current_view->buffer()->insertInset(new_inset);
}
+// candidate for move to BufferView
void Newline()
{
if (current_view->available()) {
current_view->getScreen()->HideCursor();
+#ifdef MOVE_TEXT
+ current_view->update(-2);
+ current_view->text->InsertChar(LyXParagraph::META_NEWLINE);
+ current_view->update(-1);
+#else
current_view->buffer()->update(-2);
current_view->buffer()->text->InsertChar(LyXParagraph::META_NEWLINE);
current_view->buffer()->update(-1);
+#endif
}
}
+// candidate for move to BufferView
void ProtectedBlank()
{
if (current_view->available()) {
current_view->getScreen()->HideCursor();
+#ifdef MOVE_TEXT
+ current_view->update(-2);
+ current_view->text->InsertChar(LyXParagraph::META_PROTECTED_SEPARATOR);
+ current_view->update(-1);
+#else
current_view->buffer()->update(-2);
current_view->buffer()->text->InsertChar(LyXParagraph::META_PROTECTED_SEPARATOR);
current_view->buffer()->update(-1);
+#endif
}
}
+// candidate for move to BufferView
void HFill()
{
if (current_view->available()) {
current_view->getScreen()->HideCursor();
+#ifdef MOVE_TEXT
+ current_view->update(-2);
+ current_view->text->InsertChar(LyXParagraph::META_HFILL);
+ current_view->update(-1);
+#else
current_view->buffer()->update(-2);
current_view->buffer()->text->InsertChar(LyXParagraph::META_HFILL);
current_view->buffer()->update(-1);
+#endif
}
}
* future perhaps we could try to implement a callback to the button-bar.
* That is, `light' the bold button when the font is currently bold, etc.
*/
+#ifdef MOVE_TEXT
+string CurrentState()
+{
+ string state;
+ if (current_view->available()) {
+ // I think we should only show changes from the default
+ // font. (Asger)
+ Buffer * buffer = current_view->buffer();
+ LyXFont font = current_view->text->real_current_font;
+ LyXFont defaultfont = textclasslist.TextClass(buffer->
+ params.textclass).defaultfont();
+ font.reduce(defaultfont);
+ state = _("Font: ") + font.stateText();
+
+ int depth = current_view->text->GetDepth();
+ if (depth > 0)
+ state += string(_(", Depth: ")) + tostr(depth);
+ }
+ return state;
+}
+#else
string CurrentState()
{
string state;
}
return state;
}
+#endif
-
+// candidate for move to BufferView
/* -------> Does the actual toggle job of the XxxCB() calls above.
* Also shows the current font state.
*/
{
if (current_view->available()) {
current_view->getScreen()->HideCursor();
+#ifdef MOVE_TEXT
+ current_view->update(-2);
+ current_view->text->ToggleFree(font, toggleall);
+ current_view->update(1);
+#else
current_view->buffer()->update(-2);
current_view->buffer()->text->ToggleFree(font, toggleall);
current_view->buffer()->update(1);
+#endif
}
// removed since it overrides the ToggleFree Message about the style
// Since Styles are more "High Level" than raw fonts I think the user
}
+// candidate for move to BufferView
extern "C" void MarginCB(FL_OBJECT *, long)
{
if (current_view->available()) {
minibuffer->Set(_("Inserting margin note..."));
current_view->getScreen()->HideCursor();
+#ifdef MOVE_TEXT
+ current_view->update(-2);
+ current_view->text->InsertFootnoteEnvironment(LyXParagraph::MARGIN);
+ current_view->update(1);
+#else
current_view->buffer()->update(-2);
current_view->buffer()->text->InsertFootnoteEnvironment(LyXParagraph::MARGIN);
current_view->buffer()->update(1);
+#endif
}
}
}
+// candidate for move to BufferView
void CopyEnvironmentCB()
{
if (current_view->available()) {
+#ifdef MOVE_TEXT
+ current_view->text->copyEnvironmentType();
+ /* clear the selection, even if mark_set */
+ current_view->getScreen()->ToggleSelection();
+ current_view->text->ClearSelection();
+ current_view->update(-2);
+ minibuffer->Set(_("Paragraph environment type copied"));
+#else
current_view->buffer()->text->copyEnvironmentType();
/* clear the selection, even if mark_set */
current_view->getScreen()->ToggleSelection();
current_view->buffer()->text->ClearSelection();
current_view->buffer()->update(-2);
minibuffer->Set(_("Paragraph environment type copied"));
+#endif
}
}
+// candidate for move to BufferView
void PasteEnvironmentCB()
{
if (current_view->available()) {
+#ifdef MOVE_TEXT
+ current_view->text->pasteEnvironmentType();
+ minibuffer->Set(_("Paragraph environment type set"));
+ current_view->update(1);
+#else
current_view->buffer()->text->pasteEnvironmentType();
minibuffer->Set(_("Paragraph environment type set"));
current_view->buffer()->update(1);
+#endif
}
}
+// candidate for move to BufferView
void CopyCB()
{
if (current_view->available()) {
+#ifdef MOVE_TEXT
+ current_view->text->CopySelection();
+ /* clear the selection, even if mark_set */
+ current_view->getScreen()->ToggleSelection();
+ current_view->text->ClearSelection();
+ current_view->update(-2);
+ minibuffer->Set(_("Copy"));
+#else
current_view->buffer()->text->CopySelection();
/* clear the selection, even if mark_set */
current_view->getScreen()->ToggleSelection();
current_view->buffer()->text->ClearSelection();
current_view->buffer()->update(-2);
minibuffer->Set(_("Copy"));
+#endif
}
}
+// candidate for move to BufferView
void CutCB()
{
if (current_view->available()) {
current_view->getScreen()->HideCursor();
+#ifdef MOVE_TEXT
+ current_view->update(-2);
+ current_view->text->CutSelection();
+ current_view->update(1);
+#else
current_view->buffer()->update(-2);
current_view->buffer()->text->CutSelection();
current_view->buffer()->update(1);
+#endif
minibuffer->Set(_("Cut"));
}
}
+// candidate for move to BufferView
void PasteCB()
{
if (!current_view->available()) return;
minibuffer->Set(_("Paste"));
current_view->getScreen()->HideCursor();
+ /* clear the selection */
+#ifdef MOVE_TEXT
+ current_view->getScreen()->ToggleSelection();
+ current_view->text->ClearSelection();
+ current_view->update(-2);
+
+ /* paste */
+ current_view->text->PasteSelection();
+ current_view->update(1);
+
/* clear the selection */
+ current_view->getScreen()->ToggleSelection();
+ current_view->text->ClearSelection();
+ current_view->update(-2);
+#else
current_view->getScreen()->ToggleSelection();
current_view->buffer()->text->ClearSelection();
current_view->buffer()->update(-2);
current_view->getScreen()->ToggleSelection();
current_view->buffer()->text->ClearSelection();
current_view->buffer()->update(-2);
+#endif
}
+// candidate for move to BufferView
extern "C" void MeltCB(FL_OBJECT *, long)
{
if (!current_view->available()) return;
minibuffer->Set(_("Melt"));
current_view->getScreen()->HideCursor();
BeforeChange();
+#ifdef MOVE_TEXT
+ current_view->update(-2);
+ current_view->text->MeltFootnoteEnvironment();
+ current_view->update(1);
+#else
current_view->buffer()->update(-2);
current_view->buffer()->text->MeltFootnoteEnvironment();
current_view->buffer()->update(1);
+#endif
}
+// candidate for move to BufferView
// Change environment depth.
// if decInc == 0, depth change taking mouse button number into account
// if decInc == 1, increment depth
if (current_view->available()) {
current_view->getScreen()->HideCursor();
+#ifdef MOVE_TEXT
+ current_view->update(-2);
+ if (button == 1)
+ current_view->text->IncDepth();
+ else
+ current_view->text->DecDepth();
+ current_view->update(1);
+#else
current_view->buffer()->update(-2);
if (button == 1)
current_view->buffer()->text->IncDepth();
else
current_view->buffer()->text->DecDepth();
current_view->buffer()->update(1);
+#endif
minibuffer->Set(_("Changed environment depth"
" (in possible range, maybe not)"));
}
labelwidthstring = fl_get_input(fd_form_paragraph->input_labelwidth);
noindent = fl_get_button(fd_form_paragraph->check_noindent);
-
+
+#ifdef MOVE_TEXT
+ current_view->text->SetParagraph(line_top,
+ line_bottom,
+ pagebreak_top,
+ pagebreak_bottom,
+ space_top,
+ space_bottom,
+ align,
+ labelwidthstring,
+ noindent);
+ current_view->update(1);
+#else
current_view->buffer()->text->SetParagraph(line_top,
line_bottom,
pagebreak_top,
labelwidthstring,
noindent);
current_view->buffer()->update(1);
+#endif
minibuffer->Set(_("Paragraph layout set"));
}
// successfully loaded
redo = true;
minibuffer->Set(_("Converting document to new document class..."));
+#ifdef MOVE_TEXT
+ int ret = current_view->text->
+ SwitchLayoutsBetweenClasses(current_view->buffer()->
+ params.textclass,
+ new_class,
+ current_view->buffer()->
+ paragraph);
+#else
int ret = current_view->buffer()->
text->
SwitchLayoutsBetweenClasses(current_view->buffer()->
new_class,
current_view->buffer()->
paragraph);
+#endif
if (ret){
string s;
}
+// candidate for move to BufferView
+#ifdef MOVE_TEXT
+void GotoNote()
+{
+ if (!current_view->getScreen())
+ return;
+
+ current_view->getScreen()->HideCursor();
+ BeforeChange();
+ current_view->update(-2);
+ LyXCursor tmp;
+
+ if (!current_view->text->GotoNextNote()) {
+ if (current_view->text->cursor.pos
+ || current_view->text->cursor.par !=
+ current_view->text->FirstParagraph())
+ {
+ tmp = current_view->text->cursor;
+ current_view->text->cursor.par =
+ current_view->text->FirstParagraph();
+ current_view->text->cursor.pos = 0;
+ if (!current_view->text->GotoNextNote()) {
+ current_view->text->cursor = tmp;
+ minibuffer->Set(_("No more notes"));
+ LyXBell();
+ }
+ } else {
+ minibuffer->Set(_("No more notes"));
+ LyXBell();
+ }
+ }
+ current_view->update(0);
+ current_view->text->sel_cursor =
+ current_view->text->cursor;
+}
+#else
void GotoNote()
{
if (!current_view->getScreen())
current_view->buffer()->text->sel_cursor =
current_view->buffer()->text->cursor;
}
+#endif
-
+// candidate for move to BufferView
void InsertCorrectQuote()
{
Buffer * cbuffer = current_view->buffer();
char c;
+#ifdef MOVE_TEXT
+ if (current_view->text->cursor.pos )
+ c = current_view->text->cursor.par->GetChar(current_view->text->cursor.pos - 1);
+ else
+ c = ' ';
+#else
if (cbuffer->text->cursor.pos )
c = cbuffer->text->cursor.par->GetChar(cbuffer->text->cursor.pos - 1);
else
c = ' ';
+#endif
cbuffer->insertInset(new InsetQuotes(c, cbuffer->params));
}
/* callbacks for form form_table */
+#ifdef MOVE_TEXT
+extern "C" void TableApplyCB(FL_OBJECT *, long)
+{
+ if (!current_view->getScreen())
+ return;
+
+ // check for tables in tables
+ if (current_view->text->cursor.par->table){
+ WriteAlert(_("Impossible Operation!"),
+ _("Cannot insert table in table."),
+ _("Sorry."));
+ return;
+ }
+
+ minibuffer->Set(_("Inserting table..."));
+
+ int ysize = int(fl_get_slider_value(fd_form_table->slider_columns) + 0.5);
+ int xsize = int(fl_get_slider_value(fd_form_table->slider_rows) + 0.5);
+
+
+ current_view->getScreen()->HideCursor();
+ BeforeChange();
+ current_view->update(-2);
+
+ current_view->text->SetCursorParUndo();
+ current_view->text->FreezeUndo();
+
+ current_view->text->BreakParagraph();
+ current_view->update(-1);
+
+ if (current_view->text->cursor.par->Last()) {
+ current_view->text->CursorLeft();
+
+ current_view->text->BreakParagraph();
+ current_view->update(-1);
+ }
+
+ current_view->text->current_font.setLatex(LyXFont::OFF);
+ //if (!fl_get_button(fd_form_table->check_latex)){
+ // insert the new wysiwy table
+ current_view->text->SetLayout(0); // standard layout
+ if (current_view->text->cursor.par->footnoteflag ==
+ LyXParagraph::NO_FOOTNOTE) {
+ current_view->text
+ ->SetParagraph(0, 0,
+ 0, 0,
+ VSpace (0.3 * current_view->buffer()->
+ params.spacing.getValue(),
+ LyXLength::CM),
+ VSpace (0.3 * current_view->buffer()->
+ params.spacing.getValue(),
+ LyXLength::CM),
+ LYX_ALIGN_CENTER,
+ string(),
+ 0);
+ }
+ else
+ current_view->text
+ ->SetParagraph(0, 0,
+ 0, 0,
+ VSpace(VSpace::NONE),
+ VSpace(VSpace::NONE),
+ LYX_ALIGN_CENTER,
+ string(),
+ 0);
+
+ current_view->text->cursor.par->table =
+ new LyXTable(xsize, ysize);
+
+ for (int i = 0; i < xsize * ysize - 1; ++i)
+ current_view->text->cursor.par->InsertChar(0, LyXParagraph::META_NEWLINE);
+ current_view->text->RedoParagraph();
+
+ current_view->text->UnFreezeUndo();
+
+ current_view->update(1);
+ minibuffer->Set(_("Table inserted"));
+}
+#else
extern "C" void TableApplyCB(FL_OBJECT *, long)
{
if (!current_view->getScreen())
current_view->buffer()->update(1);
minibuffer->Set(_("Table inserted"));
}
-
+#endif
extern "C" void TableCancelCB(FL_OBJECT *, long)
{
if (!current_view->available())
return;
Buffer * buffer = current_view->buffer();
- string path = OnlyPath(buffer->getFileName());
+ string path = OnlyPath(buffer->fileName());
string pageflag;
if (fl_get_button(fd_form_print->radio_even_pages))
/* callbacks for form form_figure */
+#ifdef MOVE_TEXT
+extern "C" void FigureApplyCB(FL_OBJECT *, long)
+{
+ if (!current_view->available())
+ return;
+
+ Buffer * buffer = current_view->buffer();
+ if(buffer->isReadonly()) // paranoia
+ return;
+
+ minibuffer->Set(_("Inserting figure..."));
+ if (fl_get_button(fd_form_figure->radio_inline)
+ || current_view->text->cursor.par->table) {
+ InsetFig * new_inset = new InsetFig(100, 20, buffer);
+ buffer->insertInset(new_inset);
+ minibuffer->Set(_("Figure inserted"));
+ new_inset->Edit(0, 0);
+ return;
+ }
+
+ current_view->getScreen()->HideCursor();
+ current_view->update(-2);
+ BeforeChange();
+
+ current_view->text->SetCursorParUndo();
+ current_view->text->FreezeUndo();
+
+ current_view->text->BreakParagraph();
+ current_view->update(-1);
+
+ if (current_view->text->cursor.par->Last()) {
+ current_view->text->CursorLeft();
+
+ current_view->text->BreakParagraph();
+ current_view->update(-1);
+ }
+ // The standard layout should always be numer 0;
+ current_view->text->SetLayout(0);
+
+ if (current_view->text->cursor.par->footnoteflag ==
+ LyXParagraph::NO_FOOTNOTE) {
+ current_view->text->
+ SetParagraph(0, 0,
+ 0, 0,
+ VSpace (0.3 * buffer->params.spacing.getValue(),
+ LyXLength::CM),
+ VSpace (0.3 *
+ buffer->params.spacing.getValue(),
+ LyXLength::CM),
+ LYX_ALIGN_CENTER, string(), 0);
+ } else
+ current_view->text->SetParagraph(0, 0,
+ 0, 0,
+ VSpace(VSpace::NONE),
+ VSpace(VSpace::NONE),
+ LYX_ALIGN_CENTER,
+ string(),
+ 0);
+
+ current_view->update(-1);
+
+ Inset * new_inset = new InsetFig(100, 100, buffer);
+ buffer->insertInset(new_inset);
+ new_inset->Edit(0, 0);
+ current_view->update(0);
+ minibuffer->Set(_("Figure inserted"));
+ current_view->text->UnFreezeUndo();
+}
+#else
extern "C" void FigureApplyCB(FL_OBJECT *, long)
{
if (!current_view->available())
minibuffer->Set(_("Figure inserted"));
buffer->text->UnFreezeUndo();
}
-
+#endif
extern "C" void FigureCancelCB(FL_OBJECT *, long)
{
}
+// candidate for move to BufferView
/* these functions are for the spellchecker */
char * NextWord(float & value)
{
value = 1;
return 0;
}
-
+
+#ifdef MOVE_TEXT
+ char * string = current_view->text->SelectNextWord(value);
+#else
char * string = current_view->buffer()->text->SelectNextWord(value);
+#endif
return string;
}
+// candidate for move to BufferView
void SelectLastWord()
{
if (!current_view->available())
return;
current_view->getScreen()->HideCursor();
- BeforeChange();
+ BeforeChange();
+#ifdef MOVE_TEXT
+ current_view->text->SelectSelectedWord();
+ current_view->getScreen()->ToggleSelection(false);
+ current_view->update(0);
+#else
current_view->buffer()->text->SelectSelectedWord();
current_view->getScreen()->ToggleSelection(false);
current_view->buffer()->update(0);
+#endif
}
+// candidate for move to BufferView
void EndOfSpellCheck()
{
if (!current_view->available())
return;
current_view->getScreen()->HideCursor();
- BeforeChange();
+ BeforeChange();
+#ifdef MOVE_TEXT
+ current_view->text->SelectSelectedWord();
+ current_view->text->ClearSelection();
+ current_view->update(0);
+#else
current_view->buffer()->text->SelectSelectedWord();
current_view->buffer()->text->ClearSelection();
current_view->buffer()->update(0);
+#endif
}
+// candidate for move to BufferView
void ReplaceWord(string const & replacestring)
{
if (!current_view->getScreen())
return;
current_view->getScreen()->HideCursor();
+#ifdef MOVE_TEXT
+ current_view->update(-2);
+
+ /* clear the selection (if there is any) */
+ current_view->getScreen()->ToggleSelection(false);
+ current_view->update(-2);
+
+ /* clear the selection (if there is any) */
+ current_view->getScreen()->ToggleSelection(false);
+ current_view->text->
+ ReplaceSelectionWithString(replacestring.c_str());
+
+ current_view->text->SetSelectionOverString(replacestring.c_str());
+
+ // Go back so that replacement string is also spellchecked
+ for (string::size_type i = 0; i < replacestring.length() + 1; ++i) {
+ current_view->text->CursorLeftIntern();
+ }
+ current_view->update(1);
+#else
+ current_view->buffer()->update(-2);
+
+ /* clear the selection (if there is any) */
+ current_view->getScreen()->ToggleSelection(false);
+
current_view->buffer()->update(-2);
/* clear the selection (if there is any) */
current_view->buffer()->text->CursorLeftIntern();
}
current_view->buffer()->update(1);
+#endif
}
// End of spellchecker stuff
}
if (par) {
+#ifdef MOVE_TEXT
+ BeforeChange();
+ current_view->text->SetCursor(par, 0);
+ current_view->text->sel_cursor =
+ current_view->text->cursor;
+ current_view->update(0);
+#else
BeforeChange();
current_view->buffer()->text->SetCursor(par, 0);
current_view->buffer()->text->sel_cursor =
current_view->buffer()->text->cursor;
current_view->buffer()->update(0);
+#endif
}
else {
WriteAlert(_("Error"),
}
line[pos] = ' ';
- pos++;
+ ++pos;
/* now the contents */
LyXParagraph::size_type i = 0;
line[pos] = c;
pos++;
}
- i++;
+ ++i;
}
line[pos] = '\0';
fl_add_browser_line(fd_form_toc->browser_toc, line);
tmptoclist->next = 0;
int a = 0;
- for (a = 0; a<6; a++){
+ for (a = 0; a < 6; ++a) {
tmptoclist->counter[a] = par->GetFirstCounter(a);
}
tmptoclist->appendix = par->appendix;
char const * const btmp = fl_get_browser_line(brow,
fl_get_browser(brow));
string currentstr = btmp ? btmp : "";
- //string currentstr = fl_get_browser_line(brow,
- // fl_get_browser(brow));
fl_clear_browser(brow);
}
+// candidate for move to BufferView
void UpdateInset(Inset * inset, bool mark_dirty)
{
if (!inset)
/* very first check for locking insets*/
if (current_view->buffer()->the_locking_inset == inset){
+#ifdef MOVE_TEXT
+ if (current_view->text->UpdateInset(inset)){
+ current_view->update();
+ if (mark_dirty){
+ if (current_view->buffer()->isLyxClean())
+ minibuffer->setTimer(4);
+ current_view->buffer()->markDirty();
+ }
+ current_view->updateScrollbar();
+ return;
+ }
+#else
if (current_view->buffer()->text->UpdateInset(inset)){
current_view->update();
if (mark_dirty){
current_view->updateScrollbar();
return;
}
+#endif
}
/* first check the current buffer */
if (current_view->available()){
current_view->getScreen()->HideCursor();
+#ifdef MOVE_TEXT
+ current_view->update(-3);
+ if (current_view->text->UpdateInset(inset)){
+ if (mark_dirty)
+ current_view->update(1);
+ else
+ current_view->update(3);
+ return;
+ }
+#else
current_view->buffer()->update(-3);
if (current_view->buffer()->text->UpdateInset(inset)){
if (mark_dirty)
current_view->buffer()->update(3);
return;
}
+#endif
}
// check all buffers
}
+// candidate for move to BufferView
/* these functions return 1 if an error occured,
otherwise 0 */
int LockInset(UpdatableInset * inset)
}
+// candidate for move to BufferView
void ShowLockedInsetCursor(long x, long y, int asc, int desc)
{
if (current_view->buffer()->the_locking_inset &&
current_view->getScreen()){
+#ifdef MOVE_TEXT
+ y += current_view->text->cursor.y;
+#else
y += current_view->buffer()->text->cursor.y;
+#endif
current_view->getScreen()->ShowManualCursor(x, y,
asc, desc);
}
}
+// candidate for move to BufferView
void HideLockedInsetCursor(long x, long y, int asc, int desc)
{
if (current_view->buffer()->the_locking_inset &&
current_view->getScreen()){
+#ifdef MOVE_TEXT
+ y += current_view->text->cursor.y;
+#else
y += current_view->buffer()->text->cursor.y;
+#endif
current_view->getScreen()->HideManualCursor(x, y,
asc, desc);
}
}
+// candidate for move to BufferView
void FitLockedInsetCursor(long x, long y, int asc, int desc)
{
if (current_view->buffer()->the_locking_inset &&
current_view->getScreen()){
+#ifdef MOVE_TEXT
+ y += current_view->text->cursor.y;
+#else
y += current_view->buffer()->text->cursor.y;
+#endif
if (current_view->getScreen()->FitManualCursor(x, y, asc, desc))
current_view->updateScrollbar();
}
}
+// candidate for move to BufferView
int UnlockInset(UpdatableInset * inset)
{
if (inset &&
current_view->buffer()->the_locking_inset == inset){
inset->InsetUnlock();
current_view->buffer()->the_locking_inset = 0;
+#ifdef MOVE_TEXT
+ current_view->text->FinishUndo();
+#else
current_view->buffer()->text->FinishUndo();
+#endif
return 0;
}
return bufferlist.unlockInset(inset);
}
+// candidate for move to BufferView
void LockedInsetStoreUndo(Undo::undo_kind kind)
{
if (!current_view->buffer()->the_locking_inset)
return; // shouldn't happen
if (kind == Undo::EDIT) // in this case insets would not be stored!
kind = Undo::FINISH;
+#ifdef MOVE_TEXT
+ current_view->text->SetUndo(kind,
+ current_view->text->cursor.par->
+ ParFromPos(current_view->text->cursor.pos)->previous,
+ current_view->text->cursor.par->
+ ParFromPos(current_view->text->cursor.pos)->next);
+#else
current_view->buffer()->text->SetUndo(kind,
current_view->buffer()->text->cursor.par->
ParFromPos(current_view->buffer()->text->cursor.pos)->previous,
current_view->buffer()->text->cursor.par->
- ParFromPos(current_view->buffer()->text->cursor.pos)->next);
+ ParFromPos(current_view->buffer()->text->cursor.pos)->next);
+#endif
}
{
WriteAlert(_("Any changes will be ignored"),
_("The document is read-only:"),
- current_view->buffer()->getFileName());
+ current_view->buffer()->fileName());
}
lyxerr.debug() << "Yes we loaded some files." << endl;
lyxGUI->regBuf(last_loaded);
}
+
+ // Execute batch commands if available
+ if (!batch_command.empty() && last_loaded) {
+ lyxerr << "About to handle -x '" << batch_command << "'" << endl;
+ //Buffer buffer("Script Buffer");
+ //buffer.Dispatch(batch_command);
+ last_loaded->Dispatch(batch_command);
+ lyxerr << "We are done!" << endl;
+ return; // Maybe we could do something more clever than aborting..
+ }
// Let the ball begin...
lyxGUI->runTime();
string arg = argv[i];
// Check for -dbg int
if (arg == "-dbg") {
- if (i+1 < *argc) {
- setDebuggingLevel(argv[i+1]);
+ if (i + 1 < *argc) {
+ setDebuggingLevel(argv[i + 1]);
// Now, remove these two arguments by shifting
// the following two places down.
(*argc) -= 2;
- for (int j= i; j < (*argc); j++)
- argv[j] = argv[j+2];
- i--; // After shift, check this number again.
+ for (int j = i; j < (*argc); ++j)
+ argv[j] = argv[j + 2];
+ --i; // After shift, check this number again.
} else
lyxerr << _("Missing number for -dbg switch!")
<< endl;
}
// Check for "-sysdir"
else if (arg == "-sysdir") {
- if (i+1 < *argc) {
- system_lyxdir = argv[i+1];
+ if (i + 1 < *argc) {
+ system_lyxdir = argv[i + 1];
// Now, remove these two arguments by shifting
// the following two places down.
(*argc) -= 2;
- for (int j= i; j < (*argc); j++)
- argv[j] = argv[j+2];
- i--; // After shift, check this number again.
+ for (int j= i; j < (*argc); ++j)
+ argv[j] = argv[j + 2];
+ --i; // After shift, check this number again.
} else
lyxerr << _("Missing directory for -sysdir switch!")
<< endl;
else if (arg == "-nw") {
gui = false;
}
+
+ // Check for "-x": Execute commands
+ else if (arg == "-x" || arg == "--execute") {
+ if (i + 1 < *argc) {
+ batch_command = string(argv[i + 1]);
+
+ // Now, remove these two arguments by shifting
+ // the following two places down.
+ (*argc) -= 2;
+ for (int j = i; j < (*argc); ++j)
+ argv[j] = argv[j + 2];
+ --i; // After shift, check this number again.
+
+ }
+ else
+ lyxerr << _("Missing command string after -x switch!") << endl;
+
+ // Argh. Setting gui to false segfaults..
+ //gui = false;
+ }
+
+ else if (arg == "-e" || arg == "--export") {
+ if (i + 1 < *argc) {
+ string type(argv[i+1]);
+
+ (*argc) -= 2;
+ for (int j = i; j < (*argc); ++j)
+ argv[j] = argv[j + 2];
+ --i; // After shift, check this number again.
+
+ if (type == "tex")
+ type = "latex";
+ else if (type == "ps")
+ type = "postscript";
+ else if (type == "text" || type == "txt")
+ type = "ascii";
+
+ if (type == "latex" || type == "postscript"
+ || type == "ascii" || type == "html")
+ batch_command = "buffer-export " + type;
+ else
+ lyxerr << _("Unknown file type '")
+ << type << _("' after ")
+ << arg << _(" switch!") << endl;
+ }
+ else
+ lyxerr << _("Missing file type [eg latex, "
+ "ps...] after ")
+ << arg << _(" switch!") << endl;
+ }
}
return gui;
}
/**@name Constructors and Deconstructors */
//@{
/// the only allowed constructor
- LyX(int *argc, char *argv[]); // constructor
+ LyX(int * argc, char * argv[]); // constructor
// Always is useful a destructor
~LyX();
//@}
/**@name Constructors and Deconstructors */
//@{
/// not allowed
- LyX(const LyX &){;} // not allowed
+ LyX(const LyX &) {} // not allowed
/// not allowed
- LyX(){;} // not allowed
+ LyX() {} // not allowed
//@}
/**@name Private variables */
/// does this user start lyx for the first time?
bool first_start;
///
+ string batch_command;
+ ///
struct sigaction act_;
//@}
/**@name Private Members */
LyXFindReplace0::StartSearch();
SetReplaceEnabled(!current_view->buffer()->isReadonly());
searchForward = true;
+#ifdef MOVE_TEXT
+ if (lsSearch.empty())
+ SetSearchString(GetSelectionOrWordAtCursor(current_view->text));
+#else
if (lsSearch.empty())
SetSearchString(GetSelectionOrWordAtCursor(current_view->buffer()->text));
+#endif
}
// TODO?: the user can insert multiple spaces with this routine (1999-01-11, dnaber)
void LyXFindReplace1::SearchReplaceCB()
{
- LyXText *ltCur;
-
if (!current_view->getScreen())
return;
if (current_view->buffer()->isReadonly())
string const replacestring = ReplaceString();
current_view->getScreen()->HideCursor();
+#ifdef MOVE_TEXT
+ current_view->update(-2);
+
+ LyXText * ltCur = current_view->text;
+ if (ltCur->selection) {
+ // clear the selection (if there is any)
+ current_view->getScreen()->ToggleSelection(false);
+ current_view->text->
+ ReplaceSelectionWithString(replacestring.c_str());
+ current_view->text->
+ SetSelectionOverString(replacestring.c_str());
+ current_view->update(1);
+ }
+#else
current_view->buffer()->update(-2);
- ltCur = current_view->buffer()->text;
+ LyXText * ltCur = current_view->buffer()->text;
if (ltCur->selection) {
// clear the selection (if there is any)
current_view->getScreen()->ToggleSelection(false);
SetSelectionOverString(replacestring.c_str());
current_view->buffer()->update(1);
}
+#endif
// jump to next match:
SearchCB( searchForward );
// replaces all occurences of a string (1999-01-15, dnaber@mini.gt.owl.de)
void LyXFindReplace1::SearchReplaceAllCB()
{
- LyXText *ltCur;
+ LyXText * ltCur;
if (!current_view->getScreen())
return;
current_view->getScreen()->HideCursor();
+#ifdef MOVE_TEXT
+ // start at top
+ current_view->text->ClearSelection();
+ current_view->text->CursorTop();
+
+ int replace_count = 0;
+ do {
+ ltCur = current_view->text;
+ if (ltCur->selection) {
+ current_view->update(-2);
+ current_view->getScreen()->ToggleSelection(false);
+ current_view->text->
+ ReplaceSelectionWithString(replacestring.c_str());
+ current_view->text->
+ SetSelectionOverString(replacestring.c_str());
+ current_view->update(1);
+ ++replace_count;
+ }
+ } while( SearchCB(true) );
+#else
// start at top
current_view->buffer()->text->ClearSelection();
current_view->buffer()->text->CursorTop();
replace_count++;
}
} while( SearchCB(true) );
-
+#endif
if( replace_count == 0 ) {
LyXBell();
minibuffer->Set(_("String not found!"));
bool LyXFindReplace1::SearchCB(bool fForward)
{
- LyXText *ltCur;
+ LyXText * ltCur;
bool result;
// store search direction
return(false);
current_view->getScreen()->HideCursor();
+#ifdef MOVE_TEXT
+ current_view->update(-2);
+ ltCur = current_view->text;
+#else
current_view->buffer()->update(-2);
ltCur = current_view->buffer()->text;
+#endif
if (ltCur->selection)
ltCur->cursor = fForward ? ltCur->sel_end_cursor :
ltCur->sel_start_cursor;
if (!ValidSearchData() ||
(fForward ? SearchForward(ltCur) : SearchBackward(ltCur))) {
+#ifdef MOVE_TEXT
+ current_view->update(-2);
+
+ // clear the selection (if there is any)
+ current_view->getScreen()->ToggleSelection();
+ current_view->text->ClearSelection();
+
+ // set the new selection
+ SetSelectionOverLenChars(current_view->text, iLenSelected);
+#else
current_view->buffer()->update(-2);
// clear the selection (if there is any)
// set the new selection
SetSelectionOverLenChars(current_view->buffer()->text, iLenSelected);
+#endif
current_view->getScreen()->ToggleSelection(false);
minibuffer->Set(_("Found."));
result = true;
inline
void LyXFunc::moveCursorUpdate(bool selecting)
{
+#ifdef MOVE_TEXT
+ if (selecting || owner->view()->text->mark_set) {
+ owner->view()->text->SetSelection();
+ owner->view()->getScreen()->ToggleToggle();
+ owner->view()->update(0);
+ } else {
+ owner->view()->update(-2); // this IS necessary
+ // (Matthias)
+ }
+#else
if (selecting || owner->buffer()->text->mark_set) {
owner->buffer()->text->SetSelection();
owner->view()->getScreen()->ToggleToggle();
owner->buffer()->update(-2); // this IS necessary
// (Matthias)
}
+#endif
owner->view()->getScreen()->ShowCursor();
/* ---> Everytime the cursor is moved, show the current font state. */
owner->buffer()->the_locking_inset &&
keysym_return == XK_Escape) {
UnlockInset(owner->buffer()->the_locking_inset);
+#ifdef MOVE_TEXT
+ owner->view()->text->CursorRight();
+#else
owner->buffer()->text->CursorRight();
+#endif
return 0;
}
if (action == 0) action = LFUN_PREFIX;
- if (lyxerr.debugging(Debug::KEY)) {
- char buf[100];
- keyseq.print(buf, 100);
- lyxerr << "Key ["
- << action << "]["
- << buf << "]["
- << num_bytes << "]" << endl;
+ if (lyxerr.debugging(Debug::KEY)) {
+ char buf[100];
+ keyseq.print(buf, 100);
+ lyxerr << "Key ["
+ << action << "]["
+ << buf << "]["
+ << num_bytes << "]" << endl;
+ }
+
+ // already here we know if it any point in going further
+ // why not return already here if action == -1 and
+ // num_bytes == 0? (Lgb)
+
+ if(keyseq.length>1 || keyseq.length<-1){
+ char buf[100];
+ keyseq.print(buf, 100);
+ owner->getMiniBuffer()->Set(buf);
+ }
+
+ if (action == -1) {
+ if (keyseq.length<-1) { // unknown key sequence...
+ char buf[100];
+ LyXBell();
+ keyseq.print(buf, 100);
+ owner->getMiniBuffer()->Set(_("Unknown sequence:"), buf);
+ return 0;
+ }
+
+ char isochar = keyseq.getiso();
+ if (!(keyevent->state&ControlMask) &&
+ !(keyevent->state&Mod1Mask) &&
+ (isochar && keysym_return < 0xF000)) {
+ argument += isochar;
+ }
+ if (argument.empty()) {
+ lyxerr.debug() << "Empty argument!" << endl;
+ // This can`t possibly be of any use
+ // so we`ll skip the dispatch.
+ return 0;
+ }
+ } else
+ if (action == LFUN_SELFINSERT) {
+ argument = s_r[0];
+ }
+
+ bool tmp_sc = show_sc;
+ show_sc = false;
+ Dispatch(action, argument.c_str());
+ show_sc = tmp_sc;
+
+ return 0;
+}
+
+
+LyXFunc::func_status LyXFunc::getStatus(int ac) const
+{
+ kb_action action;
+ func_status flag = LyXFunc::OK;
+ string argument;
+ Buffer * buf = owner->buffer();
+
+ if (lyxaction.isPseudoAction(ac))
+ action = lyxaction.retrieveActionArg(ac, argument);
+ else
+ action = static_cast<kb_action>(ac);
+
+ if (action == LFUN_UNKNOWN_ACTION) {
+ setErrorMessage(N_("Unknown action"));
+ return LyXFunc::Unknown;
+ }
+
+ // Check whether we need a buffer
+ if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
+ // Yes we need a buffer, do we have one?
+ if (buf) {
+ // yes
+ // Can we use a readonly buffer?
+ if (buf->isReadonly() &&
+ !lyxaction.funcHasFlag(action,
+ LyXAction::ReadOnly)) {
+ // no
+ setErrorMessage(N_("Document is read-only"));
+ flag = func_status(flag | LyXFunc::Disabled);
+ }
+ } else {
+ // no
+ setErrorMessage(N_("Command not allowed with"
+ "out any document open"));
+ flag = func_status(flag | LyXFunc::Disabled);
+ }
+ }
+
+ if (flag & LyXFunc::Disabled)
+ return flag;
+
+ static bool noLaTeX = lyxrc->latex_command == "none";
+ bool disable = false;
+ switch (action) {
+ case LFUN_PREVIEW:
+ disable = noLaTeX || lyxrc->view_dvi_command == "none";
+ break;
+ case LFUN_PREVIEWPS:
+ disable = noLaTeX || lyxrc->view_ps_command == "none";
+ break;
+ case LFUN_RUNLATEX:
+ case LFUN_RUNDVIPS:
+ disable = noLaTeX;
+ break;
+ case LFUN_MENUPRINT:
+ disable = noLaTeX || lyxrc->print_command == "none";
+ break;
+ case LFUN_FAX:
+ disable = noLaTeX || lyxrc->fax_command == "none";
+ break;
+ case LFUN_IMPORT:
+ if (argument == "latex")
+ disable = lyxrc->relyx_command == "none";
+ break;
+ case LFUN_EXPORT:
+ if (argument == "dvi" || argument == "postscript")
+ disable = noLaTeX;
+ if (argument == "html")
+ disable = lyxrc->html_command == "none";
+ break;
+ case LFUN_UNDO:
+ disable = buf->undostack.empty();
+ break;
+ case LFUN_REDO:
+ disable = buf->redostack.empty();
+ break;
+ case LFUN_SPELLCHECK:
+ disable = lyxrc->isp_command == "none";
+ break;
+ case LFUN_RUNCHKTEX:
+ disable = lyxrc->chktex_command == "none";
+ break;
+ case LFUN_LAYOUT_TABLE:
+#ifdef MOVE_TEXT
+ disable = ! owner->view()->text->cursor.par->table;
+#else
+ disable = ! buf->text->cursor.par->table;
+#endif
+ break;
+ default:
+ break;
+ }
+ if (disable)
+ flag |= LyXFunc::Disabled;
+
+ if (buf) {
+ func_status box = LyXFunc::ToggleOff;
+#ifdef MOVE_TEXT
+ LyXFont font = owner->view()->text->real_current_font;
+#else
+ LyXFont font = buf->text->real_current_font;
+#endif
+ switch (action) {
+ case LFUN_EMPH:
+ if (font.emph() == LyXFont::ON)
+ box = LyXFunc::ToggleOn;
+ break;
+ case LFUN_NOUN:
+ if (font.noun() == LyXFont::ON)
+ box = LyXFunc::ToggleOn;
+ break;
+ case LFUN_BOLD:
+ if (font.series() == LyXFont::BOLD_SERIES)
+ box = LyXFunc::ToggleOn;
+ break;
+ case LFUN_TEX:
+ if (font.latex() == LyXFont::ON)
+ box = LyXFunc::ToggleOn;
+ break;
+ default:
+ box = LyXFunc::OK;
+ break;
+ }
+ flag |= box;
+ }
+
+
+ return flag;
+}
+
+
+string LyXFunc::Dispatch(string const & s)
+{
+ // Split command string into command and argument
+ string cmd, line = frontStrip(s);
+ string arg = strip(frontStrip(split(line, cmd, ' ')));
+
+ return Dispatch(lyxaction.LookupFunc(cmd.c_str()), arg.c_str());
+}
+
+
+#ifdef MOVE_TEXT
+string LyXFunc::Dispatch(int ac,
+ char const * do_not_use_this_arg)
+{
+ string argument;
+ kb_action action;
+
+ FL_OBJECT * ob = 0; // This will disapear soon
+
+ // we have not done anything wrong yet.
+ errorstat = false;
+ dispatch_buffer.clear();
+
+ // if action is a pseudo-action, we need the real action
+ if (lyxaction.isPseudoAction(ac)) {
+ string tmparg;
+ action = static_cast<kb_action>
+ (lyxaction.retrieveActionArg(ac, tmparg));
+ if (!tmparg.empty())
+ argument = tmparg;
+ } else {
+ action = static_cast<kb_action>(ac);
+ if (do_not_use_this_arg)
+ argument = do_not_use_this_arg; // except here
+ }
+
+ selection_possible = false;
+
+ if (owner->view()->available()
+ && owner->view()->getScreen())
+ owner->view()->getScreen()->HideCursor();
+
+ // We cannot use this function here
+ if (getStatus(action) & Disabled)
+ goto exit_with_message;
+
+ commandshortcut.clear();
+
+ if (lyxrc->display_shortcuts && show_sc) {
+ if (action != LFUN_SELFINSERT) {
+ // Put name of command and list of shortcuts
+ // for it in minibuffer
+ string comname = lyxaction.getActionName(action);
+
+ int pseudoaction = action;
+ bool argsadded = false;
+
+ if (!argument.empty()) {
+ // If we have the command with argument,
+ // this is better
+ pseudoaction =
+ lyxaction.searchActionArg(action,
+ argument.c_str());
+
+ if (pseudoaction == -1) {
+ pseudoaction = action;
+ } else {
+ comname += " " + argument;
+ argsadded = true;
+ }
+ }
+
+ string shortcuts = toplevel_keymap->findbinding(pseudoaction);
+
+ if (!shortcuts.empty()) {
+ comname += ": " + shortcuts;
+ } else if (!argsadded) {
+ comname += " " + argument;
+ }
+
+ if (!comname.empty()) {
+ comname = strip(comname);
+ commandshortcut = "(" + comname + ')';
+ owner->getMiniBuffer()->Set(commandshortcut);
+ // Here we could even add a small pause,
+ // to annoy the user and make him learn
+ // the shortcuts.
+ // No! That will just annoy, not teach
+ // anything. The user will read the messages
+ // if they are interested. (Asger)
+ }
+ }
+ }
+
+ // If in math mode pass the control to
+ // the math inset [asierra060396]
+ if (owner->view()->available() &&
+ owner->buffer()->the_locking_inset) {
+ if (action > 1
+ || (action == LFUN_UNKNOWN_ACTION && keyseq.length>= -1)) {
+ if (action == LFUN_UNKNOWN_ACTION && argument.empty()) {
+ argument = keyseq.getiso();
+ }
+ // Undo/Redo pre 0.13 is a bit tricky for insets.
+ if (action == LFUN_UNDO) {
+ int slx, sly;
+ UpdatableInset * inset =
+ owner->buffer()->the_locking_inset;
+ inset->GetCursorPos(slx, sly);
+ UnlockInset(inset);
+ MenuUndo();
+ inset = static_cast<UpdatableInset*>(owner->view()->text->cursor.par->GetInset(owner->view()->text->cursor.pos));
+ if (inset)
+ inset->Edit(slx, sly);
+ return string();
+ } else
+ if (action == LFUN_REDO) {
+ int slx, sly;
+ UpdatableInset * inset = owner->buffer()->the_locking_inset;
+ inset->GetCursorPos(slx, sly);
+ UnlockInset(inset);
+ MenuRedo();
+ inset = static_cast<UpdatableInset*>(owner->view()->text->cursor.par->GetInset(owner->view()->text->cursor.pos));
+ if (inset)
+ inset->Edit(slx, sly);
+ return string();
+ } else
+ if (owner->buffer()->the_locking_inset->LocalDispatch(action, argument.c_str()))
+ return string();
+ else {
+ setMessage(N_("Text mode"));
+ if (action == LFUN_RIGHT || action == -1)
+ owner->view()->text->CursorRight();
+ if (action == LFUN_LEFT || action == LFUN_RIGHT)
+ return string();
+ }
+ }
+ }
+
+ switch(action) {
+ // --- Misc -------------------------------------------
+ case LFUN_WORDFINDFORWARD :
+ case LFUN_WORDFINDBACKWARD : {
+ static string last_search;
+ string searched_string;
+
+ if (!argument.empty()) {
+ last_search = argument;
+ searched_string = argument;
+ } else {
+ searched_string = last_search;
+ }
+
+ LyXText * ltCur = owner->view()->text ;
+
+ if (!searched_string.empty() &&
+ ((action == LFUN_WORDFINDBACKWARD) ?
+ ltCur->SearchBackward(searched_string.c_str()) :
+ ltCur->SearchForward(searched_string.c_str()))) {
+
+ // ??? What is that ???
+ owner->view()->update(-2);
+
+ // ??? Needed ???
+ // clear the selection (if there is any)
+ owner->view()->getScreen()->ToggleSelection();
+ owner->view()->text->ClearSelection();
+
+ // Move cursor so that successive C-s 's will not stand in place.
+ if( action == LFUN_WORDFINDFORWARD )
+ owner->view()->text->CursorRightOneWord();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(false);
+
+ // ??? Needed ???
+ // set the new selection
+ // SetSelectionOverLenChars(owner->view()->currentBuffer()->text, iLenSelected);
+ owner->view()->getScreen()->ToggleSelection(false);
+ } else
+ LyXBell();
+
+ // REMOVED : if (owner->view()->getWorkArea()->focus)
+ owner->view()->getScreen()->ShowCursor();
+ }
+ break;
+
+ case LFUN_PREFIX:
+ {
+ if (owner->view()->available()
+ && owner->view()->getScreen()) {
+ owner->view()->update(-2);
+ }
+ char buf[100];
+ keyseq.print(buf, 100, true);
+ owner->getMiniBuffer()->Set(buf, string(), string(), 1);
+ }
+ break;
+
+ // --- Misc -------------------------------------------
+ case LFUN_EXEC_COMMAND:
+ owner->getMiniBuffer()->ExecCommand();
+ break;
+
+ case LFUN_CANCEL: // RVDK_PATCH_5
+ keyseq.reset();
+ meta_fake_bit = 0;
+ if(owner->view()->available())
+ // cancel any selection
+ Dispatch(LFUN_MARK_OFF, 0);
+ setMessage(N_("Cancel"));
+ break;
+
+ case LFUN_META_FAKE: // RVDK_PATCH_5
+ {
+ meta_fake_bit = Mod1Mask;
+ char buf[100];
+ keyseq.print(buf, 98, true);
+ string res = string("M-") + buf;
+ setMessage(buf); // RVDK_PATCH_5
+ }
+ break;
+
+ case LFUN_READ_ONLY_TOGGLE:
+ if (owner->buffer()->lyxvc.inUse()) {
+ owner->buffer()->lyxvc.toggleReadOnly();
+ } else {
+ owner->buffer()->setReadonly(
+ !owner->buffer()->isReadonly());
+ }
+ break;
+
+ case LFUN_CENTER: // this is center and redraw.
+ BeforeChange();
+ if (owner->view()->text->cursor.y >
+ owner->view()->getWorkArea()->h / 2) {
+ owner->view()->getScreen()->
+ Draw(owner->view()->text->cursor.y -
+ owner->view()->getWorkArea()->h/2);
+ } else { // <=
+ owner->view()->getScreen()->
+ Draw(0);
+ }
+ owner->view()->update(0);
+ owner->view()->redraw();
+ break;
+
+ case LFUN_APPENDIX:
+ if (owner->view()->available()) {
+ owner->view()->text->toggleAppendix();
+ owner->view()->update(1);
+ }
+ break;
+
+ // --- Menus -----------------------------------------------
+ case LFUN_MENUNEW:
+ MenuNew(false);
+ break;
+
+ case LFUN_MENUNEWTMPLT:
+ MenuNew(true);
+ break;
+
+ case LFUN_MENUOPEN:
+ MenuOpen();
+ break;
+
+ case LFUN_CLOSEBUFFER:
+ CloseBuffer();
+ break;
+
+ case LFUN_MENUWRITE:
+ MenuWrite(owner->buffer());
+ break;
+
+ case LFUN_MENUWRITEAS:
+ MenuWriteAs(owner->buffer());
+ break;
+
+ case LFUN_MENURELOAD:
+ reloadBuffer();
+ break;
+
+ case LFUN_PREVIEW:
+ MenuPreview(owner->buffer());
+ break;
+
+ case LFUN_PREVIEWPS:
+ MenuPreviewPS(owner->buffer());
+ break;
+
+ case LFUN_RUNLATEX:
+ MenuRunLaTeX(owner->buffer());
+ break;
+
+ case LFUN_BUILDPROG:
+ MenuBuildProg(owner->buffer());
+ break;
+
+ case LFUN_RUNCHKTEX:
+ MenuRunChktex(owner->buffer());
+ break;
+
+ case LFUN_RUNDVIPS:
+ MenuRunDvips(owner->buffer(), false);
+ break;
+
+ case LFUN_MENUPRINT:
+ MenuPrint(owner->buffer());
+ break;
+
+ case LFUN_FAX:
+ MenuFax(owner->buffer());
+ break;
+
+ case LFUN_EXPORT:
+ {
+ //needs argument as string
+ string extyp = argument;
+
+ // latex
+ if (extyp == "latex") {
+ // make sure that this buffer is not linuxdoc
+ MenuMakeLaTeX(owner->buffer());
+ }
+ // linuxdoc
+ else if (extyp == "linuxdoc") {
+ // make sure that this buffer is not latex
+ MenuMakeLinuxDoc(owner->buffer());
+ }
+ // docbook
+ else if (extyp == "docbook") {
+ // make sure that this buffer is not latex or linuxdoc
+ MenuMakeDocBook(owner->buffer());
+ }
+ // dvi
+ else if (extyp == "dvi") {
+ // Run LaTeX as "Update dvi..." Bernhard.
+ // We want the dvi in the current directory. This
+ // is achieved by temporarily disabling use of
+ // temp directory. As a side-effect, we get
+ // *.log and *.aux files also. (Asger)
+ bool flag = lyxrc->use_tempdir;
+ lyxrc->use_tempdir = false;
+ MenuRunLaTeX(owner->buffer());
+ lyxrc->use_tempdir = flag;
+ }
+ // postscript
+ else if (extyp == "postscript") {
+ // Start Print-dialog. Not as good as dvi... Bernhard.
+ MenuPrint(owner->buffer());
+ // Since the MenuPrint is a pop-up, we can't use
+ // the same trick as above. (Asger)
+ // MISSING: Move of ps-file :-(
+ }
+ // ascii
+ else if (extyp == "ascii") {
+ MenuMakeAscii(owner->buffer());
+ }
+ else if (extyp == "custom") {
+ MenuSendto();
+ break;
+ }
+ // HTML
+ else if (extyp == "html" && lyxrc->html_command != "none") {
+ // First, create LaTeX file
+ MenuMakeLaTeX(owner->buffer());
+
+ // And now, run the converter
+ string file = owner->buffer()->fileName();
+ Path path(OnlyPath(file));
+ // the tex file name has to be correct for
+ // latex, but the html file name can be
+ // anything.
+ string result = ChangeExtension(file, ".html", false);
+ string infile = owner->buffer()->getLatexName();
+ string tmp = lyxrc->html_command;
+ tmp = subst(tmp, "$$FName", infile);
+ tmp = subst(tmp, "$$OutName", result);
+ Systemcalls one;
+ int res = one.startscript(Systemcalls::System, tmp);
+ if (res == 0) {
+ setMessage(N_("Document exported as HTML to file `")
+ + MakeDisplayPath(result) +'\'');
+ } else {
+ setErrorMessage(N_("Unable to convert to HTML the file `")
+ + MakeDisplayPath(infile)
+ + '\'');
+ }
+ }
+ else {
+ setErrorMessage(N_("Unknown export type: ")
+ + extyp);
+ }
+ }
+ break;
+
+ case LFUN_IMPORT:
+ {
+ //needs argument as string
+ string imtyp = argument;
+
+ // latex
+ if (imtyp == "latex") {
+ doImportLaTeX(false);
+ }
+ // ascii
+ else if (imtyp == "ascii") {
+ doImportASCII(false);
+ } else if (imtyp == "asciiparagraph") {
+ doImportASCII(true);
+ // noweb
+ } else if (imtyp == "noweb") {
+ doImportLaTeX(true);
+ } else {
+ setErrorMessage(string(N_("Unknown import type: "))
+ + imtyp);
+ }
+ break;
+ }
+
+ case LFUN_QUIT:
+ QuitLyX();
+ break;
+
+ case LFUN_TOCVIEW:
+ TocUpdateCB(ob, 0);
+ if (fd_form_toc->form_toc->visible) {
+ fl_raise_form(fd_form_toc->form_toc);
+ } else {
+ static int ow = -1, oh;
+ fl_show_form(fd_form_toc->form_toc,
+ FL_PLACE_MOUSE |
+ FL_FREE_SIZE, FL_FULLBORDER,
+ _("Table of Contents"));
+ if (ow < 0) {
+ ow = fd_form_toc->form_toc->w;
+ oh = fd_form_toc->form_toc->h;
+ }
+ fl_set_form_minsize(fd_form_toc->form_toc, ow, oh);
+ }
+ break;
+
+ case LFUN_TOC_INSERT:
+ {
+ Inset * new_inset = new InsetTOC(owner->buffer());
+ owner->buffer()->insertInset(new_inset, "Standard", true);
+ break;
+ }
+
+ case LFUN_LOF_INSERT:
+ {
+ Inset * new_inset = new InsetLOF(owner->buffer());
+ owner->buffer()->insertInset(new_inset, "Standard", true);
+ break;
+ }
+
+ case LFUN_LOA_INSERT:
+ {
+ Inset * new_inset = new InsetLOA(owner->buffer());
+ owner->buffer()->insertInset(new_inset, "Standard", true);
+ break;
+ }
+
+ case LFUN_LOT_INSERT:
+ {
+ Inset * new_inset = new InsetLOT(owner->buffer());
+ owner->buffer()->insertInset(new_inset, "Standard", true);
+ break;
+ }
+
+ case LFUN_TABLE:
+ TableCB(ob, 0);
+ break;
+
+ case LFUN_FIGURE:
+ FigureCB(ob, 0);
+ break;
+
+ case LFUN_AUTOSAVE:
+ AutoSave();
+ break;
+
+ case LFUN_UNDO:
+ MenuUndo();
+ break;
+
+ case LFUN_REDO:
+ MenuRedo();
+ break;
+
+ case LFUN_MENUSEARCH:
+ MenuSearch();
+ break;
+
+ case LFUN_PASTE:
+ PasteCB();
+ break;
+
+ case LFUN_PASTESELECTION:
+ {
+ bool asPara = false;
+ if (argument == "paragraph") asPara = true;
+ MenuPasteSelection(asPara);
+ break;
+ }
+
+ case LFUN_CUT:
+ CutCB();
+ break;
+
+ case LFUN_COPY:
+ CopyCB();
+ break;
+
+ case LFUN_LAYOUT_COPY:
+ CopyEnvironmentCB();
+ break;
+
+ case LFUN_LAYOUT_PASTE:
+ PasteEnvironmentCB();
+ break;
+
+ case LFUN_GOTOERROR:
+ owner->view()->gotoError();
+ break;
+
+ case LFUN_REMOVEERRORS:
+ if (owner->buffer()->removeAutoInsets()) {
+ owner->view()->redraw();
+ owner->view()->fitCursor();
+ owner->view()->updateScrollbar();
+ }
+ break;
+
+ case LFUN_GOTONOTE:
+ GotoNote();
+ break;
+
+ case LFUN_OPENSTUFF:
+ OpenStuff();
+ break;
+
+ case LFUN_HYPHENATION:
+ HyphenationPoint();
+ break;
+
+ case LFUN_LDOTS:
+ Ldots();
+ break;
+
+ case LFUN_END_OF_SENTENCE:
+ EndOfSentenceDot();
+ break;
+
+ case LFUN_MENU_SEPARATOR:
+ MenuSeparator();
+ break;
+
+ case LFUN_HFILL:
+ HFill();
+ break;
+
+ case LFUN_DEPTH:
+ DepthCB(ob, 0);
+ break;
+
+ case LFUN_DEPTH_MIN:
+ DepthCB(ob, -1);
+ break;
+
+ case LFUN_DEPTH_PLUS:
+ DepthCB(ob, 1);
+ break;
+
+ case LFUN_FREE:
+ FreeCB();
+ break;
+
+ case LFUN_TEX:
+ TexCB();
+ break;
+
+ case LFUN_MELT:
+ MeltCB(ob, 0);
+ break;
+
+ case LFUN_RECONFIGURE:
+ Reconfigure();
+ break;
+
+ case LFUN_FOOTMELT:
+ if (owner->view()->available()
+ && !owner->view()->text->selection
+ && owner->view()->text->cursor.par->footnoteflag
+ != LyXParagraph::NO_FOOTNOTE)
+ { // only melt footnotes with FOOTMELT, not margins etc
+ if(owner->view()->text->cursor.par->footnotekind == LyXParagraph::FOOTNOTE)
+ MeltCB(ob, 0);
+ }
+ else
+ FootCB(ob, 0);
+ break;
+
+ case LFUN_MARGINMELT:
+ if (owner->view()->available()
+ && !owner->view()->text->selection
+ && owner->view()->text->cursor.par->footnoteflag
+ != LyXParagraph::NO_FOOTNOTE) {
+ // only melt margins
+ if(owner->view()->text->cursor.par->footnotekind == LyXParagraph::MARGIN)
+ MeltCB(ob, 0);
+ }
+ else
+ MarginCB(ob, 0);
+ break;
+
+ // --- version control -------------------------------
+ case LFUN_VC_REGISTER:
+ {
+ if (!owner->buffer()->lyxvc.inUse())
+ owner->buffer()->lyxvc.registrer();
+ }
+ break;
+
+ case LFUN_VC_CHECKIN:
+ {
+ if (owner->buffer()->lyxvc.inUse()
+ && !owner->buffer()->isReadonly())
+ owner->buffer()->lyxvc.checkIn();
+ }
+ break;
+
+ case LFUN_VC_CHECKOUT:
+ {
+ if (owner->buffer()->lyxvc.inUse()
+ && owner->buffer()->isReadonly())
+ owner->buffer()->lyxvc.checkOut();
+ }
+ break;
+
+ case LFUN_VC_REVERT:
+ {
+ owner->buffer()->lyxvc.revert();
+ }
+ break;
+
+ case LFUN_VC_UNDO:
+ {
+ owner->buffer()->lyxvc.undoLast();
+ }
+ break;
+
+ case LFUN_VC_HISTORY:
+ {
+ owner->buffer()->lyxvc.showLog();
+ break;
+ }
+
+ // --- buffers ----------------------------------------
+ case LFUN_PREVBUFFER:
+#ifdef WITH_WARNINGS
+#warning fix this please
+#endif
+ // it is the LyXView or the BufferView that should
+ // remember the previous buffer, not bufferlist.
+// if (owner->view()->available()){
+// BeforeChange();
+// owner->buffer()->update(-2);
+// }
+// owner->view()->setBuffer(bufferlist.prev());
+
+// owner->view()->
+// resizeCurrentBufferPseudoExpose();
+ break;
+
+ case LFUN_FILE_INSERT:
+ {
+ MenuInsertLyXFile(argument);
+ }
+ break;
+
+ case LFUN_FILE_INSERT_ASCII:
+ {
+ bool asPara = (argument == "paragraph");
+ InsertAsciiFile(string(), asPara);
+ }
+ break;
+
+ case LFUN_FILE_NEW:
+ {
+ // servercmd: argument must be <file>:<template>
+ Buffer * tmpbuf = NewLyxFile(argument);
+ if (tmpbuf)
+ owner->view()->buffer(tmpbuf);
+ }
+ break;
+
+ case LFUN_FILE_OPEN:
+ owner->view()->buffer(
+ bufferlist.loadLyXFile(argument));
+ break;
+
+ case LFUN_LATEX_LOG:
+ ShowLatexLog();
+ break;
+
+ case LFUN_LAYOUTNO:
+ {
+ lyxerr.debug() << "LFUN_LAYOUTNO: (arg) " << argument << endl;
+ int sel = strToInt(argument);
+ lyxerr.debug() << "LFUN_LAYOUTNO: (sel) "<< sel << endl;
+
+ // Should this give a setMessage instead?
+ if (sel == 0)
+ return string(); // illegal argument
+
+ sel--; // sel 1..., but layout 0...
+
+ // Pretend we got the name instead.
+ Dispatch(int(LFUN_LAYOUT),
+ textclasslist.NameOfLayout(owner->view()->
+ text->parameters->
+ textclass,
+ sel).c_str());
+ return string();
+ }
+
+ case LFUN_LAYOUT:
+ {
+ lyxerr.debug() << "LFUN_LAYOUT: (arg) "
+ << argument << endl;
+
+ // Derive layout number from given argument (string)
+ // and current buffer's textclass (number). */
+ int layoutno =
+ textclasslist.NumberOfLayout(owner->
+ view()->
+ text->parameters->
+ textclass,
+ argument).second;
+
+ // see if we found the layout number:
+ if (layoutno == -1) {
+ setErrorMessage(string(N_("Layout ")) + argument +
+ N_(" not known"));
+ break;
+ }
+
+ if (current_layout != layoutno) {
+ owner->view()->getScreen()->HideCursor();
+ current_layout = layoutno;
+ owner->view()->update(-2);
+ owner->view()->text->
+ SetLayout(layoutno);
+ owner->getToolbar()->combox->
+ select(owner->view()->
+ text->cursor.par->
+ GetLayout() + 1);
+ owner->view()->update(1);
+ }
+ }
+ break;
+
+ case LFUN_LAYOUT_DOCUMENT:
+ MenuLayoutDocument();
+ break;
+
+ case LFUN_LAYOUT_PARAGRAPH:
+ MenuLayoutParagraph();
+ break;
+
+ case LFUN_LAYOUT_CHARACTER:
+ MenuLayoutCharacter();
+ break;
+
+ case LFUN_LAYOUT_TABLE:
+ {
+ int flag = 0;
+ if (argument == "true") flag = 1;
+ MenuLayoutTable(flag);
+ }
+ break;
+
+ case LFUN_LAYOUT_PAPER:
+ MenuLayoutPaper();
+ break;
+
+ case LFUN_LAYOUT_QUOTES:
+ MenuLayoutQuotes();
+ break;
+
+ case LFUN_LAYOUT_PREAMBLE:
+ MenuLayoutPreamble();
+ break;
+
+ case LFUN_LAYOUT_SAVE_DEFAULT:
+ MenuLayoutSave();
+ break;
+
+ case LFUN_DROP_LAYOUTS_CHOICE:
+ owner->getToolbar()->combox->Show();
+ break;
+
+ case LFUN_EMPH:
+ EmphCB();
+ break;
+
+ case LFUN_BOLD:
+ BoldCB();
+ break;
+
+ case LFUN_NOUN:
+ NounCB();
+ break;
+
+ case LFUN_CODE:
+ CodeCB();
+ break;
+
+ case LFUN_SANS:
+ SansCB();
+ break;
+
+ case LFUN_ROMAN:
+ RomanCB();
+ break;
+
+ case LFUN_DEFAULT:
+ StyleResetCB();
+ break;
+
+ case LFUN_UNDERLINE:
+ UnderlineCB();
+ break;
+
+ case LFUN_FONT_SIZE:
+ FontSizeCB(argument);
+ break;
+
+ case LFUN_FONT_STATE:
+ setMessage(CurrentState());
+ break;
+
+ case LFUN_UPCASE_WORD:
+ owner->view()->update(-2);
+ FreeUpdateTimer();
+ owner->view()->text->ChangeWordCase(LyXText::text_uppercase);
+ owner->view()->update(1);
+ SetUpdateTimer();
+ break;
+
+ case LFUN_LOWCASE_WORD:
+ owner->view()->update(-2);
+ FreeUpdateTimer();
+ owner->view()->text->ChangeWordCase(LyXText::text_lowercase);
+ owner->view()->update(1);
+ SetUpdateTimer();
+ break;
+
+ case LFUN_CAPITALIZE_WORD:
+ owner->view()->update(-2);
+ FreeUpdateTimer();
+ owner->view()->text->ChangeWordCase(LyXText::text_capitalization);
+ owner->view()->update(1);
+ SetUpdateTimer();
+ break;
+
+ case LFUN_INSERT_LABEL:
+ MenuInsertLabel(argument.c_str());
+ break;
+
+ case LFUN_INSERT_REF:
+ MenuInsertRef();
+ break;
+
+ case LFUN_REFTOGGLE:
+ {
+ InsetRef * inset =
+ static_cast<InsetRef*>(getInsetByCode(Inset::REF_CODE));
+ if (inset) {
+ if (inset->getFlag() == InsetRef::REF)
+ inset->setFlag(InsetRef::PAGE_REF);
+ else
+ inset->setFlag(InsetRef::REF);
+ UpdateInset(inset);
+ } else {
+ setErrorMessage(N_("No cross-reference to toggle"));
+ }
+ }
+ break;
+
+ case LFUN_REFBACK:
+ {
+ owner->view()->restorePosition();
+ }
+ break;
+
+ case LFUN_REFGOTO:
+ {
+ string label(argument);
+ if (label.empty()) {
+ InsetRef * inset =
+ static_cast<InsetRef*>(getInsetByCode(Inset::REF_CODE));
+ if (inset)
+ label = inset->getContents();
+ }
+
+ if (!label.empty()) {
+ owner->view()->savePosition();
+ owner->buffer()->gotoLabel(label.c_str());
+ }
+ }
+ break;
+
+ case LFUN_MENU_OPEN_BY_NAME:
+ owner->getMenus()->openByName(argument);
+ break; // RVDK_PATCH_5
+
+ case LFUN_SPELLCHECK:
+ if (lyxrc->isp_command != "none")
+ ShowSpellChecker();
+ break; // RVDK_PATCH_5
+
+ // --- Cursor Movements -----------------------------
+ case LFUN_RIGHT:
+ {
+ LyXText * tmptext = owner->view()->text;
+ if(!tmptext->mark_set)
+ BeforeChange();
+ owner->view()->update(-2);
+ if (tmptext->cursor.pos < tmptext->cursor.par->Last()
+ && tmptext->cursor.par->GetChar(tmptext->cursor.pos)
+ == LyXParagraph::META_INSET
+ && tmptext->cursor.par->GetInset(tmptext->cursor.pos)
+ && tmptext->cursor.par->GetInset(tmptext->cursor.pos)->Editable() == 2){
+ Inset * tmpinset = tmptext->cursor.par->GetInset(tmptext->cursor.pos);
+ setMessage(tmpinset->EditMessage());
+ tmpinset->Edit(0, 0);
+ break;
+ }
+ tmptext->CursorRight();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(false);
+ owner->getMiniBuffer()->Set(CurrentState());
+ }
+ break;
+
+ case LFUN_LEFT:
+ {
+ // This is soooo ugly. Isn`t it possible to make
+ // it simpler? (Lgb)
+ LyXText * txt = owner->view()->text;
+ if(!txt->mark_set) BeforeChange();
+ owner->view()->update(-2);
+ txt->CursorLeft();
+ if (txt->cursor.pos < txt->cursor.par->Last()
+ && txt->cursor.par->GetChar(txt->cursor.pos)
+ == LyXParagraph::META_INSET
+ && txt->cursor.par->GetInset(txt->cursor.pos)
+ && txt->cursor.par->GetInset(txt->cursor.pos)->Editable() == 2) {
+ Inset * tmpinset = txt->cursor.par->GetInset(txt->cursor.pos);
+ setMessage(tmpinset->EditMessage());
+ tmpinset->Edit(tmpinset->Width(txt->GetFont(txt->cursor.par,
+ txt->cursor.pos)), 0);
+ break;
+ }
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(false);
+ owner->getMiniBuffer()->Set(CurrentState());
+ }
+ break;
+
+ case LFUN_UP:
+ if(!owner->view()->text->mark_set) BeforeChange();
+ owner->view()->update(-3);
+ owner->view()->text->CursorUp();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(false);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_DOWN:
+ if(!owner->view()->text->mark_set)
+ BeforeChange();
+ owner->view()->update(-3);
+ owner->view()->text->CursorDown();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(false);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_UP_PARAGRAPH:
+ if(!owner->view()->text->mark_set)
+ BeforeChange();
+ owner->view()->update(-3);
+ owner->view()->text->CursorUpParagraph();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(false);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_DOWN_PARAGRAPH:
+ if(!owner->view()->text->mark_set)
+ BeforeChange();
+ owner->view()->update(-3);
+ owner->view()->text->CursorDownParagraph();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(false);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_PRIOR:
+ if(!owner->view()->text->mark_set)
+ BeforeChange();
+ owner->view()->update(-3);
+ owner->view()->cursorPrevious();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(false);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_NEXT:
+ if(!owner->view()->text->mark_set)
+ BeforeChange();
+ owner->view()->update(-3);
+ owner->view()->cursorNext();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(false);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_HOME:
+ if(!owner->view()->text->mark_set)
+ BeforeChange();
+ owner->view()->update(-2);
+ owner->view()->text->CursorHome();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(false);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_END:
+ if(!owner->view()->text->mark_set)
+ BeforeChange();
+ owner->view()->update(-2);
+ owner->view()->text->CursorEnd();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(false);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_TAB:
+ if(!owner->view()->text->mark_set)
+ BeforeChange();
+ owner->view()->update(-2);
+ owner->view()->text->CursorTab();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(false);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_WORDRIGHT:
+ if(!owner->view()->text->mark_set)
+ BeforeChange();
+ owner->view()->update(-2);
+ owner->view()->text->CursorRightOneWord();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(false);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_WORDLEFT:
+ if(!owner->view()->text->mark_set)
+ BeforeChange();
+ owner->view()->update(-2);
+ owner->view()->text->CursorLeftOneWord();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(false);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_BEGINNINGBUF:
+ if(!owner->view()->text->mark_set)
+ BeforeChange();
+ owner->view()->update(-2);
+ owner->view()->text->CursorTop();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(false);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_ENDBUF:
+ if(!owner->view()->text->mark_set)
+ BeforeChange();
+ owner->view()->update(-2);
+ owner->view()->text->CursorBottom();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(false);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+
+ /* cursor selection ---------------------------- */
+ case LFUN_RIGHTSEL:
+ owner->view()->update(-2);
+ owner->view()->text->CursorRight();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(true);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_LEFTSEL:
+ owner->view()->update(-2);
+ owner->view()->text->CursorLeft();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(true);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_UPSEL:
+ owner->view()->update(-2);
+ owner->view()->text->CursorUp();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(true);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_DOWNSEL:
+ owner->view()->update(-2);
+ owner->view()->text->CursorDown();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(true);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_UP_PARAGRAPHSEL:
+ owner->view()->update(-2);
+ owner->view()->text->CursorUpParagraph();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(true);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_DOWN_PARAGRAPHSEL:
+ owner->view()->update(-2);
+ owner->view()->text->CursorDownParagraph();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(true);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_PRIORSEL:
+ owner->view()->update(-2);
+ owner->view()->cursorPrevious();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(true);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_NEXTSEL:
+ owner->view()->update(-2);
+ owner->view()->cursorNext();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(true);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_HOMESEL:
+ owner->view()->update(-2);
+ owner->view()->text->CursorHome();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(true);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_ENDSEL:
+ owner->view()->update(-2);
+ owner->view()->text->CursorEnd();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(true);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_WORDRIGHTSEL:
+ owner->view()->update(-2);
+ owner->view()->text->CursorRightOneWord();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(true);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_WORDLEFTSEL:
+ owner->view()->update(-2);
+ owner->view()->text->CursorLeftOneWord();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(true);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_BEGINNINGBUFSEL:
+ owner->view()->update(-2);
+ owner->view()->text->CursorTop();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(true);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ case LFUN_ENDBUFSEL:
+ owner->view()->update(-2);
+ owner->view()->text->CursorBottom();
+ owner->view()->text->FinishUndo();
+ moveCursorUpdate(true);
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+
+ // --- text changing commands ------------------------
+ case LFUN_BREAKLINE:
+ BeforeChange();
+ owner->view()->text->InsertChar(LyXParagraph::META_NEWLINE);
+ SmallUpdate(1);
+ SetUpdateTimer(0.01);
+ moveCursorUpdate(false);
+ break;
+
+ case LFUN_PROTECTEDSPACE:
+ BeforeChange();
+ owner->view()->text->
+ InsertChar(LyXParagraph::META_PROTECTED_SEPARATOR);
+ SmallUpdate(1);
+ SetUpdateTimer();
+ moveCursorUpdate(false);
+ break;
+
+ case LFUN_SETMARK:
+ if(owner->view()->text->mark_set) {
+ BeforeChange();
+ owner->view()->update(0);
+ setMessage(N_("Mark removed"));
+ } else {
+ BeforeChange();
+ owner->view()->text->mark_set = 1;
+ owner->view()->update(0);
+ setMessage(N_("Mark set"));
+ }
+ owner->view()->text->sel_cursor =
+ owner->view()->text->cursor;
+ break;
+
+ case LFUN_DELETE:
+ FreeUpdateTimer();
+ if (!owner->view()->text->selection) {
+ owner->view()->text->Delete();
+ owner->view()->text->sel_cursor =
+ owner->view()->text->cursor;
+ SmallUpdate(1);
+ // It is possible to make it a lot faster still
+ // just comment out the lone below...
+ owner->view()->getScreen()->ShowCursor();
+ } else {
+ CutCB();
+ }
+ SetUpdateTimer();
+ break;
+
+ case LFUN_DELETE_SKIP:
+ {
+ // Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
+
+ LyXCursor cursor = owner->view()->text->cursor;
+
+ FreeUpdateTimer();
+ if (!owner->view()->text->selection) {
+ if (cursor.pos == cursor.par->Last()) {
+ owner->view()->text->CursorRight();
+ cursor = owner->view()->text->cursor;
+ if (cursor.pos == 0
+ && !(cursor.par->added_space_top
+ == VSpace (VSpace::NONE))) {
+ owner->view()->text->SetParagraph
+ (cursor.par->line_top,
+ cursor.par->line_bottom,
+ cursor.par->pagebreak_top,
+ cursor.par->pagebreak_bottom,
+ VSpace(VSpace::NONE),
+ cursor.par->added_space_bottom,
+ cursor.par->align,
+ cursor.par->labelwidthstring, 0);
+ owner->view()->text->CursorLeft();
+ owner->view()->update (1);
+ } else {
+ owner->view()->text->CursorLeft();
+ owner->view()->text->Delete();
+ owner->view()->text->sel_cursor =
+ owner->view()->text->cursor;
+ SmallUpdate(1);
+ }
+ } else {
+ owner->view()->text->Delete();
+ owner->view()->text->sel_cursor =
+ owner->view()->text->cursor;
+ SmallUpdate(1);
+ }
+ } else {
+ CutCB();
+ }
+ SetUpdateTimer();
+ }
+ break;
+
+ /* -------> Delete word forward. */
+ case LFUN_DELETE_WORD_FORWARD:
+ owner->view()->update(-2);
+ FreeUpdateTimer();
+ owner->view()->text->DeleteWordForward();
+ owner->view()->update( 1 );
+ SetUpdateTimer();
+ moveCursorUpdate(false);
+ break;
+
+ /* -------> Delete word backward. */
+ case LFUN_DELETE_WORD_BACKWARD:
+ owner->view()->update(-2);
+ FreeUpdateTimer();
+ owner->view()->text->DeleteWordBackward();
+ owner->view()->update( 1 );
+ SetUpdateTimer();
+ moveCursorUpdate(false);
+ break;
+
+ /* -------> Kill to end of line. */
+ case LFUN_DELETE_LINE_FORWARD:
+ FreeUpdateTimer();
+ owner->view()->update(-2);
+ owner->view()->text->DeleteLineForward();
+ owner->view()->update( 1 );
+ SetUpdateTimer();
+ moveCursorUpdate(false);
+ break;
+
+ /* -------> Set mark off. */
+ case LFUN_MARK_OFF:
+ BeforeChange();
+ owner->view()->update(0);
+ owner->view()->text->sel_cursor =
+ owner->view()->text->cursor;
+ setMessage(N_("Mark off"));
+ break;
+
+ /* -------> Set mark on. */
+ case LFUN_MARK_ON:
+ BeforeChange();
+ owner->view()->text->mark_set = 1;
+ owner->view()->update( 0 );
+ owner->view()->text->sel_cursor =
+ owner->view()->text->cursor;
+ setMessage(N_("Mark on"));
+ break;
+
+ case LFUN_BACKSPACE:
+ {
+ FreeUpdateTimer();
+ if (!owner->view()->text->selection) {
+ if (owner->getIntl()->getTrans()->backspace()) {
+ owner->view()->text->Backspace();
+ owner->view()->text->sel_cursor =
+ owner->view()->text->cursor;
+ SmallUpdate(1);
+ // It is possible to make it a lot faster still
+ // just comment out the lone below...
+ owner->view()->getScreen()->ShowCursor();
+ }
+ } else {
+ CutCB();
+ }
+ SetUpdateTimer();
+ }
+ break;
+
+ case LFUN_BACKSPACE_SKIP:
+ {
+ // Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
+
+ LyXCursor cursor = owner->view()->text->cursor;
+
+ FreeUpdateTimer();
+ if (!owner->view()->text->selection) {
+ if (cursor.pos == 0
+ && !(cursor.par->added_space_top
+ == VSpace (VSpace::NONE))) {
+ owner->view()->text->SetParagraph
+ (cursor.par->line_top,
+ cursor.par->line_bottom,
+ cursor.par->pagebreak_top,
+ cursor.par->pagebreak_bottom,
+ VSpace(VSpace::NONE), cursor.par->added_space_bottom,
+ cursor.par->align,
+ cursor.par->labelwidthstring, 0);
+ owner->view()->update (1);
+ } else {
+ owner->view()->text->Backspace();
+ owner->view()->text->sel_cursor
+ = cursor;
+ SmallUpdate (1);
+ }
+ } else
+ CutCB();
+ SetUpdateTimer();
+ }
+ break;
+
+ case LFUN_BREAKPARAGRAPH:
+ {
+ BeforeChange();
+ owner->view()->text->BreakParagraph(0);
+ SmallUpdate(1);
+ SetUpdateTimer(0.01);
+ owner->view()->text->sel_cursor =
+ owner->view()->text->cursor;
+ break;
+ }
+
+ case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
+ {
+ BeforeChange();
+ owner->view()->text->BreakParagraph(1);
+ SmallUpdate(1);
+ SetUpdateTimer(0.01);
+ owner->view()->text->sel_cursor =
+ owner->view()->text->cursor;
+ break;
+ }
+
+ case LFUN_BREAKPARAGRAPH_SKIP:
+ {
+ // When at the beginning of a paragraph, remove
+ // indentation and add a "defskip" at the top.
+ // Otherwise, do the same as LFUN_BREAKPARAGRAPH.
+
+ LyXCursor cursor = owner->view()->text->cursor;
+
+ BeforeChange();
+ if (cursor.pos == 0) {
+ if (cursor.par->added_space_top == VSpace(VSpace::NONE)) {
+ owner->view()->text->SetParagraph
+ (cursor.par->line_top,
+ cursor.par->line_bottom,
+ cursor.par->pagebreak_top,
+ cursor.par->pagebreak_bottom,
+ VSpace(VSpace::DEFSKIP), cursor.par->added_space_bottom,
+ cursor.par->align,
+ cursor.par->labelwidthstring, 1);
+ owner->view()->update(1);
+ }
+ }
+ else {
+ owner->view()->text->BreakParagraph(0);
+ SmallUpdate(1);
+ }
+ SetUpdateTimer(0.01);
+ owner->view()->text->sel_cursor = cursor;
+ }
+ break;
+
+ case LFUN_QUOTE:
+ BeforeChange();
+ owner->view()->text->InsertChar('\"'); // This " matches the single quote in the code
+ SmallUpdate(1);
+ SetUpdateTimer();
+ moveCursorUpdate(false);
+ break;
+
+ case LFUN_HTMLURL:
+ case LFUN_URL:
+ {
+ InsetCommand * new_inset;
+ if (action == LFUN_HTMLURL)
+ new_inset = new InsetUrl("htmlurl", "", "");
+ else
+ new_inset = new InsetUrl("url", "", "");
+ owner->buffer()->insertInset(new_inset);
+ new_inset->Edit(0, 0);
+ }
+ break;
+
+ // --- lyxserver commands ----------------------------
+
+ case LFUN_CHARATCURSOR:
+ {
+ LyXParagraph::size_type pos =
+ owner->view()->text->cursor.pos;
+ if(pos < owner->view()->text->cursor.par->size())
+ dispatch_buffer = owner->view()->text->
+ cursor.par->text[pos];
+ else
+ dispatch_buffer = "EOF";
+ }
+ break;
+
+ case LFUN_GETXY:
+ dispatch_buffer =
+ tostr(owner->view()->text->cursor.x) + ' '
+ + tostr(owner->view()->text->cursor.y);
+ break;
+
+ case LFUN_SETXY:
+ {
+ int x;
+ long y;
+ sscanf(argument.c_str(), " %d %ld", &x, &y);
+ owner->view()->text->SetCursorFromCoordinates(x, y);
+ }
+ break;
+
+ case LFUN_GETLAYOUT:
+ dispatch_buffer =
+ tostr(owner->view()->text->cursor.par->layout);
+ break;
+
+ case LFUN_GETFONT:
+ {
+ LyXFont *font = &(owner->view()->text->current_font);
+ if(font->shape() == LyXFont::ITALIC_SHAPE)
+ dispatch_buffer = 'E';
+ else if(font->shape() == LyXFont::SMALLCAPS_SHAPE)
+ dispatch_buffer = 'N';
+ else
+ dispatch_buffer = '0';
+
+ }
+ break;
+
+ case LFUN_GETLATEX:
+ {
+ LyXFont *font = &(owner->view()->text->current_font);
+ if(font->latex() == LyXFont::ON)
+ dispatch_buffer = 'L';
+ else
+ dispatch_buffer = '0';
+ }
+ break;
+
+ case LFUN_GETNAME:
+ setMessage(owner->buffer()->fileName());
+ lyxerr.debug() << "FNAME["
+ << owner->buffer()->fileName()
+ << "] " << endl;
+ break;
+
+ case LFUN_NOTIFY:
+ {
+ char buf[100];
+ keyseq.print(buf, 100);
+ dispatch_buffer = buf;
+ lyxserver->notifyClient(dispatch_buffer);
+ }
+ break;
+
+ case LFUN_GOTOFILEROW:
+ {
+ char file_name[100];
+ int row;
+ sscanf(argument.c_str(), " %s %d", file_name, &row);
+
+ // Must replace extension of the file to be .lyx and get full path
+ string s = ChangeExtension(string(file_name), ".lyx", false);
+
+ // Either change buffer or load the file
+ if (bufferlist.exists(s))
+ owner->view()->buffer(bufferlist.getBuffer(s));
+ else
+ owner->view()->buffer(bufferlist.loadLyXFile(s));
+
+ // Set the cursor
+ owner->buffer()->setCursorFromRow(row);
+
+ // Recenter screen
+ BeforeChange();
+ if (owner->view()->text->cursor.y >
+ owner->view()->getWorkArea()->h / 2) {
+ owner->view()->getScreen()->
+ Draw(owner->view()->text->cursor.y -
+ owner->view()->getWorkArea()->h/2);
+ } else { // <=
+ owner->view()->getScreen()->
+ Draw(0);
+ }
+ owner->view()->update(0);
+ owner->view()->redraw();
+ }
+ break;
+
+ case LFUN_APROPOS:
+ case LFUN_GETTIP:
+ {
+ int qa = lyxaction.LookupFunc(argument.c_str());
+ setMessage(lyxaction.helpText((kb_action)qa));
+ }
+ break;
+
+ // --- accented characters ---------------------------
+
+ case LFUN_UMLAUT:
+ case LFUN_CIRCUMFLEX:
+ case LFUN_GRAVE:
+ case LFUN_ACUTE:
+ case LFUN_TILDE:
+ case LFUN_CEDILLA:
+ case LFUN_MACRON:
+ case LFUN_DOT:
+ case LFUN_UNDERDOT:
+ case LFUN_UNDERBAR:
+ case LFUN_CARON:
+ case LFUN_SPECIAL_CARON:
+ case LFUN_BREVE:
+ case LFUN_TIE:
+ case LFUN_HUNG_UMLAUT:
+ case LFUN_CIRCLE:
+ case LFUN_OGONEK:
+ {
+ char c;
+
+ if (keyseq.length == -1 && keyseq.getiso()!= 0)
+ c= keyseq.getiso();
+ else
+ c= 0;
+
+ owner->getIntl()->getTrans()->
+ deadkey(c, get_accent(action).accent,
+ owner->view()->text);
+
+ // Need to reset, in case the minibuffer calls these
+ // actions
+ keyseq.reset();
+ keyseq.length= 0;
+
+ // copied verbatim from do_accent_char
+ SmallUpdate(1);
+ SetUpdateTimer();
+ owner->view()->text->sel_cursor =
+ owner->view()->text->cursor;
+ }
+ break;
+
+ // --- toolbar ----------------------------------
+ case LFUN_PUSH_TOOLBAR:
+ {
+ int nth = strToInt(argument);
+ if (lyxerr.debugging(Debug::TOOLBAR)) {
+ lyxerr << "LFUN_PUSH_TOOLBAR: argument = `"
+ << argument << "'\n"
+ << "LFUN_PUSH_TOOLBAR: nth = `"
+ << nth << "'" << endl;
+ }
+
+ if (nth <= 0) {
+ LyXBell();
+ setErrorMessage(N_("Push-toolbar needs argument > 0"));
+ } else {
+ owner->getToolbar()->push(nth);
+ }
+ }
+ break;
+
+ case LFUN_ADD_TO_TOOLBAR:
+ {
+ if (lyxerr.debugging(Debug::TOOLBAR)) {
+ lyxerr << "LFUN_ADD_TO_TOOLBAR:"
+ "argument = `" << argument << '\'' << endl;
+ }
+ string tmp(argument);
+ //lyxerr <<string("Argument: ") + argument);
+ //lyxerr <<string("Tmp : ") + tmp);
+ if (tmp.empty()) {
+ LyXBell();
+ setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
+ } else {
+ owner->getToolbar()->add(argument, false);
+ owner->getToolbar()->set();
+ }
+ }
+ break;
+
+ // --- insert characters ----------------------------------------
+#if 0
+ case LFUN_INSERT_INSET_LATEX:
+ {
+ Inset *new_inset = new InsetLatex(argument);
+ owner->buffer()->insertInset(new_inset);
+ }
+ break;
+#endif
+ // --- Mathed stuff. If we are here, there is no locked inset yet.
+
+ // Greek mode
+ case LFUN_GREEK:
+ {
+ if (!greek_kb_flag) {
+ greek_kb_flag = 1;
+ setMessage(N_("Math greek mode on"));
+ } else
+ greek_kb_flag = 0;
+ }
+ break;
+
+ // Greek keyboard
+ case LFUN_GREEK_TOGGLE:
+ {
+ greek_kb_flag = (greek_kb_flag) ? 0: 2;
+ if (greek_kb_flag) {
+ setMessage(N_("Math greek keyboard on"));
+ } else {
+ setMessage(N_("Math greek keyboard off"));
+ }
+ }
+ break;
+
+ case LFUN_MATH_DELIM:
+ case LFUN_INSERT_MATRIX:
+ {
+ if (owner->view()->available()) {
+ owner->buffer()->
+ open_new_inset(new InsetFormula(false));
+ owner->buffer()->
+ the_locking_inset->LocalDispatch(action, argument.c_str());
+ }
+ }
+ break;
+
+ case LFUN_INSERT_MATH:
+ {
+ math_insert_symbol(argument.c_str());
+ }
+ break;
+
+ case LFUN_MATH_DISPLAY:
+ {
+ if (owner->view()->available())
+ owner->buffer()->open_new_inset(new InsetFormula(true));
+ break;
+ }
+
+ case LFUN_MATH_MACRO:
+ {
+ if (owner->view()->available()) {
+ string s(argument);
+ if (s.empty())
+ setErrorMessage(N_("Missing argument"));
+ else {
+ string s1 = token(s, ' ', 1);
+ int na = s1.empty() ? 0: atoi(s1.c_str());
+ owner->buffer()->
+ open_new_inset(new InsetFormulaMacro(token(s, ' ', 0), na));
+ }
+ }
+ }
+ break;
+
+ case LFUN_MATH_MODE: // Open or create a math inset
+ {
+
+ if (owner->view()->available())
+ owner->buffer()->open_new_inset(new InsetFormula);
+ setMessage(N_("Math editor mode"));
+ }
+ break;
+
+ case LFUN_MATH_NUMBER:
+ case LFUN_MATH_LIMITS:
+ {
+ setErrorMessage(N_("This is only allowed in math mode!"));
+ }
+ break;
+
+ case LFUN_INSERT_CITATION:
+ {
+ InsetCitation * new_inset = new InsetCitation();
+ // ale970405
+ // The note, if any, must be after the key, delimited
+ // by a | so both key and remark can have spaces.
+ if (!argument.empty()) {
+ string lsarg(argument);
+ if (contains(lsarg, "|")) {
+ new_inset->setContents(token(lsarg, '|', 0));
+ new_inset->setOptions(token(lsarg, '|', 1));
+ } else
+ new_inset->setContents(lsarg);
+ owner->buffer()->insertInset(new_inset);
+ } else {
+ owner->buffer()->insertInset(new_inset);
+ new_inset->Edit(0, 0);
+ }
+ }
+ break;
+
+ case LFUN_INSERT_BIBTEX:
+ {
+ // ale970405+lasgoutt970425
+ // The argument can be up to two tokens separated
+ // by a space. The first one is the bibstyle.
+ string lsarg(argument);
+ string bibstyle = token(lsarg, ' ', 1);
+ if (bibstyle.empty())
+ bibstyle = "plain";
+ InsetBibtex * new_inset
+ = new InsetBibtex(token(lsarg, ' ', 0),
+ bibstyle,
+ owner->buffer());
+
+ owner->buffer()->insertInset(new_inset);
+ if (lsarg.empty()) {
+ new_inset->Edit(0, 0);
+ }
+ }
+ break;
+
+ // BibTeX data bases
+ case LFUN_BIBDB_ADD:
+ {
+ InsetBibtex * inset =
+ static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
+ if (inset) {
+ inset->addDatabase(argument);
+ }
+ }
+ break;
+
+ case LFUN_BIBDB_DEL:
+ {
+ InsetBibtex * inset =
+ static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
+ if (inset) {
+ inset->delDatabase(argument);
+ }
+ }
+ break;
+
+ case LFUN_BIBTEX_STYLE:
+ {
+ InsetBibtex * inset =
+ static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
+ if (inset) {
+ inset->setOptions(argument);
+ }
+ }
+ break;
+
+ case LFUN_INDEX_INSERT:
+ case LFUN_INDEX_INSERT_LAST:
+ {
+ // Can't do that at the beginning of a paragraph.
+ if (owner->view()->text->cursor.pos - 1 <0)
+ break;
+
+ InsetIndex * new_inset = new InsetIndex();
+ if (!argument.empty()) {
+ string lsarg(argument);
+ new_inset->setContents(lsarg);
+ owner->buffer()->insertInset(new_inset);
+ } else {
+ //reh 98/09/21
+ //get the current word for an argument
+ LyXParagraph::size_type lastpos =
+ owner->view()->text->cursor.pos - 1;
+ // Get the current word. note that this must be done
+ // before inserting the inset, or the inset will
+ // break the word
+ string curstring(owner->view()
+ ->text->cursor.par->GetWord(lastpos));
+
+ //make the new inset and write the current word into it
+ InsetIndex * new_inset = new InsetIndex();
+
+ new_inset->setContents(curstring);
+
+ //don't edit it if the call was to INSERT_LAST
+ if(action!= LFUN_INDEX_INSERT_LAST) {
+ new_inset->Edit(0, 0);
+ } else {
+ //it looks blank on the screen unless
+ //we do something. put it here.
+
+ // move the cursor to the returned value of lastpos
+ // but only for the auto-insert
+ owner->view()->text->cursor.pos= lastpos;
+ }
+
+ //put the new inset into the buffer.
+ // there should be some way of knowing the user
+ //cancelled & avoiding this, but i don't know how
+ owner->buffer()->insertInset(new_inset);
+ }
+ }
+ break;
+
+ case LFUN_INDEX_PRINT:
+ {
+ Inset * new_inset = new InsetPrintIndex(owner->buffer());
+ owner->buffer()->insertInset(new_inset, "Standard", true);
+ }
+ break;
+
+ case LFUN_PARENTINSERT:
+ {
+ lyxerr << "arg " << argument << endl;
+ Inset * new_inset = new InsetParent(argument, owner->buffer());
+ owner->buffer()->insertInset(new_inset, "Standard", true);
+ }
+ break;
+
+ case LFUN_CHILDINSERT:
+ {
+ Inset * new_inset = new InsetInclude(argument,
+ owner->buffer());
+ owner->buffer()->insertInset(new_inset, "Standard", true);
+ new_inset->Edit(0, 0);
+ }
+ break;
+
+ case LFUN_CHILDOPEN:
+ {
+ string filename =
+ MakeAbsPath(argument,
+ OnlyPath(owner->buffer()->fileName()));
+ setMessage(N_("Opening child document ") +
+ MakeDisplayPath(filename) + "...");
+ owner->view()->savePosition();
+ if (bufferlist.exists(filename))
+ owner->view()->buffer(bufferlist.getBuffer(filename));
+ else
+ owner->view()->buffer(bufferlist.loadLyXFile(filename));
+ }
+ break;
+
+ case LFUN_INSERT_NOTE:
+ NoteCB();
+ break;
+
+ case LFUN_INSERTFOOTNOTE:
+ {
+ LyXParagraph::footnote_kind kind;
+ if (argument == "footnote")
+ { kind = LyXParagraph::FOOTNOTE; }
+ else if (argument == "margin")
+ { kind = LyXParagraph::MARGIN; }
+ else if (argument == "figure")
+ { kind = LyXParagraph::FIG; }
+ else if (argument == "table")
+ { kind = LyXParagraph::TAB; }
+ else if (argument == "wide-fig")
+ { kind = LyXParagraph::WIDE_FIG; }
+ else if (argument == "wide-tab")
+ { kind = LyXParagraph::WIDE_TAB; }
+ else if (argument == "algorithm")
+ { kind = LyXParagraph::ALGORITHM; }
+ else {
+ setErrorMessage(N_("Unknown kind of footnote"));
+ break;
+ }
+ owner->view()->text->InsertFootnoteEnvironment(kind);
+ owner->view()->update(1);
+ }
+ break;
+
+ case LFUN_BUFFERBULLETSSELECT:
+ bulletForm();
+ break;
+
+ case LFUN_TOGGLECURSORFOLLOW:
+ cursor_follows_scrollbar = !cursor_follows_scrollbar;
+ break;
+
+ case LFUN_KMAP_OFF: // keymap off
+ owner->getIntl()->KeyMapOn(false);
+ break;
+
+ case LFUN_KMAP_PRIM: // primary keymap
+ owner->getIntl()->KeyMapPrim();
+ break;
+
+ case LFUN_KMAP_SEC: // secondary keymap
+ owner->getIntl()->KeyMapSec();
+ break;
+
+ case LFUN_KMAP_TOGGLE: // toggle keymap
+ owner->getIntl()->ToggleKeyMap();
+ break;
+
+ case LFUN_SELFINSERT:
+ {
+ for (string::size_type i = 0; i < argument.length(); ++i) {
+ owner->view()->text->InsertChar(argument[i]);
+ // This needs to be in the loop, or else we
+ // won't break lines correctly. (Asger)
+ SmallUpdate(1);
+ }
+ SetUpdateTimer();
+ owner->view()->text->sel_cursor =
+ owner->view()->text->cursor;
+ moveCursorUpdate(false);
}
+ break;
- // already here we know if it any point in going further
- // why not return already here if action == -1 and
- // num_bytes == 0? (Lgb)
-
- if(keyseq.length>1 || keyseq.length<-1){
- char buf[100];
- keyseq.print(buf, 100);
- owner->getMiniBuffer()->Set(buf);
+ case LFUN_SEQUENCE:
+ {
+ // argument contains ';'-terminated commands
+ while (argument.find(';') != string::npos) {
+ string first;
+ argument = split(argument, first, ';');
+ Dispatch(first);
+ }
}
+ break;
- if (action == -1) {
- if (keyseq.length<-1) { // unknown key sequence...
- char buf[100];
- LyXBell();
- keyseq.print(buf, 100);
- owner->getMiniBuffer()->Set(_("Unknown sequence:"), buf);
- return 0;
- }
+ case LFUN_SAVEPREFERENCES:
+ {
+ Path p(user_lyxdir);
+ lyxrc->write("preferences");
+ }
+ break;
- char isochar = keyseq.getiso();
- if (!(keyevent->state&ControlMask) &&
- !(keyevent->state&Mod1Mask) &&
- (isochar && keysym_return < 0xF000)) {
- argument += isochar;
- }
- if (argument.empty()) {
- lyxerr.debug() << "Empty argument!" << endl;
- // This can`t possibly be of any use
- // so we`ll skip the dispatch.
- return 0;
- }
- } else
- if (action == LFUN_SELFINSERT) {
- argument = s_r[0];
+ case LFUN_UNKNOWN_ACTION:
+ {
+ if (owner->buffer()->isReadonly()) {
+ LyXBell();
+ setErrorMessage(N_("Document is read only"));
+ break;
}
-
- bool tmp_sc = show_sc;
- show_sc = false;
- Dispatch(action, argument.c_str());
- show_sc = tmp_sc;
-
- return 0;
-}
-
-
-LyXFunc::func_status LyXFunc::getStatus(int ac) const
-{
- kb_action action;
- func_status flag = LyXFunc::OK;
- string argument;
- Buffer * buf = owner->buffer();
-
- if (lyxaction.isPseudoAction(ac))
- action = lyxaction.retrieveActionArg(ac, argument);
- else
- action = static_cast<kb_action>(ac);
-
- if (action == LFUN_UNKNOWN_ACTION) {
- setErrorMessage(N_("Unknown action"));
- return LyXFunc::Unknown;
- }
-
- // Check whether we need a buffer
- if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
- // Yes we need a buffer, do we have one?
- if (buf) {
- // yes
- // Can we use a readonly buffer?
- if (buf->isReadonly() &&
- !lyxaction.funcHasFlag(action,
- LyXAction::ReadOnly)) {
- // no
- setErrorMessage(N_("Document is read-only"));
- flag = func_status(flag | LyXFunc::Disabled);
+
+ if (!argument.empty()) {
+
+ /* Automatically delete the currently selected
+ * text and replace it with what is being
+ * typed in now. Depends on lyxrc settings
+ * "auto_region_delete", which defaults to
+ * true (on). */
+
+ if ( lyxrc->auto_region_delete ) {
+ if (owner->view()->text->selection){
+ owner->view()->text->CutSelection(false);
+ owner->view()->update(-1);
+ }
+ }
+
+ BeforeChange();
+ for (string::size_type i = 0;
+ i < argument.length(); ++i) {
+ if (greek_kb_flag) {
+ if (!math_insert_greek(argument[i]))
+ owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->view()->text);
+ } else
+ owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->view()->text);
}
+
+ SmallUpdate(1);
+ SetUpdateTimer();
+
+ owner->view()->text->sel_cursor =
+ owner->view()->text->cursor;
+ moveCursorUpdate(false);
+ return string();
} else {
- // no
- setErrorMessage(N_("Command not allowed with"
- "out any document open"));
- flag = func_status(flag | LyXFunc::Disabled);
+ // why is an "Unknown action" with empty
+ // argument even dispatched in the first
+ // place? I`ll probably change that. (Lgb)
+ LyXBell();
+ setErrorMessage(N_("Unknown action"));
}
+ break;
+ default:
+ lyxerr << "A truly unknown func!" << endl;
+ break;
}
+ } // end of switch
+ exit_with_message:
- if (flag & LyXFunc::Disabled)
- return flag;
-
- static bool noLaTeX = lyxrc->latex_command == "none";
- bool disable = false;
- switch (action) {
- case LFUN_PREVIEW:
- disable = noLaTeX || lyxrc->view_dvi_command == "none";
- break;
- case LFUN_PREVIEWPS:
- disable = noLaTeX || lyxrc->view_ps_command == "none";
- break;
- case LFUN_RUNLATEX:
- case LFUN_RUNDVIPS:
- disable = noLaTeX;
- break;
- case LFUN_MENUPRINT:
- disable = noLaTeX || lyxrc->print_command == "none";
- break;
- case LFUN_FAX:
- disable = noLaTeX || lyxrc->fax_command == "none";
- break;
- case LFUN_IMPORT:
- if (argument == "latex")
- disable = lyxrc->relyx_command == "none";
- break;
- case LFUN_EXPORT:
- if (argument == "dvi" || argument == "postscript")
- disable = noLaTeX;
- if (argument == "html")
- disable = lyxrc->html_command == "none";
- break;
- case LFUN_UNDO:
- disable = buf->undostack.empty();
- break;
- case LFUN_REDO:
- disable = buf->redostack.empty();
- break;
- case LFUN_SPELLCHECK:
- disable = lyxrc->isp_command == "none";
- break;
- case LFUN_RUNCHKTEX:
- disable = lyxrc->chktex_command == "none";
- break;
- case LFUN_LAYOUT_TABLE:
- disable = ! buf->text->cursor.par->table;
- break;
- default:
- break;
- }
- if (disable)
- flag |= LyXFunc::Disabled;
+ string res = getMessage();
- if (buf) {
- func_status box = LyXFunc::ToggleOff;
- LyXFont font = buf->text->real_current_font;
- switch (action) {
- case LFUN_EMPH:
- if (font.emph() == LyXFont::ON)
- box = LyXFunc::ToggleOn;
- break;
- case LFUN_NOUN:
- if (font.noun() == LyXFont::ON)
- box = LyXFunc::ToggleOn;
- break;
- case LFUN_BOLD:
- if (font.series() == LyXFont::BOLD_SERIES)
- box = LyXFunc::ToggleOn;
- break;
- case LFUN_TEX:
- if (font.latex() == LyXFont::ON)
- box = LyXFunc::ToggleOn;
- break;
- default:
- box = LyXFunc::OK;
- break;
+ if (res.empty()) {
+ if (!commandshortcut.empty()) {
+ string newbuf = owner->getMiniBuffer()->GetText();
+ if (newbuf != commandshortcut) {
+ owner->getMiniBuffer()->Set(newbuf
+ + " " +
+ commandshortcut);
+ }
}
- flag |= box;
+ } else {
+ owner->getMiniBuffer()->Set(string(_(res.c_str()))
+ + " " + commandshortcut);
}
-
- return flag;
-}
-
-
-string LyXFunc::Dispatch(string const & s)
-{
- // Split command string into command and argument
- string cmd, line = frontStrip(s);
- string arg = strip(frontStrip(split(line, cmd, ' ')));
-
- return Dispatch(lyxaction.LookupFunc(cmd.c_str()), arg.c_str());
+ return res;
}
-
-
+#else
string LyXFunc::Dispatch(int ac,
char const * do_not_use_this_arg)
{
return res;
}
-
+#endif
void LyXFunc::setupLocalKeymap()
{
void LyXFunc::reloadBuffer()
{
- string fn = owner->buffer()->getFileName();
+ string fn = owner->buffer()->fileName();
if (bufferlist.close(owner->buffer()))
owner->view()->buffer(bufferlist.loadLyXFile(fn));
}
{
bool found = false;
Inset * inset = 0;
+#ifdef MOVE_TEXT
+ LyXCursor cursor = owner->view()->text->cursor;
+#else
LyXCursor cursor = owner->buffer()->text->cursor;
+#endif
LyXParagraph::size_type pos = cursor.pos;
LyXParagraph * par = cursor.par;
// so... we use RCS as default, later this should perhaps be
// a lyxrc option.
if (!vcs) {
- vcs = new RCS(owner_->getFileName());
+ vcs = new RCS(owner_->fileName());
vcs->owner(owner_);
}
// If the document is changed, we might want to save it
if (!vcs->owner()->isLyxClean() &&
AskQuestion(_("Changes in document:"),
- MakeDisplayPath(vcs->owner()->getFileName(), 50),
+ MakeDisplayPath(vcs->owner()->fileName(), 50),
_("Save document and proceed?"))) {
vcs->owner()->getUser()->owner()
->getLyXFunc()->Dispatch(LFUN_MENUWRITE);
// If the document is changed, we might want to save it
if (!vcs->owner()->isLyxClean() &&
AskQuestion(_("Changes in document:"),
- MakeDisplayPath(vcs->owner()->getFileName(), 50),
+ MakeDisplayPath(vcs->owner()->fileName(), 50),
_("Save document and proceed?"))) {
vcs->owner()->getUser()->owner()
->getLyXFunc()->Dispatch(LFUN_MENUWRITE);
lyxerr[Debug::LYXVC] << "LyXVC: checkOut" << endl;
if (!vcs->owner()->isLyxClean()
&& !AskQuestion(_("Changes in document:"),
- MakeDisplayPath(vcs->owner()->getFileName(), 50),
+ MakeDisplayPath(vcs->owner()->fileName(), 50),
_("Ignore changes and proceed with check out?"))) {
return;
}
return;
}
+#ifdef MOVE_TEXT
+void Menus::ShowEditMenu(FL_OBJECT * ob, long)
+{
+ Menus * men = static_cast<Menus*>(ob->u_vdata);
+
+ // set the pseudo menu-button
+ fl_set_object_boxtype(ob, FL_UP_BOX);
+ fl_set_button(ob, 0);
+ fl_redraw_object(ob);
+
+ Buffer * tmpbuffer = men->_view->buffer();
+ LyXFunc * tmpfunc = men->_view->getLyXFunc();
+
+ // Floats & Insets submenu
+ int SubEditFloats= fl_defpup(FL_ObjWin(ob),
+ _("Floats & Insets%t"
+ "|Open/Close%x21"
+ "|Melt%x22"
+ "|Open All Footnotes/Margin Notes%x23"
+ "|Close All Footnotes/Margin Notes%x24"
+ "|Open All Figures/Tables%x25"
+ "|Close All Figures/Tables%x26%l"
+ "|Remove all Error Boxes%x27"));
+
+ fl_setpup_shortcut(SubEditFloats, 21, scex(_("EMF|Oo#o#O")));
+ fl_setpup_shortcut(SubEditFloats, 22, scex(_("EMF|Mm#m#M")));
+ fl_setpup_shortcut(SubEditFloats, 23, scex(_("EMF|Aa#a#A")));
+ fl_setpup_shortcut(SubEditFloats, 24, scex(_("EMF|Cc#c#C")));
+ fl_setpup_shortcut(SubEditFloats, 25, scex(_("EMF|Ff#f#F")));
+ fl_setpup_shortcut(SubEditFloats, 26, scex(_("EMF|Tt#t#T")));
+ fl_setpup_shortcut(SubEditFloats, 27, scex(_("EMF|Rr#r#R")));
+
+ // Table submenu
+ int SubEditTable = fl_newpup(FL_ObjWin(ob));
+ if (men->currentView()->available() &&
+ men->currentView()->text->cursor.par->table &&
+ !tmpbuffer->isReadonly()){
+
+ fl_addtopup(SubEditTable, _("Table%t"));
+
+ if (men->currentView()->text->cursor.par->table->
+ IsMultiColumn(men->currentView()->text->
+ NumberOfCell(men->currentView()->
+ text->cursor.par,
+ men->currentView()->
+ text->cursor.pos)))
+ fl_addtopup(SubEditTable, _("|Multicolumn%B%x44%l"));
+ else
+ fl_addtopup(SubEditTable, _("|Multicolumn%b%x44%l"));
+ fl_setpup_shortcut(SubEditTable, 44, scex(_("EMT|Mm#m#M")));
+
+ if (men->currentView()->text->cursor.par->table->
+ TopLine(men->currentView()->text->
+ NumberOfCell(men->currentView()->
+ text->cursor.par,
+ men->currentView()->text->
+ cursor.pos)))
+ fl_addtopup(SubEditTable, _("|Line Top%B%x36"));
+ else
+ fl_addtopup(SubEditTable, _("|Line Top%b%x36"));
+ fl_setpup_shortcut(SubEditTable, 36, scex(_("EMT|Tt#t#T")));
+
+ if (men->currentView()->text->cursor.par->table->
+ BottomLine(men->currentView()->text->
+ NumberOfCell(men->currentView()->
+ text->cursor.par,
+ men->currentView()->
+ text->cursor.pos)))
+ fl_addtopup(SubEditTable, _("|Line Bottom%B%x37"));
+ else
+ fl_addtopup(SubEditTable, _("|Line Bottom%b%x37"));
+ fl_setpup_shortcut(SubEditTable, 37, scex(_("EMT|Bb#b#B")));
+
+ if (men->currentView()->text->cursor.par->table->
+ LeftLine(men->currentView()->text->
+ NumberOfCell(men->currentView()->
+ text->cursor.par,
+ men->currentView()->
+ text->cursor.pos)))
+ fl_addtopup(SubEditTable, _("|Line Left%B%x38"));
+ else
+ fl_addtopup(SubEditTable, _("|Line Left%b%x38"));
+ fl_setpup_shortcut(SubEditTable, 38, scex(_("EMT|Ll#l#L")));
+
+ if (men->currentView()->text->cursor.par->table->
+ RightLine(men->currentView()->text->
+ NumberOfCell(men->currentView()->
+ text->cursor.par,
+ men->currentView()->
+ text->cursor.pos)))
+ fl_addtopup(SubEditTable, _("|Line Right%B%x39%l"));
+ else
+ fl_addtopup(SubEditTable, _("|Line Right%b%x39%l"));
+ fl_setpup_shortcut(SubEditTable, 39, scex(_("EMT|Rr#r#R")));
+
+ int align = men->currentView()->text->cursor.par->
+ table->GetAlignment(men->currentView()->text->
+ NumberOfCell(men->currentView()->
+ text->cursor.par,
+ men->currentView()->
+ text->cursor.pos));
+ if (align == LYX_ALIGN_LEFT)
+ fl_addtopup(SubEditTable, _("|Align Left%R%x40"));
+ else
+ fl_addtopup(SubEditTable, _("|Align Left%r%x40"));
+ fl_setpup_shortcut(SubEditTable, 40, scex(_("EMT|eE#e#E")));
+
+ if (align == LYX_ALIGN_RIGHT)
+ fl_addtopup(SubEditTable, _("|Align Right%R%x41"));
+ else
+ fl_addtopup(SubEditTable, _("|Align Right%r%x41"));
+ fl_setpup_shortcut(SubEditTable, 41, scex(_("EMT|iI#i#I")));
+
+ if (align == LYX_ALIGN_CENTER)
+ fl_addtopup(SubEditTable, _("|Align Center%R%x42%l"));
+ else
+ fl_addtopup(SubEditTable, _("|Align Center%r%x42%l"));
+ fl_setpup_shortcut(SubEditTable, 42, scex(_("EMT|Cc#c#C")));
+
+ // xgettext:no-c-format
+ fl_addtopup(SubEditTable, _("|Append Row%x32"));
+ fl_setpup_shortcut(SubEditTable, 32, scex(_("EMT|oO#o#O")));
+ // xgettext:no-c-format
+ fl_addtopup(SubEditTable, _("|Append Column%x33%l"));
+ fl_setpup_shortcut(SubEditTable, 33, scex(_("EMT|uU#u#U")));
+ // xgettext:no-c-format
+ fl_addtopup(SubEditTable, _("|Delete Row%x34"));
+ fl_setpup_shortcut(SubEditTable, 34, scex(_("EMT|wW#w#W")));
+ // xgettext:no-c-format
+ fl_addtopup(SubEditTable, _("|Delete Column%x35%l"));
+ fl_setpup_shortcut(SubEditTable, 35, scex(_("EMT|nN#n#N")));
+ // xgettext:no-c-format
+ fl_addtopup(SubEditTable, _("|Delete Table%x43"));
+ fl_setpup_shortcut(SubEditTable, 43, scex(_("EMT|Dd#d#D")));
+ }
+ else {
+ fl_addtopup(SubEditTable, _("Table%t"));
+ // xgettext:no-c-format
+ fl_addtopup(SubEditTable, _("|Insert table%x31"));
+ fl_setpup_shortcut(SubEditTable, 31, scex(_("EMT|Ii#i#I")));
+ }
+
+ int SubVersionControl = fl_newpup(FL_ObjWin(ob));
+ fl_addtopup(SubVersionControl, _("Version Control%t"));
+ if (tmpbuffer->lyxvc.inUse()) {
+ // xgettext:no-c-format
+ fl_addtopup(SubVersionControl, _("|Register%d%x51"));
+ if (tmpbuffer->isReadonly()) {
+ // signifies that the file is not checked out
+ // xgettext:no-c-format
+ fl_addtopup(SubVersionControl, _("|Check In Changes%d%x52"));
+ // xgettext:no-c-format
+ fl_addtopup(SubVersionControl, _("|Check Out for Edit%x53"));
+ } else {
+ // signifies that the file is checked out
+ // xgettext:no-c-format
+ fl_addtopup(SubVersionControl, _("|Check In Changes%x52"));
+ // xgettext:no-c-format
+ fl_addtopup(SubVersionControl, _("|Check Out for Edit%d%x53"));
+ }
+ // xgettext:no-c-format
+ fl_addtopup(SubVersionControl, _("|Revert to last version%x54"));
+ // xgettext:no-c-format
+ fl_addtopup(SubVersionControl, _("|Undo last check in%x55"));
+ // xgettext:no-c-format
+ fl_addtopup(SubVersionControl, _("|Show History%x56"));
+ } else {
+ // xgettext:no-c-format
+ fl_addtopup(SubVersionControl, _("|Register%x51"));
+ }
+ // the shortcuts are not good.
+ fl_setpup_shortcut(SubVersionControl, 51, scex(_("EMV|Rr#r#R")));
+ fl_setpup_shortcut(SubVersionControl, 52, scex(_("EMV|Ii#i#I")));
+ fl_setpup_shortcut(SubVersionControl, 53, scex(_("EMV|Oo#o#O")));
+ fl_setpup_shortcut(SubVersionControl, 54, scex(_("EMV|lL#l#l")));
+ fl_setpup_shortcut(SubVersionControl, 55, scex(_("EMV|Uu#u#U")));
+ fl_setpup_shortcut(SubVersionControl, 56, scex(_("EMV|Hh#h#H")));
+
+ int EditMenu= fl_defpup(FL_ObjWin(ob),
+ _("Undo"
+ "|Redo %l"
+ "|Cut"
+ "|Copy"
+ "|Paste%l"
+ "|Find & Replace..."
+ "|Go to Error"
+ "|Go to Note"
+ "|Floats & Insets%m"
+ "|Table%m"
+ "|Spellchecker...."
+ "|Check TeX"
+ "|Table of Contents...%l"
+ "|Version Control%m%l"
+ "|View LaTeX log file%l"
+ "|Paste Primary Selection as Lines"
+ "|Paste Primary Selection as Paragraphs"),
+ SubEditFloats, SubEditTable, SubVersionControl);
+
+ fl_setpup_shortcut(EditMenu, 1, scex(_("EM|Uu#u#U")));
+ fl_setpup_shortcut(EditMenu, 2, scex(_("EM|Rr#r#R")));
+ fl_setpup_shortcut(EditMenu, 3, scex(_("EM|Cc#c#C")));
+ fl_setpup_shortcut(EditMenu, 4, scex(_("EM|oO#o#O")));
+ fl_setpup_shortcut(EditMenu, 5, scex(_("EM|Pp#p#P")));
+ fl_setpup_shortcut(EditMenu, 6, scex(_("EM|Ff#f#F")));
+ fl_setpup_shortcut(EditMenu, 7, scex(_("EM|Ee#e#E")));
+ fl_setpup_shortcut(EditMenu, 8, scex(_("EM|Nn#n#N")));
+ fl_setpup_shortcut(EditMenu, 9, scex(_("EM|Ii#i#I")));
+ fl_setpup_shortcut(EditMenu, 10, scex(_("EM|Tt#t#T")));
+ fl_setpup_shortcut(EditMenu, 11, scex(_("EM|Ss#s#S")));
+ fl_setpup_shortcut(EditMenu, 12, scex(_("EM|hH#h#H")));
+ fl_setpup_shortcut(EditMenu, 13, scex(_("EM|aA#a#A")));
+ fl_setpup_shortcut(EditMenu, 14, scex(_("EM|Vv#v#V")));
+ fl_setpup_shortcut(EditMenu, 15, scex(_("EM|wW#w#W")));
+ fl_setpup_shortcut(EditMenu, 16, scex(_("EM|Ll#l#L")));
+ fl_setpup_shortcut(EditMenu, 17, scex(_("EM|gG#g#G")));
+
+ // disable unavailable entries.
+ if(tmpbuffer->undostack.empty())
+ fl_setpup_mode(EditMenu, 1, FL_PUP_GREY);
+ if(tmpbuffer->redostack.empty())
+ fl_setpup_mode(EditMenu, 2, FL_PUP_GREY);
+ if(lyxrc->isp_command == "none")
+ fl_setpup_mode(EditMenu, 11, FL_PUP_GREY);
+ if(lyxrc->chktex_command == "none")
+ fl_setpup_mode(EditMenu, 12, FL_PUP_GREY);
+ if (tmpbuffer->isReadonly()) {
+ fl_setpup_mode(EditMenu, 1, FL_PUP_GREY);
+ fl_setpup_mode(EditMenu, 2, FL_PUP_GREY);
+ fl_setpup_mode(EditMenu, 3, FL_PUP_GREY);
+ fl_setpup_mode(EditMenu, 5, FL_PUP_GREY);
+ fl_setpup_mode(EditMenu, 16, FL_PUP_GREY);
+ fl_setpup_mode(EditMenu, 17, FL_PUP_GREY);
+ }
+
+ fl_setpup_position(men->_view->getForm()->x + ob->x,
+ men->_view->getForm()->y + ob->y +
+ ob->h + 10);
+ int choice = fl_dopup(EditMenu);
+ XFlush(fl_display);
+
+ // set the pseudo menu-button back
+ fl_set_object_boxtype(ob, FL_FLAT_BOX);
+ fl_redraw_object(ob);
+
+ switch (choice) {
+ case 1: tmpfunc->Dispatch(LFUN_UNDO); break;
+ case 2: tmpfunc->Dispatch(LFUN_REDO); break;
+ case 3: tmpfunc->Dispatch(LFUN_CUT); break;
+ case 4: tmpfunc->Dispatch(LFUN_COPY); break;
+ case 5: tmpfunc->Dispatch(LFUN_PASTE); break;
+ case 6: tmpfunc->Dispatch(LFUN_MENUSEARCH); break;
+ case 7: tmpfunc->Dispatch(LFUN_GOTOERROR); break;
+ case 8: tmpfunc->Dispatch(LFUN_GOTONOTE); break;
+ case 9: // floats & insets
+ break;
+ case 10:// table
+ break;
+ case 11: tmpfunc->Dispatch(LFUN_SPELLCHECK); break;
+ case 12: tmpfunc->Dispatch(LFUN_RUNCHKTEX); break;
+ case 13: tmpfunc->Dispatch(LFUN_TOCVIEW); break;
+ case 14: // version control
+ break;
+ case 15: tmpfunc->Dispatch(LFUN_LATEX_LOG); break;
+ case 16: tmpfunc->Dispatch(LFUN_PASTESELECTION, "line"); break;
+ case 17: tmpfunc->Dispatch(LFUN_PASTESELECTION, "paragraph"); break;
+
+ // floats & insets sub-menu
+ case 21: ToggleFloat(); break;
+ case 22: tmpfunc->Dispatch(LFUN_MELT); break;
+ case 23: AllFloats(1, 0); break;
+ case 24: AllFloats(0, 0); break;
+ case 25: AllFloats(1, 1); break;
+ case 26: AllFloats(0, 1); break;
+ case 27: tmpfunc->Dispatch(LFUN_REMOVEERRORS); break;
+
+ case 31: tmpfunc->Dispatch(LFUN_TABLE); break;
+ // this is really temporary. We need new function in keybind.C
+ // These should set the minibuffer, too.
+ case 32: case 33: case 34:
+ case 35: case 36: case 37:
+ case 38: case 39: case 40:
+ case 41: case 42: case 43:
+ case 44:
+ if (men->currentView()->available()){
+ men->currentView()->getScreen()->HideCursor();
+ if (!men->currentView()->text->selection){
+ BeforeChange();
+ men->currentView()->update(-2);
+ }
+ men->currentView()->text->
+ TableFeatures(choice - 32);
+ men->currentView()->update(1);
+ }
+ break;
+ // version control sub-menu
+ case 51: // register
+ tmpfunc->Dispatch(LFUN_VC_REGISTER);
+ break;
+ case 52: // check in
+ tmpfunc->Dispatch(LFUN_VC_CHECKIN);
+ break;
+ case 53: // check out
+ tmpfunc->Dispatch(LFUN_VC_CHECKOUT);
+ break;
+ case 54: // revert to last
+ tmpfunc->Dispatch(LFUN_VC_REVERT);
+ break;
+ case 55: // undo last
+ tmpfunc->Dispatch(LFUN_VC_UNDO);
+ break;
+ case 56: // show history
+ tmpfunc->Dispatch(LFUN_VC_HISTORY);
+ break;
+ }
+
+ fl_freepup(EditMenu);
+ fl_freepup(SubEditFloats);
+ fl_freepup(SubEditTable);
+ fl_freepup(SubVersionControl);
+}
+#else
void Menus::ShowEditMenu(FL_OBJECT * ob, long)
{
Menus * men = static_cast<Menus*>(ob->u_vdata);
fl_freepup(SubEditTable);
fl_freepup(SubVersionControl);
}
+#endif
void Menus::ShowLayoutMenu(FL_OBJECT * ob, long)
fl_setpup_shortcut(LayoutMenu, 13, scex(_("LM|Ss#s#S")));
// Set values of checkboxes according to font
+#ifdef MOVE_TEXT
+ LyXFont font = men->currentView()->text->real_current_font;
+#else
LyXFont font = tmpbuffer->text->real_current_font;
+#endif
if (font.emph() == LyXFont::ON)
fl_setpup_mode(LayoutMenu, 7, FL_PUP_CHECK);
if (font.noun() == LyXFont::ON)
fl_setpup_mode(LayoutMenu, 10, FL_PUP_CHECK);
// Grey out unavailable entries
+#ifdef MOVE_TEXT
+ if (!men->currentView()->text->cursor.par->table)
+ fl_setpup_mode(LayoutMenu, 5, FL_PUP_GREY);
+#else
if (!tmpbuffer->text->cursor.par->table)
fl_setpup_mode(LayoutMenu, 5, FL_PUP_GREY);
+#endif
if (tmpbuffer->isReadonly()) {
fl_setpup_mode(LayoutMenu, 1, FL_PUP_GREY);
show_symbols_form(tmpfunc);
break;
}
- tmpbuffer->update(0);
+ men->currentView()->update(0);
}
fl_freepup(MathMenu);
}
else if (owner->view()->available()) {
string nicename =
MakeDisplayPath(owner->buffer()->
- getFileName());
+ fileName());
// Should we do this instead? (kindo like emacs)
// leaves more room for other information
text = "LyX: ";
}
break;
case KMAP: {
- char key_from;
+ unsigned char key_from;
char * string_to;
if (lyxerr.debugging(Debug::KBMAP))
if (lex.next(true)) {
char const * t = lex.text();
string_to = strcpy(new char[strlen(t)+1], t);
- if (key_from == char(254))
+ if (key_from == 254)
lyxerr << "check two triggered"
<< endl;
keymap_[key_from] = string_to;
char * dt = dummy;
char * t = Match(c);
- if ((t == 0 && (dt[0] = c)) || (t[0] != 0 && (dt = t)) ){
+ if ((t == 0 && (*dt = c)) || (t[0] != 0 && (dt = t)) ){
return k.normalkey(c, dt);
} else {
return k.deadkey(c, *kmod_list_[(tex_accent)t[1]]);
char const TransState::TOKEN_SEP = 4;
-TransState::~TransState() {}
-
-
// TransInitState
TransInitState::TransInitState()
{
string TransInitState::normalkey(char c, char * t)
{
string res;
- if (t!= 0)
+ if (t != 0)
res = t;
else
res = c;
// Third key in a row. Output the first one and
// reenter with shifted deadkeys
string res;
- if (deadkey_!= 0)
+ if (deadkey_ != 0)
res = deadkey_;
- res+= TOKEN_SEP;
+ res += TOKEN_SEP;
deadkey_ = deadkey2_;
deadkey_info_ = deadkey2_info_;
- res+= deadkey_state_->deadkey(c, d);
+ res += deadkey_state_->deadkey(c, d);
return res;
}
// encoding (chset_->name()) matches the current font_norm
// (lyrxc->font_norm
- if (chset_.getName()!= lyxrc->font_norm ||
+ if (chset_.getName() != lyxrc->font_norm ||
chset_.encodeString(str) == false) {
// Could not find an encoding
InsetLatexAccent ins(str);
KmodInfo i;
string res;
- if (c == 0 && active_!= default_) {
+ if (c == 0 && active_ != default_) {
// A deadkey was pressed that cannot be printed
// or a accent command was typed in the minibuffer
class TransState {
public:
///
- virtual ~TransState();
+ virtual ~TransState() {}
///
virtual string normalkey(char, char *) = 0;
///
inline string normalkey(char, char *);
///
void deadkey(char, tex_accent, LyXText *);
-
};
string cmd = "ci -q -u -i -t-\"";
cmd += msg;
cmd += "\" \"";
- cmd += OnlyFilename(owner_->getFileName());
+ cmd += OnlyFilename(owner_->fileName());
cmd += "\"";
doVCCommand(cmd);
owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload");
void RCS::checkIn(string const & msg)
{
doVCCommand("ci -q -u -m\"" + msg + "\" \""
- + OnlyFilename(owner_->getFileName()) + "\"");
+ + OnlyFilename(owner_->fileName()) + "\"");
owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload");
}
{
owner_->markLyxClean();
doVCCommand("co -q -l \""
- + OnlyFilename(owner_->getFileName()) + "\"");
+ + OnlyFilename(owner_->fileName()) + "\"");
owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload");
}
void RCS::revert()
{
doVCCommand("co -f -u" + version() + " \""
- + OnlyFilename(owner_->getFileName()) + "\"");
+ + OnlyFilename(owner_->fileName()) + "\"");
// We ignore changes and just reload!
owner_->markLyxClean();
owner_->getUser()->owner()
{
lyxerr[Debug::LYXVC] << "LyXVC: undoLast" << endl;
doVCCommand("rcs -o" + version() + " \""
- + OnlyFilename(owner_->getFileName()) + "\"");
+ + OnlyFilename(owner_->fileName()) + "\"");
}
void RCS::getLog(string const & tmpf)
{
doVCCommand("rlog \""
- + OnlyFilename(owner_->getFileName()) + "\" > " + tmpf);
+ + OnlyFilename(owner_->fileName()) + "\" > " + tmpf);
}
void CVS::registrer(string const & msg)
{
doVCCommand("cvs -q add -m \"" + msg + "\" \""
- + OnlyFilename(owner_->getFileName()) + "\"");
+ + OnlyFilename(owner_->fileName()) + "\"");
owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload");
}
void CVS::checkIn(string const & msg)
{
doVCCommand("cvs -q commit -m \"" + msg + "\" \""
- + OnlyFilename(owner_->getFileName()) + "\"");
+ + OnlyFilename(owner_->fileName()) + "\"");
owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload");
}
int VSpace::inPixels() const
{
// Height of a normal line in pixels (zoom factor considered)
+#ifdef MOVE_TEXT
+ int height = current_view->text->DefaultHeight(); // [pixels]
+#else
int height = current_view->buffer()->text->DefaultHeight(); // [pixels]
+#endif
// Zoom factor specified by user in percent
float const zoom = lyxrc->zoom / 100.0; // [percent]