use more explicit on constructors use the pimpl idom to reduce size with about 500k

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@641 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2000-04-08 17:02:02 +00:00
parent 1a0b18b01c
commit 76938908d7
80 changed files with 1887 additions and 1406 deletions

View File

@ -1,3 +1,24 @@
2000-04-08 Lars Gullik Bjønnes <larsbj@lyx.org>
* src/WorkArea.C (belowMouse): manually implement below mouse.
* src/*: Add "explicit" on several constructors, I added probably
some unneeded ones. A couple of changes to code because of this.
* src/BufferView.[Ch]: Used the "pimpl" idom to hide more of the
implementation and private parts from the users of BufferView. Not
quite finished.
* src/lyxlex.[Ch]: Used the "pimpl" idom to hide more of the
implementaaion and private parts from the users of LyXLex. Not
quite finished.
* src/BufferView_pimpl.[Ch]: new files
* src/lyxlex_pimpl.[Ch]: new files
* src/LyXView.[Ch]: some inline functios move out-of-line
2000-04-04 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/lyxparagraph.h: make strict InsetTable public.

File diff suppressed because it is too large Load Diff

View File

@ -17,17 +17,11 @@
#endif
#include FORMS_H_LOCATION
#include "BackStack.h"
#include "LaTeX.h"
#include "undo.h"
#include "UpdateInset.h"
class LyXView;
class Buffer;
class LyXScreen;
class Inset;
class LyXText;
class WorkArea;
class TeXErrors;
///
class BufferView {
@ -37,7 +31,7 @@ public:
///
~BufferView();
///
Buffer * buffer() const { return buffer_; }
Buffer * buffer() const;
///
Painter & painter();
///
@ -73,7 +67,7 @@ public:
///
bool available() const;
///
LyXView * owner() const { return owner_; }
LyXView * owner() const;
///
void beforeChange();
///
@ -190,27 +184,6 @@ public:
///
void center();
private:
friend class WorkArea;
/// Update pixmap of screen
void updateScreen();
///
void workAreaExpose();
///
void scrollUpOnePage();
///
void scrollDownOnePage();
///
void create_view();
///
Inset * checkInsetHit(int & x, int & y, unsigned int button);
///
int scrollUp(long time);
///
int scrollDown(long time);
public:
///
bool focus() const;
///
@ -232,48 +205,25 @@ public:
///
void setState();
private:
///
void workAreaMotionNotify(int x, int y, unsigned int state);
void pushIntoUpdateList(Inset * i);
///
void workAreaExpose();
///
void workAreaButtonPress(int x, int y, unsigned int button);
///
void workAreaButtonRelease(int x, int y, unsigned int button);
///
void workAreaSelectionNotify(Window win, XEvent * event);
void workAreaMotionNotify(int x, int y, unsigned int state);
///
void doubleClick(int x, int y, unsigned int button);
///
void tripleClick(int x, int y, unsigned int button);
///
LyXView * owner_;
///
Buffer * buffer_;
///
LyXScreen * screen;
///
long current_scrollbar_value;
///
bool lyx_focus;
///
bool work_area_focus;
///
FL_OBJECT * figinset_canvas;
///
FL_OBJECT * timer_cursor;
///
BackStack backstack;
///
int last_click_x, last_click_y;
///
WorkArea * workarea;
///
UpdateInset updatelist;
public:
///
void pushIntoUpdateList(Inset * i) {
updatelist.push(i);
}
void workAreaSelectionNotify(Window win, XEvent * event);
private:
struct Pimpl;
Pimpl * pimpl_;
};
#endif

View File

@ -11,6 +11,8 @@
#include <config.h>
#include <fstream>
#include "BufferView.h"
#include "buffer.h"
#include "lyxcursor.h"
@ -23,6 +25,10 @@
#include "bufferlist.h"
#include "support/FileInfo.h"
#include "lyxscreen.h"
#include "support/filetools.h"
#include "lyx_gui_misc.h"
#include "LaTeX.h"
#include "BufferView_pimpl.h"
extern BufferList bufferlist;
@ -734,7 +740,7 @@ void BufferView::showLockedInsetCursor(long x, long y, int asc, int desc)
{
if (the_locking_inset && available()) {
y += text->cursor.y;
screen->ShowManualCursor(x, y, asc, desc,
pimpl_->screen->ShowManualCursor(x, y, asc, desc,
LyXScreen::BAR_SHAPE);
}
}
@ -743,7 +749,7 @@ void BufferView::showLockedInsetCursor(long x, long y, int asc, int desc)
void BufferView::hideLockedInsetCursor()
{
if (the_locking_inset && available()) {
screen->HideCursor();
pimpl_->screen->HideCursor();
}
}
@ -752,7 +758,7 @@ void BufferView::fitLockedInsetCursor(long x, long y, int asc, int desc)
{
if (the_locking_inset && available()){
y += text->cursor.y;
if (screen->FitManualCursor(x, y, asc, desc))
if (pimpl_->screen->FitManualCursor(x, y, asc, desc))
updateScrollbar();
}
}

752
src/BufferView_pimpl.C Normal file
View File

@ -0,0 +1,752 @@
#include <config.h>
//#include <utility>
#ifdef __GNUG__
#pragma implementation
#endif
#include "BufferView_pimpl.h"
#include "WorkArea.h"
#include "lyxscreen.h"
#include "lyxtext.h"
#include "lyxrow.h"
#include "LyXView.h"
#include "commandtags.h"
#include "lyxfunc.h"
#include "minibuffer.h"
#include "font.h"
#include "lyx_cb.h"
#include "TextCache.h"
#include "bufferlist.h"
#include "insets/insetbib.h"
using std::pair;
extern BufferList bufferlist;
extern bool selection_possible;
extern char ascii_type;
extern int bibitemMaxWidth(Painter &, LyXFont const &);
extern "C"
void C_BufferView_CursorToggleCB(FL_OBJECT * ob, long buf);
BufferView::Pimpl::Pimpl(BufferView * b, LyXView * o,
int xpos, int ypos, int width, int height)
: bv_(b), owner_(o)
{
buffer_ = 0;
workarea = new WorkArea(bv_, xpos, ypos, width, height);
screen = 0;
timer_cursor = 0;
create_view();
current_scrollbar_value = 0;
fl_set_timer(timer_cursor, 0.4);
workarea->setFocus();
work_area_focus = true;
lyx_focus = false;
}
void BufferView::Pimpl::updateScreen()
{
// Regenerate the screen.
delete screen;
screen = new LyXScreen(*workarea, bv_->text);
}
void BufferView::Pimpl::create_view()
{
FL_OBJECT * obj;
//
// TIMERS
//
// timer_cursor
timer_cursor = obj = fl_add_timer(FL_HIDDEN_TIMER,
0, 0, 0, 0, "Timer");
fl_set_object_callback(obj, C_BufferView_CursorToggleCB, 0);
obj->u_vdata = bv_;
}
int BufferView::Pimpl::scrollUp(long time)
{
if (buffer_ == 0) return 0;
if (!screen) return 0;
double value = workarea->getScrollbarValue();
if (value == 0) return 0;
float add_value = (bv_->text->DefaultHeight()
+ float(time) * float(time) * 0.125);
if (add_value > workarea->height())
add_value = float(workarea->height() -
bv_->text->DefaultHeight());
value -= add_value;
if (value < 0)
value = 0;
workarea->setScrollbarValue(value);
bv_->scrollCB(value);
return 0;
}
int BufferView::Pimpl::scrollDown(long time)
{
if (buffer_ == 0) return 0;
if (!screen) return 0;
double value= workarea->getScrollbarValue();
pair<double, double> p = workarea->getScrollbarBounds();
double max = p.second;
if (value == max) return 0;
float add_value = (bv_->text->DefaultHeight()
+ float(time) * float(time) * 0.125);
if (add_value > workarea->height())
add_value = float(workarea->height() -
bv_->text->DefaultHeight());
value += add_value;
if (value > max)
value = max;
workarea->setScrollbarValue(value);
bv_->scrollCB(value);
return 0;
}
void BufferView::Pimpl::scrollUpOnePage()
{
if (buffer_ == 0) return;
if (!screen) return;
long y = screen->first;
if (!y) return;
Row * row = bv_->text->GetRowNearY(y);
y = y - workarea->height() + row->height;
workarea->setScrollbarValue(y);
bv_->scrollCB(y);
}
void BufferView::Pimpl::scrollDownOnePage()
{
if (buffer_ == 0) return;
if (!screen) return;
long y = screen->first;
if (y > bv_->text->height - workarea->height())
return;
y += workarea->height();
bv_->text->GetRowNearY(y);
workarea->setScrollbarValue(y);
bv_->scrollCB(y);
}
void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
{
if (buffer_ == 0 || !screen) return;
// Check for inset locking
if (bv_->the_locking_inset) {
LyXCursor cursor = bv_->text->cursor;
bv_->the_locking_inset->
InsetMotionNotify(bv_,
x - cursor.x,
y - cursor.y,
state);
return;
}
// Only use motion with button 1
if (!state & Button1MotionMask)
return;
/* The selection possible is needed, that only motion events are
* used, where the bottom press event was on the drawing area too */
if (selection_possible) {
screen->HideCursor();
bv_->text->SetCursorFromCoordinates(x, y + screen->first);
if (!bv_->text->selection)
bv_->update(-3); // Maybe an empty line was deleted
bv_->text->SetSelection();
screen->ToggleToggle();
if (screen->FitCursor())
bv_->updateScrollbar();
screen->ShowCursor();
}
return;
}
// Single-click on work area
void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, unsigned int button)
{
last_click_x = -1;
last_click_y = -1;
if (buffer_ == 0 || !screen) return;
Inset * inset_hit = checkInsetHit(xpos, ypos, button);
// ok ok, this is a hack.
if (button == 4 || button == 5) {
switch (button) {
case 4:
scrollUp(100); // This number is only temporary
break;
case 5:
scrollDown(100);
break;
}
}
if (bv_->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 == bv_->the_locking_inset) {
bv_->the_locking_inset->
InsetButtonPress(bv_,
xpos, ypos,
button);
return;
} else {
bv_->unlockInset(bv_->the_locking_inset);
}
}
if (!inset_hit)
selection_possible = true;
screen->HideCursor();
// Right button mouse click on a table
if (button == 3 &&
(bv_->text->cursor.par->table ||
bv_->text->MouseHitInTable(xpos, ypos + screen->first))) {
// Set the cursor to the press-position
bv_->text->SetCursorFromCoordinates(xpos, ypos + screen->first);
bool doit = true;
// Only show the table popup if the hit is in
// the table, too
if (!bv_->text->HitInTable(bv_->text->cursor.row, xpos))
doit = false;
// Hit above or below the table?
if (doit) {
if (!bv_->text->selection) {
screen->ToggleSelection();
bv_->text->ClearSelection();
bv_->text->FullRebreak();
screen->Update();
bv_->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;
}
}
int screen_first = screen->first;
// Middle button press pastes if we have a selection
bool paste_internally = false;
if (button == 2
&& bv_->text->selection) {
owner_->getLyXFunc()->Dispatch(LFUN_COPY);
paste_internally = true;
}
// Clear the selection
screen->ToggleSelection();
bv_->text->ClearSelection();
bv_->text->FullRebreak();
screen->Update();
bv_->updateScrollbar();
// Single left click in math inset?
if ((inset_hit != 0) &&
(inset_hit->Editable()==Inset::HIGHLY_EDITABLE)) {
// Highly editable inset, like math
UpdatableInset * inset = static_cast<UpdatableInset *>(inset_hit);
selection_possible = false;
owner_->updateLayoutChoice();
owner_->getMiniBuffer()->Set(inset->EditMessage());
inset->InsetButtonPress(bv_, xpos, ypos, button);
inset->Edit(bv_, xpos, ypos, button);
return;
}
// Right click on a footnote flag opens float menu
if (button == 3) {
selection_possible = false;
return;
}
if (!inset_hit) // otherwise it was already set in checkInsetHit(...)
bv_->text->SetCursorFromCoordinates(xpos, ypos + screen_first);
bv_->text->FinishUndo();
bv_->text->sel_cursor = bv_->text->cursor;
bv_->text->cursor.x_fix = bv_->text->cursor.x;
owner_->updateLayoutChoice();
if (screen->FitCursor()){
bv_->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) {
if (paste_internally)
owner_->getLyXFunc()->Dispatch(LFUN_PASTE);
else
owner_->getLyXFunc()->Dispatch(LFUN_PASTESELECTION,
"paragraph");
selection_possible = false;
return;
}
}
void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, unsigned int button)
{
// select a word
if (buffer_ && !bv_->the_locking_inset) {
if (screen && button == 1) {
screen->HideCursor();
screen->ToggleSelection();
bv_->text->SelectWord();
screen->ToggleSelection(false);
/* This will fit the cursor on the screen
* if necessary */
bv_->update(0);
}
}
}
void BufferView::Pimpl::tripleClick(int /*x*/, int /*y*/, unsigned int button)
{
// select a line
if (buffer_ && screen && button == 1) {
screen->HideCursor();
screen->ToggleSelection();
bv_->text->CursorHome();
bv_->text->sel_cursor = bv_->text->cursor;
bv_->text->CursorEnd();
bv_->text->SetSelection();
screen->ToggleSelection(false);
/* This will fit the cursor on the screen
* if necessary */
bv_->update(0);
}
}
void BufferView::Pimpl::workAreaButtonRelease(int x, int y, unsigned int button)
{
if (buffer_ == 0 || screen == 0) return;
// 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.
Inset * inset_hit = checkInsetHit(x, y, button);
if (bv_->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. */
bv_->the_locking_inset->
InsetButtonRelease(bv_, x, y, button);
return;
}
selection_possible = false;
if (bv_->text->cursor.par->table) {
int cell = bv_->text->
NumberOfCell(bv_->text->cursor.par,
bv_->text->cursor.pos);
if (bv_->text->cursor.par->table->IsContRow(cell) &&
bv_->text->cursor.par->table->
CellHasContRow(bv_->text->cursor.par->table->
GetCellAbove(cell))<0) {
bv_->text->CursorUp();
}
}
if (button >= 2) return;
bv_->setState();
owner_->getMiniBuffer()->Set(CurrentState());
// 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) {
bv_->text->SetCursorParUndo();
}
owner_->getMiniBuffer()->Set(inset_hit->EditMessage());
if (inset_hit->Editable()==Inset::HIGHLY_EDITABLE) {
// Highly editable inset, like math
UpdatableInset *inset = (UpdatableInset *)inset_hit;
inset->InsetButtonRelease(bv_, x, y, button);
} else {
inset_hit->Edit(bv_, x, y, button);
}
return;
}
// check whether we want to open a float
if (bv_->text) {
bool hit = false;
char c = ' ';
if (bv_->text->cursor.pos <
bv_->text->cursor.par->Last()) {
c = bv_->text->cursor.par->
GetChar(bv_->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 (bv_->text->cursor.pos - 1 >= 0) {
c = bv_->text->cursor.par->
GetChar(bv_->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
bv_->text->CursorLeft();
hit = true;
}
}
if (hit == true) {
bv_->toggleFloat();
selection_possible = false;
return;
}
}
// Do we want to close a float? (click on the float-label)
if (bv_->text->cursor.row->par->footnoteflag ==
LyXParagraph::OPEN_FOOTNOTE
//&& text->cursor.pos == 0
&& bv_->text->cursor.row->previous &&
bv_->text->cursor.row->previous->par->
footnoteflag != LyXParagraph::OPEN_FOOTNOTE){
LyXFont font(LyXFont::ALL_SANE);
font.setSize(LyXFont::SIZE_FOOTNOTE);
int box_x = 20; // LYX_PAPER_MARGIN;
box_x += lyxfont::width(" wide-tab ", font);
int screen_first = screen->first;
if (x < box_x
&& y + screen_first > bv_->text->cursor.y -
bv_->text->cursor.row->baseline
&& y + screen_first < bv_->text->cursor.y -
bv_->text->cursor.row->baseline
+ lyxfont::maxAscent(font) * 1.2 + lyxfont::maxDescent(font) * 1.2) {
bv_->toggleFloat();
selection_possible = false;
return;
}
}
// Maybe we want to edit a bibitem ale970302
if (bv_->text->cursor.par->bibkey && x < 20 +
bibitemMaxWidth(bv_->painter(),
textclasslist
.TextClass(buffer_->
params.textclass).defaultfont())) {
bv_->text->cursor.par->bibkey->Edit(bv_, 0, 0, 0);
}
return;
}
/*
* 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.
*/
Inset * BufferView::Pimpl::checkInsetHit(int & x, int & y, unsigned int button)
{
if (!screen)
return 0;
int y_tmp = y + screen->first;
LyXCursor cursor;
bv_->text->SetCursorFromCoordinates(cursor, x, y_tmp);
#if 1
bool move_cursor = true;
#else
bool move_cursor = ((cursor.par != bv_->text->cursor.par) ||
(cursor.pos != bv_->text->cursor.pos)) && (button < 2);
#endif
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 = bv_->text->GetFont(cursor.par, cursor.pos);
bool is_rtl = font.isVisibleRightToLeft();
int start_x, end_x;
if (is_rtl) {
start_x = cursor.x - tmpinset->width(bv_->painter(), font);
end_x = cursor.x;
} else {
start_x = cursor.x;
end_x = cursor.x + tmpinset->width(bv_->painter(), font);
}
if (x > start_x && x < end_x
&& y_tmp > cursor.y - tmpinset->ascent(bv_->painter(), font)
&& y_tmp < cursor.y + tmpinset->descent(bv_->painter(), font)) {
if (move_cursor)
bv_->text->SetCursorFromCoordinates(x, y_tmp);
x = x - start_x;
// The origin of an inset is on the baseline
y = y_tmp - (bv_->text->cursor.y);
return tmpinset;
}
}
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())) {
Inset * tmpinset = cursor.par->GetInset(cursor.pos-1);
LyXFont font = bv_->text->GetFont(cursor.par, cursor.pos-1);
bool is_rtl = font.isVisibleRightToLeft();
int start_x, end_x;
if (!is_rtl) {
start_x = cursor.x - tmpinset->width(bv_->painter(), font);
end_x = cursor.x;
} else {
start_x = cursor.x;
end_x = cursor.x + tmpinset->width(bv_->painter(), font);
}
if (x > start_x && x < end_x
&& y_tmp > cursor.y - tmpinset->ascent(bv_->painter(), font)
&& y_tmp < cursor.y + tmpinset->descent(bv_->painter(), font)) {
if (move_cursor)
bv_->text->SetCursorFromCoordinates(x, y_tmp);
x = x - start_x;
// The origin of an inset is on the baseline
y = y_tmp - (bv_->text->cursor.y);
return tmpinset;
}
}
return 0;
}
void BufferView::Pimpl::workAreaExpose()
{
// this is a hack to ensure that we only call this through
// BufferView::redraw().
//if (!lgb_hack) {
// redraw();
//}
static int work_area_width = -1;
static int work_area_height = -1;
bool widthChange = workarea->workWidth() != work_area_width;
bool heightChange = workarea->height() != work_area_height;
// update from work area
work_area_width = workarea->workWidth();
work_area_height = workarea->height();
if (buffer_ != 0) {
if (widthChange) {
// All buffers need a resize
bufferlist.resize();
// Remove all texts from the textcache
// This is not _really_ what we want to do. What
// we really want to do is to delete in textcache
// that does not have a BufferView with matching
// width, but as long as we have only one BufferView
// deleting all gives the same result.
if (lyxerr.debugging())
textcache.show(lyxerr, "Expose delete all");
textcache.clear();
} else if (heightChange) {
// Rebuild image of current screen
updateScreen();
// fitCursor() ensures we don't jump back
// to the start of the document on vertical
// resize
bv_->fitCursor();
// The main window size has changed, repaint most stuff
bv_->redraw();
// ...including the minibuffer
owner_->getMiniBuffer()->Init();
} else if (screen) screen->Redraw();
} else {
// Grey box when we don't have a buffer
workarea->greyOut();
}
// always make sure that the scrollbar is sane.
bv_->updateScrollbar();
owner_->updateLayoutChoice();
return;
}
static
string fromClipboard(Window win, XEvent * event)
{
string strret;
if (event->xselection.type == XA_STRING
&& event->xselection.property) {
Atom tmpatom;
unsigned long ul1;
unsigned long ul2;
unsigned char * uc = 0;
int tmpint;
if (XGetWindowProperty(
event->xselection.display, // display
win, // w
event->xselection.property, // property
0, // long_offset
0, // logn_length
False, // delete
XA_STRING, // req_type
&tmpatom, // actual_type_return
&tmpint, // actual_format_return
&ul1,
&ul2,
&uc // prop_return
) != Success) {
return strret;
}
if (uc) {
free(uc);
uc = 0;
}
if (XGetWindowProperty(
event->xselection.display, // display
win, // w
event->xselection.property, // property
0, // long_offset
ul2/4+1, // long_length
True, // delete
XA_STRING, // req_type
&tmpatom, // actual_type_return
&tmpint, // actual_format_return
&ul1, // nitems_return
&ul2, // bytes_after_return
&uc // prop_return */
) != Success) {
return strret;
}
if (uc) {
strret = reinterpret_cast<char*>(uc);
free(uc); // yes free!
uc = 0;
}
}
return strret;
}
void BufferView::Pimpl::workAreaSelectionNotify(Window win, XEvent * event)
{
if (buffer_ == 0) return;
screen->HideCursor();
bv_->beforeChange();
string clb = fromClipboard(win, event);
if (!clb.empty()) {
if (!ascii_type)
bv_->text->InsertStringA(clb);
else
bv_->text->InsertStringB(clb);
bv_->update(1);
}
}

77
src/BufferView_pimpl.h Normal file
View File

@ -0,0 +1,77 @@
// -*- C++ -*-
#ifndef BUFFERVIEW_PIMPL_H
#define BUFFERVIEW_PIMPL_H
#include "BufferView.h"
#include "UpdateInset.h"
#include "BackStack.h"
#ifdef __GNUG__
#pragma interface
#endif
class LyXView;
class WorkArea;
class LyXScreen;
struct BufferView::Pimpl {
Pimpl(BufferView * i, LyXView * o,
int xpos, int ypos, int width, int height);
/// Update pixmap of screen
void updateScreen();
///
void workAreaExpose();
///
void scrollUpOnePage();
///
void scrollDownOnePage();
///
void create_view();
///
Inset * checkInsetHit(int & x, int & y, unsigned int button);
///
int scrollUp(long time);
///
int scrollDown(long time);
///
void workAreaMotionNotify(int x, int y, unsigned int state);
///
void workAreaButtonPress(int x, int y, unsigned int button);
///
void workAreaButtonRelease(int x, int y, unsigned int button);
///
void workAreaSelectionNotify(Window win, XEvent * event);
///
void doubleClick(int x, int y, unsigned int button);
///
void tripleClick(int x, int y, unsigned int button);
///
BufferView * bv_;
///
LyXView * owner_;
///
Buffer * buffer_;
///
LyXScreen * screen;
///
long current_scrollbar_value;
///
bool lyx_focus;
///
bool work_area_focus;
///
FL_OBJECT * figinset_canvas;
///
FL_OBJECT * timer_cursor;
///
BackStack backstack;
///
int last_click_x, last_click_y;
///
WorkArea * workarea;
///
UpdateInset updatelist;
};
#endif

View File

@ -27,10 +27,10 @@
class Bullet {
public:
///
Bullet(const int f = -1, const int c = -1, const int s = -1);
Bullet(int f = -1, int c = -1, int s = -1);
///
Bullet(string const &);
explicit Bullet(string const &);
///
void setCharacter(int);

View File

@ -30,8 +30,8 @@ public:
FontInfo() { init(); }
///
FontInfo(string const & pat)
: pattern(pat) { init(); }
explicit FontInfo(string const & pat)
: pattern(pat) { init(); }
/// Destructor
~FontInfo() { release(); }

View File

@ -29,7 +29,7 @@ public:
/**
file = name and path of the latex file
*/
ImportLaTeX(string const & file);
explicit ImportLaTeX(string const & file);
/** Imports the document.
Return 0 if fail.

View File

@ -29,7 +29,7 @@ public:
/**
file = name and path of the noweb file to import
*/
ImportNoweb(string const & file) : file(file) {}
explicit ImportNoweb(string const & file) : file(file) {}
/** Imports the document.
Return 0 if fail.

View File

@ -33,7 +33,7 @@ struct Language;
in buffer.C and paragraph.C when you do so. */
struct LaTeXFeatures {
///
LaTeXFeatures(int n) ;
explicit LaTeXFeatures(int n) ;
/// The packaes needed by the document
string getPackages(BufferParams const & params);
/// The macros definitions needed by the document

View File

@ -32,6 +32,8 @@
#include "support/filetools.h" // OnlyFilename()
#include "layout.h"
#include "lyxtext.h"
#include "buffer.h"
#include "menus.h"
using std::endl;
@ -50,7 +52,7 @@ extern "C" int C_LyXView_atCloseMainFormCB(FL_FORM *, void *);
LyXView::LyXView(int width, int height)
{
create_form_form_main(width, height);
fl_set_form_atclose(_form, C_LyXView_atCloseMainFormCB, 0);
fl_set_form_atclose(form_, C_LyXView_atCloseMainFormCB, 0);
lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl;
lyxfunc = new LyXFunc(this);
intl = new Intl;
@ -71,11 +73,66 @@ LyXView::~LyXView()
/// Redraw the main form.
void LyXView::redraw() {
lyxerr[Debug::INFO] << "LyXView::redraw()" << endl;
fl_redraw_form(_form);
fl_redraw_form(form_);
minibuffer->Activate();
}
/// returns the buffer currently shown in the main form.
Buffer * LyXView::buffer() const
{
return bufferview->buffer();
}
BufferView * LyXView::view() const
{
return bufferview;
}
FD_form_main * LyXView::getMainForm() const
{
return form_main_;
}
FL_FORM * LyXView::getForm() const
{
return form_;
}
Toolbar * LyXView::getToolbar() const
{
return toolbar;
}
LyXFunc * LyXView::getLyXFunc() const
{
return lyxfunc;
}
MiniBuffer * LyXView::getMiniBuffer() const
{
return minibuffer;
}
Menus * LyXView::getMenus() const
{
return menus;
}
Intl * LyXView::getIntl() const
{
return intl;
}
// Callback for update timer
void LyXView::UpdateTimerCB(FL_OBJECT * ob, long)
{
@ -120,7 +177,7 @@ extern "C" void C_LyXView_AutosaveTimerCB(FL_OBJECT * ob, long data)
void LyXView::resetAutosaveTimer()
{
if (lyxrc.autosave)
fl_set_timer(_form_main->timer_autosave, lyxrc.autosave);
fl_set_timer(form_main_->timer_autosave, lyxrc.autosave);
}
@ -141,15 +198,15 @@ extern "C" int C_LyXView_atCloseMainFormCB(FL_FORM * form, void * p)
void LyXView::setPosition(int x, int y)
{
fl_set_form_position(_form, x, y);
fl_set_form_position(form_, x, y);
}
void LyXView::show(int place, int border, char const * title)
{
fl_show_form(_form, place, border, title);
fl_show_form(form_, place, border, title);
minibuffer->Init();
InitLyXLookup(fl_display, _form->window);
InitLyXLookup(fl_display, form_->window);
}
@ -165,10 +222,10 @@ void LyXView::create_form_form_main(int width, int height)
FD_form_main * fdui = static_cast<FD_form_main *>
(fl_calloc(1, sizeof(FD_form_main)));
_form_main = fdui;
form_main_ = fdui;
// the main form
_form = fdui->form_main = fl_bgn_form(FL_NO_BOX, width, height);
form_ = fdui->form_main = fl_bgn_form(FL_NO_BOX, width, height);
fdui->form_main->u_vdata = this;
FL_OBJECT * obj = fl_add_box(FL_FLAT_BOX, 0, 0, width, height, "");
fl_set_object_color(obj, FL_MCOL, FL_MCOL);
@ -260,11 +317,11 @@ void LyXView::init()
// Start autosave timer
if (lyxrc.autosave)
fl_set_timer(_form_main->timer_autosave, lyxrc.autosave);
fl_set_timer(form_main_->timer_autosave, lyxrc.autosave);
// Install the raw callback for keyboard events
fl_register_raw_callback(_form,
fl_register_raw_callback(form_,
KeyPressMask,
C_LyXView_KeyPressMask_raw_callback);
intl->InitKeyMapper(lyxrc.use_kbmap);
@ -411,7 +468,7 @@ void LyXView::updateWindowTitle()
}
// Don't update title if it's the same as last time
if (title != last_title) {
fl_set_form_title(_form, title.c_str());
fl_set_form_title(form_, title.c_str());
last_title = title;
}
}

View File

@ -17,13 +17,14 @@
#endif
#include FORMS_H_LOCATION
#include "buffer.h"
#include "menus.h"
class LyXFunc;
class Toolbar;
class MiniBuffer;
class Intl;
class Buffer;
class Menus;
class BufferView;
///
struct FD_form_main {
@ -66,31 +67,31 @@ public:
void redraw();
/// returns the buffer currently shown in the main form.
Buffer * buffer() const { return bufferview->buffer(); }
Buffer * buffer() const;
///
BufferView * view() { return bufferview; }
BufferView * view() const;
/// returns a pointer to the main form.
FD_form_main * getMainForm() { return _form_main; }
FD_form_main * getMainForm() const;
/// returns a pointer to the form.
FL_FORM * getForm() { return _form; }
FL_FORM * getForm() const;
/// return a pointer to the toolbar
Toolbar * getToolbar() { return toolbar; }
Toolbar * getToolbar() const;
/// return a pointer to the lyxfunc
LyXFunc * getLyXFunc() { return lyxfunc; }
LyXFunc * getLyXFunc() const;
/// return a pointer to the minibuffer
MiniBuffer * getMiniBuffer() { return minibuffer; }
MiniBuffer * getMiniBuffer() const;
///
Menus * getMenus() { return menus; }
Menus * getMenus() const;
///
Intl * getIntl() { return intl; }
Intl * getIntl() const;
///
void updateLayoutChoice();
@ -134,9 +135,9 @@ private:
/// makes the main form.
void create_form_form_main(int width, int height);
/// A pointer to the form.
FD_form_main * _form_main;
FD_form_main * form_main_;
/// A pointer to the form.
FL_FORM * _form;
FL_FORM * form_;
/** The last textclass layout list in the layout choice selector
This should probably be moved to the toolbar, but for now it's

View File

@ -14,6 +14,8 @@ lyx_SOURCES = \
BufferView.C \
BufferView.h \
BufferView2.C \
BufferView_pimpl.C \
BufferView_pimpl.h \
Bullet.C \
Bullet.h \
Chktex.C \
@ -138,6 +140,8 @@ lyx_SOURCES = \
lyxfunc.h \
lyxlex.C \
lyxlex.h \
lyxlex_pimpl.C \
lyxlex_pimpl.h \
lyxlookup.C \
lyxlookup.h \
lyxparagraph.h \

View File

@ -35,7 +35,7 @@ class WorkArea;
class Painter : public PainterBase {
public:
/// Constructor
Painter(WorkArea &);
explicit Painter(WorkArea &);
/// Destructor
~Painter();

View File

@ -56,7 +56,7 @@ public:
};
///
PainterBase(WorkArea & wa) : owner(wa) {}
explicit PainterBase(WorkArea & wa) : owner(wa) {}
///
virtual ~PainterBase() {}

View File

@ -211,8 +211,22 @@ WorkArea::~WorkArea()
bool WorkArea::belowMouse() const
{
lyxerr << "Below mouse: " << work_area->belowmouse << endl;
return work_area->belowmouse;
FL_Coord x, y;
unsigned int button;
fl_get_mouse(&x, &y, &button);
FL_Coord ulx = work_area->form->x + work_area->x;
FL_Coord uly = work_area->form->y + work_area->y;
FL_Coord w = work_area->w;
FL_Coord h = work_area->h;
if (x > ulx && y > uly && x < ulx + h && y < uly + w)
return true;
return false;
//lyxerr << "Mouse: (" << x << ", " << y <<") button = " << button << endl;
//lyxerr << "Workarea: (" << work_area->x + work_area->form->x << ", " << work_area->y + work_area->form->y << ", " << work_area->w << ", " << work_area->h << ")" << endl;
//lyxerr << "Below mouse: " << work_area->belowmouse << endl;
//return work_area->belowmouse;
}

View File

@ -167,6 +167,26 @@ Buffer::~Buffer()
}
string Buffer::getLatexName(bool no_path = true) const
{
return ChangeExtension(MakeLatexName(filename),
".tex", no_path);
}
void Buffer::setReadonly(bool flag = true)
{
if (read_only != flag) {
read_only = flag;
updateTitles();
updateAllVisibleBufferRelatedPopups();
}
if (read_only) {
WarnReadonly(filename);
}
}
bool Buffer::saveParamsAsDefaults()
{
string fname = AddName(AddPath(user_lyxdir, "templates/"),
@ -716,10 +736,10 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
}
} else if (token == "\\added_space_top") {
lex.nextToken();
par->added_space_top = lex.GetString();
par->added_space_top = VSpace(lex.GetString());
} else if (token == "\\added_space_bottom") {
lex.nextToken();
par->added_space_bottom = lex.GetString();
par->added_space_bottom = VSpace(lex.GetString());
} else if (token == "\\pextra_type") {
lex.nextToken();
par->pextra_type = lex.GetInteger();

View File

@ -32,8 +32,7 @@
#include "lyxvc.h"
#include "bufferparams.h"
#include "texrow.h"
#include "support/filetools.h"
#include "lyx_gui_misc.h"
class LyXRC;
class TeXErrors;
@ -61,7 +60,7 @@ public:
/**@name Constructors and destructor */
//@{
///
Buffer(string const & file, bool b = false);
explicit Buffer(string const & file, bool b = false);
///
~Buffer();
@ -81,10 +80,10 @@ public:
/** high-level interface to buffer functionality
This function parses a command string and executes it
*/
void Dispatch(const string & command);
void Dispatch(string const & command);
/// Maybe we know the function already by number...
void Dispatch(int ac, const string & argument);
void Dispatch(int ac, string const & argument);
/// should be changed to work for a list.
void resize() {
@ -133,7 +132,7 @@ public:
/* This parses a single LyXformat-Token */
bool parseSingleLyXformat2Token(LyXLex &, LyXParagraph *& par,
LyXParagraph *& return_par,
const string & token, int & pos,
string const & token, int & pos,
char & depth, LyXFont &,
LyXParagraph::footnote_flag &,
LyXParagraph::footnote_kind &);
@ -243,10 +242,7 @@ public:
/** A transformed version of the file name, adequate for LaTeX
The path is stripped if no_path is true (default) */
string getLatexName(bool no_path = true) const {
return ChangeExtension(MakeLatexName(filename),
".tex", no_path);
}
string getLatexName(bool no_path = true) const;
/// Change name of buffer. Updates "read-only" flag.
void fileName(string const & newfile);
@ -258,16 +254,7 @@ public:
bool isReadonly() const { return read_only; }
/// Set buffer read-only flag
void setReadonly(bool flag = true) {
if (read_only != flag) {
read_only = flag;
updateTitles();
updateAllVisibleBufferRelatedPopups();
}
if (read_only) {
WarnReadonly(filename);
}
}
void setReadonly(bool flag = true);
/// returns true if the buffer contains a LaTeX document
bool isLatex() const;

View File

@ -51,7 +51,7 @@ typedef void (*FL_COMBO_PRE_POST) ();
class Combox {
public:
///
Combox(combox_type t = FL_COMBOX_NORMAL);
explicit Combox(combox_type t = FL_COMBOX_NORMAL);
///
~Combox();

View File

@ -27,6 +27,7 @@ public:
///
InsetCitation() : InsetCommand("cite") {}
///
explicit
InsetCitation(string const & key, string const & note = string());
///
~InsetCitation();
@ -64,8 +65,10 @@ public:
///
InsetBibKey() : InsetCommand("bibitem") { counter = 1; }
///
explicit
InsetBibKey(string const & key, string const & label = string());
///
explicit
InsetBibKey(InsetBibKey const *);
///
~InsetBibKey();

View File

@ -34,6 +34,7 @@ public:
///
static int const TEXT_TO_BOTTOM_OFFSET = 2;
///
explicit
InsetCollapsable(Buffer *);
///
~InsetCollapsable() {}

View File

@ -30,6 +30,7 @@ public:
///
InsetCommand();
///
explicit
InsetCommand(string const & name, string const & arg = string(),
string const & opt = string());
///

View File

@ -29,6 +29,7 @@
class InsetError: public Inset {
public:
///
explicit
InsetError(string const & string);
///
InsetError();

View File

@ -18,7 +18,8 @@
#include "lyxfont.h"
#include "Painter.h"
#include "buffer.h"
//#include "lyx_gui_misc.h"
#include "support/LOstream.h"
#include "lyx_gui_misc.h"
using std::ostream;

View File

@ -19,6 +19,7 @@
#include "BufferView.h"
#include "lyxscreen.h"
#include "Painter.h"
#include "support/LOstream.h"
using std::ostream;

View File

@ -28,6 +28,7 @@ class Painter;
class InsetFoot : public InsetCollapsable {
public:
///
explicit
InsetFoot(Buffer *);
///
~InsetFoot() {}

View File

@ -31,6 +31,7 @@ public:
///
InsetIndex() : InsetCommand("index") {}
///
explicit
InsetIndex(string const & key);
///
~InsetIndex();

View File

@ -33,6 +33,7 @@ public:
///
InsetInfo();
///
explicit
InsetInfo(string const & string);
///
~InsetInfo();

View File

@ -15,6 +15,7 @@
#endif
#include "insetlabel.h"
#include "support/LOstream.h"
using std::ostream;

View File

@ -23,6 +23,7 @@
class InsetLabel : public InsetCommand {
public:
///
explicit
InsetLabel(string const & cmd);
///
InsetLabel() : InsetCommand("label") {}

View File

@ -29,6 +29,7 @@ public:
///
InsetLatex();
///
explicit
InsetLatex(string const & string);
///
~InsetLatex();

View File

@ -32,6 +32,7 @@ public:
///
InsetLatexAccent();
///
explicit
InsetLatexAccent(string const & string);
///
int ascent(Painter &, LyXFont const &) const;

View File

@ -28,6 +28,7 @@ public:
///
InsetLOA() : InsetCommand("listofalgorithms") {}
///
explicit
InsetLOA(Buffer * b) : InsetCommand("listofalgorithms"), owner(b) {}
///
void Validate(LaTeXFeatures & features) const;

View File

@ -28,6 +28,7 @@ public:
///
InsetLOF() : InsetCommand("listoffigures") {}
///
explicit
InsetLOF(Buffer * b) : InsetCommand("listoffigures"), owner(b) {}
///
Inset * Clone() const { return new InsetLOF(owner); }

View File

@ -28,6 +28,7 @@ public:
///
InsetLOT() : InsetCommand("listoftables") {}
///
explicit
InsetLOT(Buffer * b) : InsetCommand("listoftables"), owner(b) {}
///
Inset * Clone() const { return new InsetLOT(owner); }

View File

@ -23,6 +23,7 @@
#include "LyXView.h"
#include "lyxfunc.h"
#include "commandtags.h"
#include "buffer.h"
using std::ostream;

View File

@ -30,6 +30,7 @@ public:
/// Non-standard LyX macro
InsetParent() : InsetCommand("lyxparent") {}
///
explicit
InsetParent(string const & fn, Buffer * owner = 0);
///
int Latex(std::ostream &, signed char fragile, bool free_spc) const;

View File

@ -65,7 +65,8 @@ public:
\item grd <- german double quote right
\item etc.
\end{itemize}
*/
*/
explicit
InsetQuotes(string const & str = "eld");
/// Create the right quote inset after character c
InsetQuotes(char c, BufferParams const & params);

View File

@ -45,6 +45,7 @@ public:
///
InsetSpecialChar() {}
///
explicit
InsetSpecialChar(Kind k);
///
int ascent(Painter &, LyXFont const &) const;

View File

@ -37,6 +37,7 @@ public:
///
enum { TEXT_TO_INSET_OFFSET = 1 };
///
explicit
InsetText(Buffer *);
///
InsetText(InsetText const &, Buffer *);

View File

@ -28,6 +28,7 @@ public:
///
InsetTOC() : InsetCommand("tableofcontents") {}
///
explicit
InsetTOC(Buffer * b) : InsetCommand("tableofcontents"), owner(b) {}
///
Inset * Clone() const { return new InsetTOC(owner); }

View File

@ -38,8 +38,10 @@ public:
flag = InsetUrl::URL;
}
///
explicit
InsetUrl(string const &);
///
explicit
InsetUrl(InsetCommand const &);
///
InsetUrl(string const &, string const &, string const &);

View File

@ -37,7 +37,8 @@ public:
Parameters are: name of file to read. Whether LastFiles should
check for file existance, and the number of files to remember.
*/
LastFiles(string const &, bool dostat = true, unsigned int num = 4);
explicit LastFiles(string const &,
bool dostat = true, unsigned int num = 4);
//@}
/**@name Methods */

View File

@ -1050,7 +1050,7 @@ bool LyXTextClass::Read(string const & filename, bool merge)
if (!defaultfont_.resolved()) {
lexrc.printError("Warning: defaultfont should "
"be fully instantiated!");
defaultfont_.realize(LyXFont::ALL_SANE);
defaultfont_.realize(LyXFont(LyXFont::ALL_SANE));
}
break;
@ -1602,3 +1602,17 @@ LyXTextClassList::Load (LyXTextClassList::size_type number) const
}
return result;
}
std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p)
{
switch (p) {
case LyXTextClass::OneSide:
os << "1";
break;
case LyXTextClass::TwoSides:
os << "2";
break;
}
return os;
}

View File

@ -12,6 +12,8 @@
#ifndef LAYOUT_H
#define LAYOUT_H
#include <vector>
#ifdef __GNUG__
#pragma interface
#endif
@ -20,7 +22,6 @@
#include "lyxfont.h"
#include "Spacing.h"
#include <vector>
/// Reads the style files
extern void LyXSetStyle();
@ -359,6 +360,7 @@ public:
///
typedef LayoutList::size_type size_type;
///
explicit
LyXTextClass (string const & = string(),
string const & = string(),
string const & = string());
@ -508,19 +510,7 @@ void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
///
inline
std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p)
{
switch (p) {
case LyXTextClass::OneSide:
os << "1";
break;
case LyXTextClass::TwoSides:
os << "2";
break;
}
return os;
}
std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p);
///

View File

@ -12,6 +12,7 @@
#include <fstream>
#include <algorithm>
#include <iostream>
#include "LString.h"
#include "support/lstrings.h"

View File

@ -158,10 +158,13 @@ public:
LyXFont(LyXFont const & x);
/// Shortcut initialization
explicit
LyXFont(LyXFont::FONT_INIT1);
/// Shortcut initialization
explicit
LyXFont(LyXFont::FONT_INIT2);
/// Shortcut initialization
explicit
LyXFont(LyXFont::FONT_INIT3);
/// Shortcut initialization
LyXFont(LyXFont::FONT_INIT1, Language const * l);

View File

@ -19,8 +19,11 @@
#include "lyxtext.h"
#include "LyXView.h"
#include "minibuffer.h"
#include "lyx_gui_misc.h"
#include "support/textutils.h"
#include "support/lstrings.h"
#include "BufferView.h"
#include "buffer.h"
// Returns the current selection. If nothing is selected or if the selection
// spans 2 paragraphs, an empty string is returned.

View File

@ -69,6 +69,7 @@
#include "layout.h"
#include "WorkArea.h"
#include "lyxfr1.h"
#include "menus.h"
using std::pair;
using std::endl;

View File

@ -30,6 +30,7 @@ public:
ToggleOff = 8
};
///
explicit
LyXFunc(LyXView *);
/// LyX distpatcher, executes lyx actions.

View File

@ -6,160 +6,107 @@
#include <config.h>
#include <algorithm>
#include <cstdlib>
#ifdef __GNUG__
#pragma implementation "lyxlex.h"
#endif
#include "lyxlex.h"
#include "debug.h"
#include "lyxlex_pimpl.h"
#include "support/filetools.h"
#include "support/lyxalgo.h"
using std::ios;
using std::ostream;
using std::istream;
using std::lower_bound;
using std::sort;
using std::endl;
// namespace {
struct compare_tags {
// used by lower_bound
inline
int operator()(keyword_item const & a, char const * const tag) const {
return compare_no_case(a.tag, tag) < 0;
}
// used by sorted and sort
inline
int operator()(keyword_item const & a, keyword_item const & b) const {
return compare_no_case(a.tag, b.tag) < 0;
}
};
// } // end of anon namespace
LyXLex::LyXLex(keyword_item * tab, int num)
: is(&fb__), table(tab), no_items(num)
: pimpl_(new Pimpl(tab, num))
{}
LyXLex::~LyXLex()
{
status = 0;
pushed = 0;
// Check if the table is sorted and if not, sort it.
if (table && !sorted(table, table + no_items, compare_tags())) {
lyxerr << "The table passed to LyXLex is not sorted!!\n"
<< "Tell the developers to fix it!" << endl;
// We sort it anyway to avoid problems.
lyxerr << "\nUnsorted:\n";
printTable(lyxerr);
sort(table, table + no_items,
compare_tags());
lyxerr << "\nSorted:\n";
printTable(lyxerr);
}
delete pimpl_;
}
bool LyXLex::IsOK() const
{
return pimpl_->is.good();
}
void LyXLex::setLineNo(int l)
{
pimpl_->lineno = l;
}
int LyXLex::GetLineNo() const
{
return pimpl_->lineno;
}
char const * LyXLex::text() const
{
return &pimpl_->buff[0];
}
std::istream & LyXLex::getStream()
{
return pimpl_->is;
}
void LyXLex::pushTable(keyword_item * tab, int num)
{
pushed_table * tmppu = new pushed_table;
tmppu->next = pushed;
tmppu->table_elem = table;
tmppu->table_siz = no_items;
pushed = tmppu;
table = tab;
no_items = num;
// Check if the table is sorted and if not, sort it.
if (table && !sorted(table, table + no_items, compare_tags())) {
lyxerr << "The table passed to LyXLex is not sorted!!\n"
<< "Tell the developers to fix it!" << endl;
// We sort it anyway to avoid problems.
lyxerr << "\nUnsorted:\n";
printTable(lyxerr);
sort(table, table + no_items, compare_tags());
lyxerr << "\nSorted:\n";
printTable(lyxerr);
}
pimpl_->pushTable(tab, num);
}
void LyXLex::popTable()
{
if (pushed == 0)
lyxerr << "LyXLex error: nothing to pop!" << endl;
pushed_table * tmp;
tmp = pushed;
table = tmp->table_elem;
no_items = tmp->table_siz;
tmp->table_elem = 0;
pushed = tmp->next;
delete tmp;
pimpl_->popTable();
}
void LyXLex::printTable(ostream & os)
{
os << "\nNumber of tags: " << no_items << '\n';
for(int i= 0; i < no_items; ++i)
os << "table[" << i
<< "]: tag: `" << table[i].tag
<< "' code:" << table[i].code << '\n';
os.flush();
pimpl_->printTable(os);
}
void LyXLex::printError(string const & message) const
{
string tmpmsg = subst(message, "$$Token", GetString());
lyxerr << "LyX: " << tmpmsg << " [around line " << lineno
<< " of file " << MakeDisplayPath(name) << ']' << endl;
pimpl_->printError(message);
}
bool LyXLex::setFile(string const & filename)
{
if (fb__.is_open())
lyxerr << "Error in LyXLex::setFile: "
"file or stream already set." << endl;
fb__.open(filename.c_str(), ios::in);
is.rdbuf(&fb__);
name = filename;
lineno = 0;
return fb__.is_open() && is.good();
return pimpl_->setFile(filename);
}
void LyXLex::setStream(istream & i)
{
if (fb__.is_open() || is.rdbuf()->in_avail())
lyxerr << "Error in LyXLex::setStream: "
"file or stream already set." << endl;
is.rdbuf(i.rdbuf());
lineno = 0;
pimpl_->setStream(i);
}
int LyXLex::lex()
{
//NOTE: possible bug.
if (next() && status == LEX_TOKEN)
return search_kw(buff);
else
return status;
return pimpl_->lex();
}
int LyXLex::GetInteger() const
{
if (buff[0] > ' ')
return atoi(buff);
if (pimpl_->buff[0] > ' ')
return atoi(pimpl_->buff);
else {
printError("Bad integer `$$Token'");
pimpl_->printError("Bad integer `$$Token'");
return -1;
}
}
@ -167,18 +114,18 @@ int LyXLex::GetInteger() const
float LyXLex::GetFloat() const
{
if (buff[0] > ' ')
return atof(buff);
if (pimpl_->buff[0] > ' ')
return atof(pimpl_->buff);
else {
printError("Bad float `$$Token'");
pimpl_->printError("Bad float `$$Token'");
return -1;
}
}
string LyXLex::GetString() const
string const LyXLex::GetString() const
{
return string(buff);
return pimpl_->GetString();
}
@ -234,299 +181,29 @@ string LyXLex::getLongString(string const & endtoken)
bool LyXLex::GetBool() const
{
if (compare(buff, "true") == 0)
if (compare(pimpl_->buff, "true") == 0)
return true;
else if (compare(buff, "false") != 0)
printError("Bad boolean `$$Token'. Use \"false\" or \"true\"");
else if (compare(pimpl_->buff, "false") != 0)
pimpl_->printError("Bad boolean `$$Token'. Use \"false\" or \"true\"");
return false;
}
bool LyXLex::EatLine()
{
int i = 0;
unsigned char c = '\0';
char cc = 0;
while(is && c != '\n' && i != (LEX_MAX_BUFF - 1)) {
is.get(cc);
c = cc;
lyxerr[Debug::LYXLEX] << "LyXLex::EatLine read char: `"
<< c << "'" << endl;
if (c != '\r')
buff[i++] = c;
}
if (i == (LEX_MAX_BUFF - 1) && c != '\n') {
printError("Line too long");
c = '\n'; // Pretend we had an end of line
--lineno; // but don't increase line counter (netto effect)
++i; // and preserve last character read.
}
if (c == '\n') {
++lineno;
buff[--i] = '\0'; // i can never be 0 here, so no danger
status = LEX_DATA;
return true;
} else {
buff[i] = '\0';
return false;
}
}
int LyXLex::search_kw(char const * const tag) const
{
keyword_item * res =
lower_bound(table, table + no_items, tag, compare_tags());
if (res != table + no_items && !compare_no_case(res->tag, tag))
return res->code;
return LEX_UNDEF;
return pimpl_->EatLine();
}
bool LyXLex::next(bool esc)
{
if (!esc) {
unsigned char c = 0; // getc() returns an int
char cc = 0;
status = 0;
while (is && !status) {
is.get(cc);
c = cc;
if (c == '#') {
// Read rest of line (fast :-)
is.getline(buff, sizeof(buff));
lyxerr[Debug::LYXLEX] << "Comment read: `" << c
<< buff << "'" << endl;
++lineno;
continue;
}
if (c == '\"') {
int i = -1;
do {
is.get(cc);
c = cc;
if (c != '\r')
buff[++i] = c;
} while (c != '\"' && c != '\n' && is &&
i != (LEX_MAX_BUFF - 2));
if (i == (LEX_MAX_BUFF - 2)) {
printError("Line too long");
c = '\"'; // Pretend we got a "
++i;
}
if (c != '\"') {
printError("Missing quote");
if (c == '\n')
++lineno;
}
buff[i] = '\0';
status = LEX_DATA;
break;
}
if (c == ',')
continue; /* Skip ','s */
// using relational operators with chars other
// than == and != is not safe. And if it is done
// the type _have_ to be unsigned. It usually a
// lot better to use the functions from cctype
if (c > ' ' && is) {
int i = 0;
do {
buff[i++] = c;
is.get(cc);
c = cc;
} while (c > ' ' && c != ',' && is
&& (i != LEX_MAX_BUFF - 1) );
if (i == LEX_MAX_BUFF - 1) {
printError("Line too long");
}
buff[i] = '\0';
status = LEX_TOKEN;
}
if (c == '\r' && is) {
// The Windows support has lead to the
// possibility of "\r\n" at the end of
// a line. This will stop LyX choking
// when it expected to find a '\n'
is.get(cc);
c = cc;
}
if (c == '\n')
++lineno;
}
if (status) return true;
status = is.eof() ? LEX_FEOF: LEX_UNDEF;
buff[0] = '\0';
return false;
} else {
unsigned char c = 0; // getc() returns an int
char cc = 0;
status = 0;
while (is && !status) {
is.get(cc);
c = cc;
// skip ','s
if (c == ',') continue;
if (c == '\\') {
// escape
int i = 0;
do {
if (c == '\\') {
// escape the next char
is.get(cc);
c = cc;
}
buff[i++] = c;
is.get(cc);
c = cc;
} while (c > ' ' && c != ',' && is
&& (i != LEX_MAX_BUFF - 1) );
if (i == LEX_MAX_BUFF - 1) {
printError("Line too long");
}
buff[i] = '\0';
status = LEX_TOKEN;
continue;
}
if (c == '#') {
// Read rest of line (fast :-)
is.getline(buff, sizeof(buff));
lyxerr[Debug::LYXLEX] << "Comment read: `" << c
<< buff << "'" << endl;
++lineno;
continue;
}
// string
if (c == '\"') {
int i = -1;
bool escaped = false;
do {
escaped = false;
is.get(cc);
c = cc;
if (c == '\r') continue;
if (c == '\\') {
// escape the next char
is.get(cc);
c = cc;
escaped = true;
}
buff[++i] = c;
if (!escaped && c == '\"') break;
} while (c != '\n' && is &&
i != (LEX_MAX_BUFF - 2));
if (i == (LEX_MAX_BUFF - 2)) {
printError("Line too long");
c = '\"'; // Pretend we got a "
++i;
}
if (c != '\"') {
printError("Missing quote");
if (c == '\n')
++lineno;
}
buff[i] = '\0';
status = LEX_DATA;
break;
}
if (c > ' ' && is) {
int i = 0;
do {
if (c == '\\') {
// escape the next char
is.get(cc);
c = cc;
//escaped = true;
}
buff[i++] = c;
is.get(cc);
c = cc;
} while (c > ' ' && c != ',' && is
&& (i != LEX_MAX_BUFF-1) );
if (i == LEX_MAX_BUFF-1) {
printError("Line too long");
}
buff[i] = '\0';
status = LEX_TOKEN;
}
// new line
if (c == '\n')
++lineno;
}
if (status) return true;
status = is.eof() ? LEX_FEOF : LEX_UNDEF;
buff[0] = '\0';
return false;
}
return pimpl_->next(esc);
}
bool LyXLex::nextToken()
{
status = 0;
while (is && !status) {
unsigned char c = 0;
char cc = 0;
is.get(cc);
c = cc;
if (c >= ' ' && is) {
int i = 0;
if (c == '\\') { // first char == '\\'
do {
buff[i++] = c;
is.get(cc);
c = cc;
} while (c > ' ' && c != '\\' && is
&& i != (LEX_MAX_BUFF-1));
} else {
do {
buff[i++] = c;
is.get(cc);
c = cc;
} while (c >= ' ' && c != '\\' && is
&& i != (LEX_MAX_BUFF-1));
}
if (i == (LEX_MAX_BUFF - 1)) {
printError("Line too long");
}
if (c == '\\') is.putback(c); // put it back
buff[i] = '\0';
status = LEX_TOKEN;
}
if (c == '\n')
++lineno;
}
if (status) return true;
status = is.eof() ? LEX_FEOF: LEX_UNDEF;
buff[0] = '\0';
return false;
return pimpl_->nextToken();
}
@ -535,15 +212,15 @@ int LyXLex::FindToken(char const * str[])
int i = -1;
if (next()) {
if (compare(buff, "default")) {
for (i = 0; str[i][0] && compare(str[i], buff); ++i);
if (compare(pimpl_->buff, "default")) {
for (i = 0; str[i][0] && compare(str[i], pimpl_->buff); ++i);
if (!str[i][0]) {
printError("Unknown argument `$$Token'");
pimpl_->printError("Unknown argument `$$Token'");
i = -1;
}
}
} else
printError("file ended while scanning string token");
pimpl_->printError("file ended while scanning string token");
return i;
}
@ -552,11 +229,11 @@ int LyXLex::CheckToken(char const * str[], int print_error)
{
int i = -1;
if (compare(buff, "default")) {
for (i = 0; str[i][0] && compare(str[i], buff); ++i);
if (compare(pimpl_->buff, "default")) {
for (i = 0; str[i][0] && compare(str[i], pimpl_->buff); ++i);
if (!str[i][0]) {
if (print_error)
printError("Unknown argument `$$Token'");
pimpl_->printError("Unknown argument `$$Token'");
i = -1;
}
}

View File

@ -12,7 +12,6 @@
#endif
#include <iosfwd>
#include <fstream>
#include "LString.h"
@ -34,7 +33,9 @@ class LyXLex {
public:
///
LyXLex (keyword_item *, int);
///
~LyXLex();
/// Lex basic codes
enum {
///
@ -54,9 +55,10 @@ public:
///
void setStream(std::istream & i);
///
std::istream & getStream() { return is; }
std::istream & getStream();
/// Danger! Don't use it unless you know what you are doing.
void setLineNo(int l) { lineno = l; }
void setLineNo(int l);
/// returns a lex code
int lex();
@ -71,7 +73,8 @@ public:
bool nextToken();
///
int GetLineNo() const { return lineno; }
int GetLineNo() const;
///
int GetInteger() const;
///
@ -79,7 +82,7 @@ public:
///
float GetFloat() const;
///
string GetString() const;
string const GetString() const;
/// get a long string, ended by the tag `endtag'
string getLongString(string const & endtag);
@ -92,7 +95,7 @@ public:
int CheckToken(char const * str[], int print_error);
///
char const * text() const { return &buff[0]; }
char const * text() const;
/** Pushes a token list on a stack and replaces it with a new one.
*/
@ -113,58 +116,12 @@ public:
Prints the current token table on the supplied ostream.
*/
void printTable(std::ostream &);
protected:
///
enum {
///
LEX_MAX_BUFF = 2048
};
///
struct pushed_table {
///
pushed_table(){
next= 0;
table_elem= 0;
}
///
pushed_table * next;
///
keyword_item * table_elem;
///
int table_siz;
};
/// fb__ is only used to open files, the stream is accessed through is
std::filebuf fb__;
/// the stream that we use.
std::istream is;
///
string name;
///
int lineno;
///
keyword_item * table;
///
int no_items;
///
char buff[LEX_MAX_BUFF];
///
pushed_table * pushed;
///
int search_kw(char const * const) const;
///
short status;
private:
struct Pimpl;
Pimpl * pimpl_;
};
inline
bool LyXLex::IsOK() const
{
return is.good();
}
// This is needed to ensure that the pop is done upon exit from methods
// with more than one exit point or that can return as a response to
// exceptions. (Lgb)

440
src/lyxlex_pimpl.C Normal file
View File

@ -0,0 +1,440 @@
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include <algorithm>
#include "lyxlex_pimpl.h"
#include "support/lyxalgo.h"
#include "support/filetools.h"
#include "debug.h"
using std::sort;
using std::ostream;
using std::ios;
using std::istream;
using std::endl;
using std::lower_bound;
// namespace {
struct compare_tags {
// used by lower_bound
inline
int operator()(keyword_item const & a, char const * const tag) const {
return compare_no_case(a.tag, tag) < 0;
}
// used by sorted and sort
inline
int operator()(keyword_item const & a, keyword_item const & b) const {
return compare_no_case(a.tag, b.tag) < 0;
}
};
// } // end of anon namespace
LyXLex::Pimpl::Pimpl(keyword_item * tab, int num)
: is(&fb__), table(tab), no_items(num),
status(0), pushed(0), lineno(0)
{
if (table && !sorted(table, table + no_items, compare_tags())) {
lyxerr << "The table passed to LyXLex is not sorted!!\n"
<< "Tell the developers to fix it!" << endl;
// We sort it anyway to avoid problems.
lyxerr << "\nUnsorted:\n";
printTable(lyxerr);
sort(table, table + no_items,
compare_tags());
lyxerr << "\nSorted:\n";
printTable(lyxerr);
}
}
string const LyXLex::Pimpl::GetString() const
{
return string(buff);
}
void LyXLex::Pimpl::printError(string const & message) const
{
string tmpmsg = subst(message, "$$Token", GetString());
lyxerr << "LyX: " << tmpmsg << " [around line " << lineno
<< " of file " << MakeDisplayPath(name) << ']' << endl;
}
void LyXLex::Pimpl::printTable(ostream & os)
{
os << "\nNumber of tags: " << no_items << '\n';
for(int i= 0; i < no_items; ++i)
os << "table[" << i
<< "]: tag: `" << table[i].tag
<< "' code:" << table[i].code << '\n';
os.flush();
}
void LyXLex::Pimpl::pushTable(keyword_item * tab, int num)
{
pushed_table * tmppu = new pushed_table;
tmppu->next = pushed;
tmppu->table_elem = table;
tmppu->table_siz = no_items;
pushed = tmppu;
table = tab;
no_items = num;
// Check if the table is sorted and if not, sort it.
if (table
&& !sorted(table, table + no_items, compare_tags())) {
lyxerr << "The table passed to LyXLex is not sorted!!\n"
<< "Tell the developers to fix it!" << endl;
// We sort it anyway to avoid problems.
lyxerr << "\nUnsorted:\n";
printTable(lyxerr);
sort(table, table + no_items, compare_tags());
lyxerr << "\nSorted:\n";
printTable(lyxerr);
}
}
void LyXLex::Pimpl::popTable()
{
if (pushed == 0)
lyxerr << "LyXLex error: nothing to pop!" << endl;
pushed_table * tmp;
tmp = pushed;
table = tmp->table_elem;
no_items = tmp->table_siz;
tmp->table_elem = 0;
pushed = tmp->next;
delete tmp;
}
bool LyXLex::Pimpl::setFile(string const & filename)
{
if (fb__.is_open())
lyxerr << "Error in LyXLex::setFile: "
"file or stream already set." << endl;
fb__.open(filename.c_str(), ios::in);
is.rdbuf(&fb__);
name = filename;
lineno = 0;
return fb__.is_open() && is.good();
}
void LyXLex::Pimpl::setStream(istream & i)
{
if (fb__.is_open() || is.rdbuf()->in_avail())
lyxerr << "Error in LyXLex::setStream: "
"file or stream already set." << endl;
is.rdbuf(i.rdbuf());
lineno = 0;
}
bool LyXLex::Pimpl::next(bool esc = false)
{
if (!esc) {
unsigned char c = 0; // getc() returns an int
char cc = 0;
status = 0;
while (is && !status) {
is.get(cc);
c = cc;
if (c == '#') {
// Read rest of line (fast :-)
is.getline(buff, sizeof(buff));
lyxerr[Debug::LYXLEX] << "Comment read: `" << c
<< buff << "'" << endl;
++lineno;
continue;
}
if (c == '\"') {
int i = -1;
do {
is.get(cc);
c = cc;
if (c != '\r')
buff[++i] = c;
} while (c != '\"' && c != '\n' && is &&
i != (LEX_MAX_BUFF - 2));
if (i == (LEX_MAX_BUFF - 2)) {
printError("Line too long");
c = '\"'; // Pretend we got a "
++i;
}
if (c != '\"') {
printError("Missing quote");
if (c == '\n')
++lineno;
}
buff[i] = '\0';
status = LEX_DATA;
break;
}
if (c == ',')
continue; /* Skip ','s */
// using relational operators with chars other
// than == and != is not safe. And if it is done
// the type _have_ to be unsigned. It usually a
// lot better to use the functions from cctype
if (c > ' ' && is) {
int i = 0;
do {
buff[i++] = c;
is.get(cc);
c = cc;
} while (c > ' ' && c != ',' && is
&& (i != LEX_MAX_BUFF - 1) );
if (i == LEX_MAX_BUFF - 1) {
printError("Line too long");
}
buff[i] = '\0';
status = LEX_TOKEN;
}
if (c == '\r' && is) {
// The Windows support has lead to the
// possibility of "\r\n" at the end of
// a line. This will stop LyX choking
// when it expected to find a '\n'
is.get(cc);
c = cc;
}
if (c == '\n')
++lineno;
}
if (status) return true;
status = is.eof() ? LEX_FEOF: LEX_UNDEF;
buff[0] = '\0';
return false;
} else {
unsigned char c = 0; // getc() returns an int
char cc = 0;
status = 0;
while (is && !status) {
is.get(cc);
c = cc;
// skip ','s
if (c == ',') continue;
if (c == '\\') {
// escape
int i = 0;
do {
if (c == '\\') {
// escape the next char
is.get(cc);
c = cc;
}
buff[i++] = c;
is.get(cc);
c = cc;
} while (c > ' ' && c != ',' && is
&& (i != LEX_MAX_BUFF - 1) );
if (i == LEX_MAX_BUFF - 1) {
printError("Line too long");
}
buff[i] = '\0';
status = LEX_TOKEN;
continue;
}
if (c == '#') {
// Read rest of line (fast :-)
is.getline(buff, sizeof(buff));
lyxerr[Debug::LYXLEX] << "Comment read: `" << c
<< buff << "'" << endl;
++lineno;
continue;
}
// string
if (c == '\"') {
int i = -1;
bool escaped = false;
do {
escaped = false;
is.get(cc);
c = cc;
if (c == '\r') continue;
if (c == '\\') {
// escape the next char
is.get(cc);
c = cc;
escaped = true;
}
buff[++i] = c;
if (!escaped && c == '\"') break;
} while (c != '\n' && is &&
i != (LEX_MAX_BUFF - 2));
if (i == (LEX_MAX_BUFF - 2)) {
printError("Line too long");
c = '\"'; // Pretend we got a "
++i;
}
if (c != '\"') {
printError("Missing quote");
if (c == '\n')
++lineno;
}
buff[i] = '\0';
status = LEX_DATA;
break;
}
if (c > ' ' && is) {
int i = 0;
do {
if (c == '\\') {
// escape the next char
is.get(cc);
c = cc;
//escaped = true;
}
buff[i++] = c;
is.get(cc);
c = cc;
} while (c > ' ' && c != ',' && is
&& (i != LEX_MAX_BUFF-1) );
if (i == LEX_MAX_BUFF-1) {
printError("Line too long");
}
buff[i] = '\0';
status = LEX_TOKEN;
}
// new line
if (c == '\n')
++lineno;
}
if (status) return true;
status = is.eof() ? LEX_FEOF : LEX_UNDEF;
buff[0] = '\0';
return false;
}
}
///
int LyXLex::Pimpl::search_kw(char const * const tag) const
{
keyword_item * res =
lower_bound(table, table + no_items,
tag, compare_tags());
if (res != table + no_items
&& !compare_no_case(res->tag, tag))
return res->code;
return LEX_UNDEF;
}
int LyXLex::Pimpl::lex()
{
//NOTE: possible bug.
if (next() && status == LEX_TOKEN)
return search_kw(buff);
else
return status;
}
bool LyXLex::Pimpl::EatLine()
{
int i = 0;
unsigned char c = '\0';
char cc = 0;
while(is && c != '\n' && i != (LEX_MAX_BUFF - 1)) {
is.get(cc);
c = cc;
lyxerr[Debug::LYXLEX] << "LyXLex::EatLine read char: `"
<< c << "'" << endl;
if (c != '\r')
buff[i++] = c;
}
if (i == (LEX_MAX_BUFF - 1) && c != '\n') {
printError("Line too long");
c = '\n'; // Pretend we had an end of line
--lineno; // but don't increase line counter (netto effect)
++i; // and preserve last character read.
}
if (c == '\n') {
++lineno;
buff[--i] = '\0'; // i can never be 0 here, so no danger
status = LEX_DATA;
return true;
} else {
buff[i] = '\0';
return false;
}
}
bool LyXLex::Pimpl::nextToken()
{
status = 0;
while (is && !status) {
unsigned char c = 0;
char cc = 0;
is.get(cc);
c = cc;
if (c >= ' ' && is) {
int i = 0;
if (c == '\\') { // first char == '\\'
do {
buff[i++] = c;
is.get(cc);
c = cc;
} while (c > ' ' && c != '\\' && is
&& i != (LEX_MAX_BUFF-1));
} else {
do {
buff[i++] = c;
is.get(cc);
c = cc;
} while (c >= ' ' && c != '\\' && is
&& i != (LEX_MAX_BUFF-1));
}
if (i == (LEX_MAX_BUFF - 1)) {
printError("Line too long");
}
if (c == '\\') is.putback(c); // put it back
buff[i] = '\0';
status = LEX_TOKEN;
}
if (c == '\n')
++lineno;
}
if (status) return true;
status = is.eof() ? LEX_FEOF: LEX_UNDEF;
buff[0] = '\0';
return false;
}

83
src/lyxlex_pimpl.h Normal file
View File

@ -0,0 +1,83 @@
// -*- C++ -*-
#ifndef LYXLEX_PIMPL_H
#define LYXLEX_PIMPL_H
#include <fstream>
#include "lyxlex.h"
#ifdef __GNUG__
#pragma interface
#endif
///
struct LyXLex::Pimpl {
///
enum {
///
LEX_MAX_BUFF = 2048
};
///
struct pushed_table {
///
pushed_table(){
next = 0;
table_elem = 0;
}
///
pushed_table * next;
///
keyword_item * table_elem;
///
int table_siz;
};
Pimpl(keyword_item * tab, int num);
string const GetString() const;
void printError(string const & message) const;
void printTable(std::ostream & os);
void pushTable(keyword_item * tab, int num);
void popTable();
bool setFile(string const & filename);
void setStream(std::istream & i);
bool next(bool esc = false);
///
int search_kw(char const * const tag) const;
int lex();
bool EatLine();
bool nextToken();
/// fb__ is only used to open files, the stream is accessed through is
std::filebuf fb__;
/// the stream that we use.
std::istream is;
///
string name;
///
keyword_item * table;
///
int no_items;
///
char buff[LEX_MAX_BUFF];
///
short status;
///
pushed_table * pushed;
///
int lineno;
};
#endif

View File

@ -120,6 +120,7 @@ public:
///
LyXParagraph();
/// this konstruktor inserts the new paragraph in a list
explicit
LyXParagraph(LyXParagraph * par);
/// the destruktors removes the new paragraph from the list
~LyXParagraph();

View File

@ -39,8 +39,8 @@ public:
typedef void (*ClientCallbackfct)(LyXServer *, string const &);
/// Construct with pipe-basename and callback to receive messages
LyXComm(string const &pip, LyXServer * cli, ClientCallbackfct ccb = 0)
:pipename(pip), client(cli), clientcb(ccb)
LyXComm(string const & pip, LyXServer * cli, ClientCallbackfct ccb = 0)
: pipename(pip), client(cli), clientcb(ccb)
{
ready = false;
openConnection();
@ -98,7 +98,7 @@ public:
// bufferview. We just have to find a way to handle situations like if
// lyxserver is using a buffer that is being edited with a bufferview.
// With a common buffer list this is not a problem, maybe. (Alejandro)
LyXServer(LyXFunc *f, string const &pip)
LyXServer(LyXFunc * f, string const & pip)
: numclients(0), func(f), pipes(pip, (this), callback)
{ }
///
@ -113,7 +113,7 @@ private:
string clients[MAX_CLIENTS];
int numclients;
///
LyXFunc *func;
LyXFunc * func;
///
LyXComm pipes;
};

View File

@ -39,13 +39,16 @@ public:
};
///
explicit
LyxArrayBase(int size = ARRAY_STEP);
///
LyxArrayBase(LyxArrayBase const &);
///
~LyxArrayBase();
/// Constructs a new array with dx elements starting at pos
LyxArrayBase & operator= (LyxArrayBase const &);
///
int empty() const { return (last == 0); }
@ -82,9 +85,6 @@ public:
/// Constructs a new array with dx elements starting at pos
byte operator[](const int);
/// Constructs a new array with dx elements starting at pos
LyxArrayBase & operator= (LyxArrayBase const &);
protected:
///
void Resize(int newsize);

View File

@ -32,8 +32,10 @@ class MathedCursor;
class InsetFormula: public UpdatableInset {
public:
///
explicit
InsetFormula(bool display = false);
///
explicit
InsetFormula(MathParInset *);
///
~InsetFormula();

View File

@ -32,6 +32,7 @@ public:
///
InsetFormulaMacro();
///
explicit
InsetFormulaMacro(string name, int na = 0, bool env = false);
///
~InsetFormulaMacro();

View File

@ -31,6 +31,7 @@
class MathedCursor {
public:
///
explicit
MathedCursor(MathParInset * p);
///
~MathedCursor() { };

View File

@ -222,6 +222,7 @@ class MathedInset {
/// A math inset has a name (usually its LaTeX name), type and font-size
MathedInset(char const * nm, short ot, short st);
///
explicit
MathedInset(MathedInset *);
///
virtual ~MathedInset() {}
@ -317,6 +318,7 @@ class MathParInset: public MathedInset {
MathParInset(short st = LM_ST_TEXT, char const * nm = 0,
short ot = LM_OT_MIN);
///
explicit
MathParInset(MathParInset *);
///
virtual ~MathParInset();
@ -414,7 +416,8 @@ class MathParInset: public MathedInset {
Only used for multiline paragraphs.
*/
struct MathedRowSt {
///
///
explicit
MathedRowSt(int n) {
w = new int[n + 1]; // this leaks
asc = desc = y = 0;
@ -473,8 +476,10 @@ struct MathedRowSt {
class MathMatrixInset: public MathParInset {
public:
///
explicit
MathMatrixInset(int m = 1, int n = 1, short st = LM_ST_TEXT);
///
explicit
MathMatrixInset(MathMatrixInset *);
///
MathedInset * Clone();

View File

@ -36,6 +36,7 @@
class MathFuncInset: public MathedInset {
public:
///
explicit
MathFuncInset(char const * nm,
short ot = LM_OT_FUNC, short st = LM_ST_TEXT);
///

View File

@ -51,6 +51,7 @@ class MathedIter {
ncols = row = col = 0;
}
///
explicit
MathedIter(LyxArrayBase *);
///
virtual ~MathedIter() { }
@ -69,11 +70,11 @@ class MathedIter {
///
byte GetChar();
///
byte* GetString(int& len);
byte * GetString(int& len);
///
MathedInset* GetInset();
MathedInset * GetInset();
///
MathParInset* GetActiveInset();
MathParInset * GetActiveInset();
///
bool IsInset();
///
@ -89,9 +90,9 @@ class MathedIter {
///
virtual void Reset();
///
virtual void Insert(byte, MathedTextCodes c= LM_TC_CONST);
virtual void Insert(byte, MathedTextCodes c = LM_TC_CONST);
///
virtual void Insert(MathedInset*, int t= LM_TC_INSET);
virtual void Insert(MathedInset *, int t = LM_TC_INSET);
///
virtual bool Delete();
///
@ -111,12 +112,12 @@ class MathedIter {
///
void setNumCols(int n) { ncols = n; }
///
void SetData(LyxArrayBase *a) { array = a; Reset(); }
void SetData(LyxArrayBase * a) { array = a; Reset(); }
///
LyxArrayBase *GetData() { return array; }
LyxArrayBase * GetData() { return array; }
/// Copy every object from position p1 to p2
LyxArrayBase *Copy(int p1= 0, int p2= 10000);
LyxArrayBase * Copy(int p1= 0, int p2= 10000);
/// Delete every object from position p1 to p2
void Clear();

View File

@ -37,8 +37,10 @@ class MathMacro : public MathParInset
{
public:
/// A macro can only be builded from an existing template
explicit
MathMacro(MathMacroTemplate *);
/// or from another macro.
explicit
MathMacro(MathMacro *);
///
~MathMacro();
@ -105,6 +107,7 @@ public:
///
MathMacroArgument() { expnd_mode = false; number = 1; SetType(LM_OT_MACRO_ARG); }
///
explicit
MathMacroArgument(int);
///
~MathMacroArgument() { lyxerr << "help, destroyme!" << std::endl; }
@ -134,6 +137,7 @@ private:
class MathMacroTemplate: public MathParInset {
public:
/// A template constructor needs all the data
explicit
MathMacroTemplate(char const *, int na = 0, int f = 0);
///
~MathMacroTemplate();
@ -186,6 +190,7 @@ typedef MathMacroTemplate * MathMacroTemplateP;
class MathMacroTable {
public:
///
explicit
MathMacroTable(int);
///
~MathMacroTable();

View File

@ -28,8 +28,10 @@
class MathRootInset: public MathSqrtInset {
public:
///
explicit
MathRootInset(short st = LM_ST_TEXT);
///
// explicit
// MathRootInset(MathSqrtInset &);
///
~MathRootInset();

View File

@ -325,7 +325,9 @@ void mathed_write(MathParInset * p, ostream & os, int * newlines,
else {
// Thinko!
// Is this '\n' really needed, what can go wrong
//if it is not there?
//if it is not there? The reason why I want to avoid this is
// because of the "backlook" into the output stream.
// Lgb.
#warning Thinko!
#if 0
if (!suffixIs(outf, '\n')) {

View File

@ -25,6 +25,8 @@
#include "debug.h"
#include "gettext.h"
#include "LyXAction.h"
#include "BufferView.h"
#include "buffer.h"
using std::endl;

View File

@ -16,7 +16,8 @@ class LyXView;
class MiniBuffer {
public:
///
MiniBuffer(LyXView *o, FL_Coord x, FL_Coord y, FL_Coord h, FL_Coord w);
MiniBuffer(LyXView * o,
FL_Coord x, FL_Coord y, FL_Coord h, FL_Coord w);
///
bool shows_no_match;

View File

@ -19,6 +19,7 @@
#ifdef MODERN_STL_STREAMS
#include <fstream>
#endif
#include <iostream>
using std::ostream;
using std::streambuf;

View File

@ -12,7 +12,7 @@
#ifndef DEBUGSTREAM_H
#define DEBUGSTREAM_H
#include <iostream>
#include "LOstream.h"
#ifdef TEST_DEBUGSTREAM
#include <string>
@ -88,6 +88,7 @@ public:
explicit DebugStream(Debug::type t = Debug::NONE);
/// Constructor, sets the log file to f, and the debug level to t.
explicit
DebugStream(char const * f, Debug::type t = Debug::NONE);
///

View File

@ -29,9 +29,11 @@ public:
/** Get information about file.
If link is true, the information is about the link itself, not
the file that is obtained by tracing the links. */
explicit
FileInfo(string const & path, bool link = false);
/// File descriptor
explicit
FileInfo(int fildes);
/// Query a new file

View File

@ -19,6 +19,7 @@
class LRegex {
public:
///
explicit
LRegex(string const & regex);
///

View File

@ -163,6 +163,7 @@ public:
lyxstring(value_type const *, size_type n);
/// #lyxstring x("abc")#
explicit
lyxstring(value_type const *);
/// lyxstring(5, 'n') -> "nnnnn"

View File

@ -14,6 +14,7 @@
class Path {
public:
///
explicit
Path(string const & path)
: popped_(false)
{

View File

@ -69,6 +69,7 @@ public:
///
LyXTable(int columns_arg, int rows_arg);
///
explicit
LyXTable(LyXLex & lex);
///
~LyXTable();

View File

@ -37,6 +37,7 @@
#include "lyxrow.h"
#include "Painter.h"
#include "font.h"
#include "debug.h"
#define FIX_DOUBLE_SPACE 1

View File

@ -7,6 +7,7 @@
class DebugTracer {
public:
explicit
DebugTracer(string const & s) : str(s) {
lyxerr << string(depth, ' ') << "Trace begin : "
<< str << std::endl;

View File

@ -76,6 +76,7 @@ protected:
class RCS : public VCS {
public:
///
explicit
RCS(string const & m);
///
static string find_file(string const & file);
@ -103,6 +104,7 @@ private:
class CVS : public VCS {
public:
///
explicit
CVS(string const & m, string const & f);
///
static string find_file(string const & file);

View File

@ -61,6 +61,7 @@ public:
LyXLength(float v, LyXLength::UNIT u) : val(v), uni(u) {}
/** "data" must be a decimal number, followed by a unit. */
explicit
LyXLength(string const & data);
//@}
@ -102,9 +103,12 @@ public:
//@Man: constructors
//@{
///
LyXGlueLength(float v, LyXLength::UNIT u,
float pv= 0.0, LyXLength::UNIT pu= LyXLength::UNIT_NONE,
float mv= 0.0, LyXLength::UNIT mu= LyXLength::UNIT_NONE)
LyXGlueLength(float v,
LyXLength::UNIT u,
float pv = 0.0,
LyXLength::UNIT pu = LyXLength::UNIT_NONE,
float mv = 0.0,
LyXLength::UNIT mu = LyXLength::UNIT_NONE)
: LyXLength (v, u),
plus_val(pv), minus_val(mv),
plus_uni(pu), minus_uni(mu) {}
@ -115,6 +119,7 @@ public:
1.2 cm // 4mm +2pt // 2cm -4mm +2mm // 4+0.1-0.2cm
The traditional Latex format is also accepted, like
4cm plus 10pt minus 10pt */
explicit
LyXGlueLength(string const & data);
//@}
@ -160,17 +165,19 @@ public:
enum vspace_kind { NONE, DEFSKIP,
SMALLSKIP, MEDSKIP, BIGSKIP,
VFILL, LENGTH };
// constructors
/// constructors
VSpace() :
kin (NONE),
len(0.0, LyXLength::PT),
kp (false) {}
///
explicit
VSpace(vspace_kind k) :
kin (k),
len (0.0, LyXLength::PT),
kp (false) {}
///
explicit
VSpace(LyXGlueLength l) :
kin (LENGTH),
len (l),
@ -182,6 +189,7 @@ public:
kp (false) {}
/// this constructor is for reading from a .lyx file
explicit
VSpace(string const & data);
// access functions