+2000-04-26 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * src/text2.C (GetRowNearY): remove currentrow code
+
+ * src/text.C (GetRow): remove currentrow code
+
+ * src/screen.C (Update): rewritten a bit.
+ (SmallUpdate): removed func
+
+ * src/lyxtext.h (text_status): removed NEED_LITTLE_REFRESH, never
+ used.
+ (FullRebreak): return bool
+ (currentrow): remove var
+ (currentrow_y): ditto
+
+ * src/lyxscreen.h (Draw): change arg to unsigned long
+ (FitCursor): return bool
+ (FitManualCursor): ditto
+ (Smallpdate): remove func
+ (first): change to unsigned long
+ (DrawOneRow): change second arg to long (from long &)
+ (screen_refresh_y): remove var
+ (scree_refresh_row): ditto
+
+ * src/lyxrow.h: change baseline to usigned int from unsigned
+ short, this brings some implicit/unsigned issues out in the open.
+
+ * src/lyxfunc.C (moveCursorUpdate): update(0) == update(-2) change
+ accordingly.
+ (Dispatch): don't call updateScrollbar after fitCursor. Use update
+ instead of smallUpdate.
+
+ * src/lyxcursor.h: change y to unsigned long
+
+ * src/buffer.h: don't call updateScrollbar after fitcursor
+
+ * src/buffer.C (parseSingleLyXformat2Token): move variables to
+ where they are used. Removed "\\direction", this was not present
+ in 1.1.4 and is already obsolete. Commented out some code that I
+ believe to never be called.
+ (runLiterate): don't call updateScrollbar after fitCursor
+ (runLaTeX): ditto
+ (buildProgram): ditto
+ (runChktex): ditto
+
+ * src/WorkArea.h (workWidth): change return val to unsigned
+ (width): ditto
+ (height): ditto
+ (redraw): remove the button redraws
+ (setScrollbarValue): change for scrollbar
+ (getScrollbarValue): change for scrollbar
+ (getScrollbarBounds): change for scrollbar
+
+ * src/WorkArea.C (C_WorkArea_up_cb): removed func
+ (C_WorkArea_down_cb): removed func
+ (WorkArea): use fl_add_scrollbar instead of two buttons and a slider.
+ (resize): change for scrollbar
+ (setScrollbar): ditto
+ (setScrollbarBounds): ditto
+ (setScrollbarIncrements): ditto
+ (up_cb): removed func
+ (down_cb): removed func
+ (scroll_cb): change for scrollbar
+ (work_area_handler): ditto
+
+ * src/BufferView_pimpl.C (fitCursor): only call updateScrollbar
+ when FitCursor did something.
+ (updateScrollbar): some unsigned changes
+ (downCB): removed func
+ (scrollUpOnePage): removed func
+ (scrollDownOnePage): remvoed func
+ (workAreaMotionNotify): don't call screen->FitCursor but use
+ fitCursor instead. and bool return val
+ (workAreaButtonPress): ditto
+ (workAreaButtonRelease): some unsigned changes
+ (checkInsetHit): ditto
+ (workAreaExpose): ditto
+ (update): parts rewritten, comments about the signed char arg added
+ (smallUpdate): removed func
+ (cursorPrevious): call needed updateScrollbar
+ (cursorNext): ditto
+
+ * src/BufferView2.C (allFloats): don't call updateScrollbar after
+ fitCursor.
+
+ * src/BufferView.[Ch] (upCB): removed func
+ (downCB): removed func
+ (smallUpdate): removed func
+
+2000-04-25 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * src/lyxtext.h src/text.C src/text2.C: removed support for the
+ currentrow, currentrow_y optimization. This did not help a lot and
+ if we want to do this kind of optimization we should rather use
+ cursor.row instead of the currentrow.
+
+ * src/buffer.C (parseSingleLyXformat2Token): fixed mistake in
+ buffer spacing and klyx spacing support.
+
2000-04-25 Dekel Tsur <dekel@math.tau.ac.il>
* src/spellchecker.C (RunSpellChecker): Speedup spellchecking by
--- /dev/null
+
+ How to support the seminar package in LyX
+ ===========================================
+
+ Seminar.cls is a nice LaTeX2e package aimed a producing
+ nice and clear slides. It can work together with pstricks and
+ the color package, and can procduce fance slides indeed.
+
+ The seminar class has some important class options:
+ - article Produce the whole seminar document as a regular
+ latex article with the slides as floating
+ bodies and the notes as running text.
+ - slidesonly Generates only the slides, not the notes.
+ - notesonly Generates only the notes.
+ -
+
+ Variables for the slide environment
+ ===================================
+
+ \slideleftmargin
+ \sliderightmargin
+ \slidetopmargin
+ \slidebottommargin
+ \paperwidth
+ \paperheight
+ ... and a lot of others
+
+ Goal
+ ====
+
+ The ultimate goad would be to be able to do all that is
+ done in the Seminar FAQ inside LyX.
+
+ References
+ ==========
+
+ CTAN/macros/latex/contrib/other/seminar
+ http://www.tug.org/applications/Seminar
+ The Seminar FAQ
\ No newline at end of file
--- /dev/null
+
+ Lazy Generation of LyXText
+ --------------------------
+
+ Currently we generate the Row structure at the time of LyXText
+ creation. This is the "formatting" period of the document
+ loading. As can be seen this has a significant hit on the amount
+ of time used to load large documents. On my computer this
+ manifests itself as a 15 second load time of the UserGuide. In
+ many ways this is acceptable, but we actually get the same hit
+ when switching between documents. Because of this the TextCache
+ was created, however it seems that textcache has some internal
+ problems or it makes problems in LyXText show.
+
+ My suggestion is to make LyXText only generate Rows as need, i.e.
+ lazy evaluation/generation of the on screen formatting. This will
+ give us: blinding fast document loading. It also lessens the need
+ for the TextCache class significantly and with some small further
+ alterations TextCache can be removed completely.
+
+ The Rows are currently stored in a home made double linked list.
+ To achieve the lazy evaluation this should be changed slightly:
+
+ struct RowPar {
+ // Pointer to the paragraph that this rowpar holds rows for.
+ LyXParagraph * par;
+ // Only used for lazy evaluation when switching between buffers.
+ unsigned int par_y;
+ typedef vector<Row> Rows;
+ // The actual rows, generated as needed.
+ Rows rows;
+ };
+
+ struct Row {
+ LyXParagraph::size_type pos;
+ mutable int fill;
+ unsigned short height;
+ unsigned short ascent_of_text;
+ unsigned baseline;
+ };
+
+ typedef list<RowPar> ParRowList;
+ ParRowList parrow;
+
+ Several LyXText methods needs to be changed to handle this new
+ structure.
+
+ Note about RowPar::par_y: If we only want top-down¹ this variable
+ is not needed. If we however want to be able to begin evaluation
+ at the location of the cursor it is needed. Then we don't have to
+ store the formatted document in the textcache. Only a list of
+
+ struct Cache {
+ LyXParagraph * par;
+ unsigned int par_y;
+ };
+
+ is needed. Since we regenerate all the rows subtleties with row
+ lifetime etc. are avoided.
+
+ Memory usage: the current Row has a size of about 28 bytes on a
+ 32 bit machine and we have one Row for each line on the screen.
+ For a 10 page document with ca. 50 lines on each page this is
+ 28 * 10 * 50 = 14000 bytes.
+ The approach above has three pointer less in each row, so
+ this is 16 * 10 * 50 = 8000 bytes, we have however some
+ additional overhead: the RowPars one for each paragraph if we
+ assume 5 lines per paragraph and 20 bytes for each RowPar we get:
+ 10 * 50 / 5 * 20 = 2000. This is a sum of 10000 on the new scheme.
+
+ Speed: some operations will most likely be somewhat faster since
+ they now can operate on the number of paragraph instead of the
+ number of rows. I do not foresee any operations becoming slower.
+ The actual lazy evaluation will be done upon displaying, and when
+ the lyx process is idle (idle_callback), this will mostly be
+ initiated by LyXScreen and done in LyXText::GetRowNearY and in
+ LyXText::GetRow. Perhaps also in LyXText::GetVisibleRow. All of
+ the evaluation will be done on a per-paragraph basis.
+
+ If we want to operate on rows only it is easy to create iterators
+ that can handle this. (This means that a way to force the
+ evaluation of the rows might be something like:
+
+ // traverse all the rows and generate the missing ones.
+ for_each(rowlist.begin(), rowlist.end(), dummy_func);
+
+ Note about the buffer structure in the lyx repository: LyXText
+ really is orthogonal to the new buffer structure in that the
+ BufferStructure is used for storage of the paragraphs, and
+ LyXText is used for the caching of on-screen display (of
+ lines/rows).
+
+ Note on impact on other code: Since the current rowlist is
+ internal to LyXText the impact on code outside LyXText will be
+ very small. However _inside_ LyXText the impact will be huge, and
+ all methods that access the rowlist will have to change.
+
+ When to begin coding on this. Of course since this is something
+ that I want to do, I'd like to begin right away. There can be
+ argued that this should wait until table and floats has been
+ moved out of LyXText, but I only partially agree. These changes
+ will be on a fairly low-level and the removal of table and floats
+ will not impact the development of this code much. Also this can
+ very well be done in a separate branch in cvs. Anyway this coding
+ will not begin until after 1.1.5 is released.
+
+ Fun stuff: Instead of doing the lazy evaluation only when needed
+ or by the idle callback this could also be done by a separate
+ thread taking advantage of SMP and/or io-blocking in the main
+ thread. We could even have the evaluation of each paragraph we
+ done in its own thread (or by a few² worker threads)
+
+
+ Lgb
+
+¹ Row evaluation from the beginning of the document to the end. Never
+from the middle.
+
+² Number of CPUs f.ex.
+
+
+
\ No newline at end of file
}
+#if 0
// Callback for scrollbar up button
void BufferView::upCB(long time, int button)
{
break;
}
}
+#endif
void BufferView::enterView()
}
+#if 0
// Callback for scrollbar down button
void BufferView::downCB(long time, int button)
{
pimpl_->downCB(time, button);
}
+#endif
void BufferView::workAreaMotionNotify(int x, int y, unsigned int state)
}
+#if 0
void BufferView::smallUpdate(signed char f)
{
pimpl_->smallUpdate(f);
}
+#endif
void BufferView::setState()
void update();
///
void update(signed char f);
+#if 0
///
void smallUpdate(signed char f);
+#endif
///
void updateScrollbar();
///
bool active() const;
///
bool belowMouse() const;
+#if 0
/// A callback for the up arrow in the scrollbar.
void upCB(long time, int button);
- /// A callback for the slider in the scrollbar.
- void scrollCB(double);
/// A callback for the down arrow in the scrollbar.
void downCB(long time, int button);
+#endif
+ /// A callback for the slider in the scrollbar.
+ void scrollCB(double);
///
static void cursorToggleCB(FL_OBJECT * ob, long);
text->SetCursorIntern(cursor.par, cursor.pos);
redraw();
fitCursor();
- updateScrollbar();
+ //updateScrollbar();
}
#include "lyx_gui_misc.h"
#include "lyxrc.h"
#include "intl.h"
-
+#include "support/LAssert.h"
using std::pair;
using std::endl;
}
-void BufferView::Pimpl::fitCursor()
+bool BufferView::Pimpl::fitCursor()
{
- if (screen) screen->FitCursor();
- updateScrollbar();
+ Assert(screen); // it is a programming error to call fitCursor
+ // without a valid screen.
+ bool ret = screen->FitCursor();
+ if (ret) updateScrollbar();
+ return ret;
}
return;
}
- static long max2 = 0;
- static long height2 = 0;
+ static unsigned long max2 = 0;
+ static unsigned long height2 = 0;
- long cbth = 0;
+ unsigned long cbth = 0;
long cbsf = 0;
if (bv_->text)
if (cursor_follows_scrollbar) {
LyXText * vbt = bv_->text;
- int height = vbt->DefaultHeight();
+ unsigned int height = vbt->DefaultHeight();
if (vbt->cursor.y < screen->first + height) {
vbt->SetCursorFromCoordinates(0,
}
+#if 0
// Callback for scrollbar down button
void BufferView::Pimpl::downCB(long time, int button)
{
break;
}
}
+#endif
int BufferView::Pimpl::scrollUp(long time)
return 0;
}
-
+#if 0
void BufferView::Pimpl::scrollUpOnePage()
{
if (buffer_ == 0) return;
bv_->scrollCB(y);
}
+#endif
-
+#if 0
void BufferView::Pimpl::scrollDownOnePage()
{
if (buffer_ == 0) return;
bv_->scrollCB(y);
}
+#endif
void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
bv_->text->SetSelection();
screen->ToggleToggle();
- if (screen->FitCursor())
- updateScrollbar();
+ fitCursor();
screen->ShowCursor();
}
return;
bv_->text->cursor.x_fix = bv_->text->cursor.x;
owner_->updateLayoutChoice();
- if (screen->FitCursor()){
- updateScrollbar();
+ if (fitCursor()) {
selection_possible = false;
}
}
-void BufferView::Pimpl::workAreaButtonRelease(int x, int y, unsigned int button)
+void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
+ unsigned int button)
{
if (buffer_ == 0 || screen == 0) return;
if (inset_hit != 0) {
// Inset like error, notes and figures
selection_possible = false;
-#ifdef WITH_WARNINGS
-#warning fix this proper in 0.13
-#endif
+
+ // CHECK fix this proper in 0.13
+
// Following a ref shouldn't issue
// a push on the undo-stack
// anylonger, now that we have
int box_x = 20; // LYX_PAPER_MARGIN;
box_x += lyxfont::width(" wide-tab ", font);
- int screen_first = screen->first;
+ unsigned int screen_first = screen->first;
if (x < box_x
&& y + screen_first > bv_->text->cursor.y -
if (!screen)
return 0;
- int y_tmp = y + screen->first;
+ unsigned int y_tmp = y + screen->first;
LyXCursor cursor;
bv_->text->SetCursorFromCoordinates(cursor, x, y_tmp);
// redraw();
//}
- static int work_area_width = -1;
- static int work_area_height = -1;
+ static unsigned int work_area_width = 0;
+ static unsigned int work_area_height = 0;
bool widthChange = workarea->workWidth() != work_area_width;
bool heightChange = workarea->height() != work_area_height;
if (screen) screen->Update();
}
-
+// Values used when calling update:
+// -3 - update
+// -2 - update, move sel_cursor if selection, fitcursor
+// -1 - update, move sel_cursor if selection, fitcursor, mark dirty
+// 0 - update, move sel_cursor if selection, fitcursor
+// 1 - update, move sel_cursor if selection, fitcursor, mark dirty
+// 3 - update, move sel_cursor if selection
+//
+// update -
+// a simple redraw of the parts that need refresh
+//
+// move sel_cursor if selection -
+// the text's sel_cursor is moved if there is selection is progress
+//
+// fitcursor -
+// fitCursor() is called and the scrollbar updated
+//
+// mark dirty -
+// the buffer is marked dirty.
+//
+// enum {
+// UPDATE = 0,
+// SELECT = 1,
+// FITCUR = 2,
+// CHANGE = 4
+// };
+//
+// UPDATE_ONLY = UPDATE;
+// UPDATE_SELECT = UPDATE | SELECT;
+// UPDATE_SELECT_MOVE = UPDATE | SELECT | FITCUR;
+// UPDATE_SELECT_MOVE_AFTER_CHANGE = UPDATE | SELECT | FITCUR | CHANGE;
+//
+// update(-3) -> update(0) -> update(0) -> update(UPDATE)
+// update(-2) -> update(1 + 2) -> update(3) -> update(SELECT|FITCUR)
+// update(-1) -> update(1 + 2 + 4) -> update(7) -> update(SELECT|FITCUR|CHANGE)
+// update(1) -> update(1 + 2 + 4) -> update(7) -> update(SELECT|FITCUR|CHANGE)
+// update(3) -> update(1) -> update(1) -> update(SELECT)
void BufferView::Pimpl::update(signed char f)
{
+#if 1
owner_->updateLayoutChoice();
if (!bv_->text->selection && f > -3)
if (f != 3 && f != -3) {
fitCursor();
- updateScrollbar();
+ //updateScrollbar();
}
if (f == 1 || f == -1) {
buffer_->markDirty();
}
}
+#else
+ owner_->updateLayoutChoice();
+
+ if (!bv_->text->selection && (f & SELECT))
+ bv_->text->sel_cursor = bv_->text->cursor;
+
+ FreeUpdateTimer();
+ bv_->text->FullRebreak();
+
+ update();
+
+ if ((f & FITCUR)) {
+ fitCursor();
+ //updateScrollbar();
+ }
+
+ if ((f & CHANGE)) {
+ if (buffer_->isLyxClean()) {
+ buffer_->markDirty();
+ owner_->getMiniBuffer()->setTimer(4);
+ } else {
+ buffer_->markDirty();
+ }
+ }
+#endif
}
+#if 0
void BufferView::Pimpl::smallUpdate(signed char f)
{
+#if 1
+ update(f);
+#else
screen->SmallUpdate();
if (screen->TopCursorVisible()
!= screen->first) {
}
fitCursor();
- updateScrollbar();
+ //updateScrollbar();
if (!bv_->text->selection)
bv_->text->sel_cursor = bv_->text->cursor;
buffer_->markDirty();
}
}
+#endif
}
+#endif
// Callback for cursor timer
- bv_->text->cursor.row->baseline
+ bv_->text->cursor.row->height
- workarea->height() + 1 );
+ updateScrollbar();
}
if (bv_->text->cursor.row->height < workarea->height())
screen->Draw(bv_->text->cursor.y
- bv_->text->cursor.row->baseline);
+ updateScrollbar();
}
void resize();
///
void redraw();
- ///
- void fitCursor();
+ /// Return true if the cursor was fitted.
+ bool fitCursor();
///
void redoCurrentBuffer();
///
void update();
///
void update(signed char f);
+#if 0
///
void smallUpdate(signed char f);
+#endif
///
void gotoError();
/// Update pixmap of screen
void updateScrollbar();
///
void scrollCB(double value);
+#if 0
///
void downCB(long time, int button);
+#endif
+#if 0
///
void scrollUpOnePage();
+#endif
+#if 0
///
void scrollDownOnePage();
+#endif
///
void create_view();
///
#endif
#include "WorkArea.h"
+#ifndef USE_FL_SCROLLBAR
#include "up.xpm"
#include "down.xpm"
+#endif
#include "debug.h"
#include "support/lstrings.h"
#include "BufferView.h"
extern "C" {
// Just a bunch of C wrappers around static members of WorkArea
+#ifndef USE_FL_SCROLLBAR
void C_WorkArea_up_cb(FL_OBJECT * ob, long buf)
{
WorkArea::up_cb(ob, buf);
{
WorkArea::down_cb(ob, buf);
}
-
+#endif
void C_WorkArea_scroll_cb(FL_OBJECT * ob, long buf)
{
WorkArea::scroll_cb(ob, buf);
// THE SCROLLBAR
//
+#ifdef USE_FL_SCROLLBAR
+ scrollbar = obj = fl_add_scrollbar(FL_VERT_SCROLLBAR,
+ xpos + width - 15,
+ ypos, 17, height, "");
+ fl_set_object_boxtype(obj, FL_UP_BOX);
+ //fl_set_object_color(obj, FL_MCOL, FL_BLUE);
+ fl_set_object_resize(obj, FL_RESIZE_ALL);
+ fl_set_object_gravity(obj, NorthEastGravity, SouthEastGravity);
+ obj->u_vdata = this;
+ fl_set_object_callback(obj, C_WorkArea_scroll_cb, 0);
+#else
// up - scrollbar button
fl_set_border_width(-1);
fl_set_pixmapbutton_data(obj, const_cast<char**>(down_xpm));
fl_set_border_width(-bw);
-
// Remove the blue feedback rectangle
fl_set_pixmapbutton_focus_outline(obj,0);
+#endif
///
/// The free object
//
// THE SCROLLBAR
//
-
+#ifdef USE_FL_SCROLLBAR
+ fl_set_object_geometry(scrollbar, xpos + width - 15,
+ ypos, 17, height);
+#else
// up - scrollbar button
fl_set_object_geometry(button_up, xpos + width - 15,
ypos,
fl_set_object_geometry(button_down, xpos + width - 15,
ypos + height - 15,
15, 15);
-
+#endif
// Create the workarea pixmap
createPixmap(width - 15 - 2 * bw, height - 2 * bw);
void WorkArea::setScrollbar(double pos, double length_fraction) const
{
+#ifdef USE_FL_SCROLLBAR
+ fl_set_scrollbar_value(scrollbar, pos);
+ fl_set_scrollbar_size(scrollbar, scrollbar->h * length_fraction);
+#else
fl_set_slider_value(scrollbar, pos);
fl_set_slider_size(scrollbar, scrollbar->h * length_fraction);
+#endif
}
void WorkArea::setScrollbarBounds(double l1, double l2) const
{
+#ifdef USE_FL_SCROLLBAR
+ fl_set_scrollbar_bounds(scrollbar, l1, l2);
+#else
fl_set_slider_bounds(scrollbar, l1, l2);
+#endif
}
-void WorkArea::setScrollbarIncrements(float inc) const
+void WorkArea::setScrollbarIncrements(double inc) const
{
+#ifdef USE_FL_SCROLLBAR
+ fl_set_scrollbar_increment(scrollbar, work_area->h - inc, inc);
+#else
fl_set_slider_increment(scrollbar, work_area->h - inc, inc);
+#endif
}
-
+#ifndef USE_FL_SCROLLBAR
void WorkArea::up_cb(FL_OBJECT * ob, long)
{
WorkArea * area = static_cast<WorkArea*>(ob->u_vdata);
ev2 = fl_last_event();
if (ev2->type == ButtonPress || ev2->type == ButtonRelease)
time = 0;
- //area->up(time++, fl_get_button_numb(ob));
area->owner->upCB(time++, fl_get_button_numb(ob));
}
static long time = 0;
if (ev2->type == ButtonPress || ev2->type == ButtonRelease)
time = 0;
- //area->down(time++, fl_get_button_numb(ob));
area->owner->downCB(time++, fl_get_button_numb(ob));
}
+#endif
// Callback for scrollbar slider
void WorkArea::scroll_cb(FL_OBJECT * ob, long)
{
WorkArea * area = static_cast<WorkArea*>(ob->u_vdata);
-
- //area->scroll(fl_get_slider_value(ob));
+#ifdef USE_FL_SCROLLBAR
+ // If we really want the accellerating scroll we can do that
+ // from here. IMHO that is a waste of effort since we already
+ // have other ways to move fast around in the document. (Lgb)
+ area->owner->scrollCB(fl_get_scrollbar_value(ob));
+#else
area->owner->scrollCB(fl_get_slider_value(ob));
+#endif
waitForX();
}
if (!ev || ! area->scrollbar) break;
if (ev->xmotion.x != x_old ||
ev->xmotion.y != y_old ||
- fl_get_slider_value(area->scrollbar) != scrollbar_value_old) {
+#ifdef USE_FL_SCROLLBAR
+ fl_get_scrollbar_value(area->scrollbar) != scrollbar_value_old
+#else
+ fl_get_slider_value(area->scrollbar) != scrollbar_value_old
+#endif
+ ) {
lyxerr.debug() << "Workarea event: MOUSE" << endl;
area->owner->workAreaMotionNotify(ev->xmotion.x - ob->x,
ev->xmotion.y - ob->y,
class BufferView;
+#define USE_FL_SCROLLBAR 1
+
class WorkArea {
public:
///
///
Painter & getPainter() { return painter_; }
///
- int workWidth() const { return work_area->w; }
+ unsigned int workWidth() const { return work_area->w; }
///
- int width() const { return work_area->w + scrollbar->w; }
+ unsigned int width() const { return work_area->w + scrollbar->w; }
///
- int height() const { return work_area->h; }
+ unsigned int height() const { return work_area->h; }
///
int xpos() const { return work_area->x; }
///
void redraw() const {
fl_redraw_object(work_area);
fl_redraw_object(scrollbar);
+#ifndef USE_FL_SCROLLBAR
fl_redraw_object(button_down);
fl_redraw_object(button_up);
+#endif
}
///
void setFocus() const;
///
void setScrollbar(double pos, double length_fraction) const;
///
- void setScrollbarValue(double y) const { fl_set_slider_value(scrollbar, y); }
+ void setScrollbarValue(double y) const {
+#ifdef USE_FL_SCROLLBAR
+ fl_set_scrollbar_value(scrollbar, y);
+#else
+ fl_set_slider_value(scrollbar, y);
+#endif
+ }
///
void setScrollbarBounds(double, double) const;
///
- void setScrollbarIncrements(float inc) const;
+ void setScrollbarIncrements(double inc) const;
///
double getScrollbarValue() const {
+#ifdef USE_FL_SCROLLBAR
+ return fl_get_scrollbar_value(scrollbar);
+#else
return fl_get_slider_value(scrollbar);
+#endif
}
+#ifdef USE_FL_SCROLLBAR
+ ///
+ std::pair<float, float> getScrollbarBounds() const {
+ std::pair<float, float> p;
+ fl_get_scrollbar_bounds(scrollbar, &p.first, &p.second);
+ return p;
+ }
+#else
///
std::pair<double, double> getScrollbarBounds() const {
std::pair<double, double> p;
fl_get_slider_bounds(scrollbar, &p.first, &p.second);
return p;
}
+#endif
///
Pixmap getPixmap() const { return workareapixmap; }
/// xforms callback
static int work_area_handler(FL_OBJECT *, int event,
FL_Coord, FL_Coord,
int /*key*/, void * xev);
+#ifndef USE_FL_SCROLLBAR
/// xforms callback
static void up_cb(FL_OBJECT *, long);
/// xforms callback
static void down_cb(FL_OBJECT *, long);
+#endif
/// xforms callback
static void scroll_cb(FL_OBJECT *, long);
private:
FL_OBJECT * work_area;
///
FL_OBJECT * scrollbar;
+#ifndef USE_FL_SCROLLBAR
///
FL_OBJECT * button_down;
///
FL_OBJECT * button_up;
+#endif
///
BufferView * owner;
/// The pixmap overlay on the workarea
#include "lyxlex.h"
#include "tex-strings.h"
#include "layout.h"
-//#include "lyx_cb.h"
#include "bufferview_funcs.h"
#include "minibuffer.h"
#include "lyxfont.h"
using std::endl;
using std::pair;
-// Uncomment this line to enable a workaround for the weird behaviour
-// of the cursor between a displayed inset and last character
-// at the upper line. (Alejandro 20.9.96)
-// #define BREAK_BEFORE_INSET
-
-/* Lars, when changing this file sometime in the future to a list,
- * please check out the figinsets-sideeffects described at the
- * beginning of figinset.C Matthias (04.07.1996)
- */
-
// all these externs should eventually be removed.
extern BufferList bufferlist;
}
-string Buffer::getLatexName(bool no_path /* = true */) const
+string Buffer::getLatexName(bool no_path) const
{
return ChangeExtension(MakeLatexName(filename),
".tex", no_path);
}
-void Buffer::setReadonly(bool flag /* = true */)
+void Buffer::setReadonly(bool flag)
{
if (read_only != flag) {
read_only = flag;
bool Buffer::saveParamsAsDefaults()
{
string fname = AddName(AddPath(user_lyxdir, "templates/"),
- "defaults.lyx");
+ "defaults.lyx");
Buffer defaults = Buffer(fname);
// Use the current buffer's parameters as default
bool the_end_read = false;
LyXParagraph * return_par = 0;
- LyXFont font(LyXFont::ALL_INHERIT,params.language_info);
+ LyXFont font(LyXFont::ALL_INHERIT, params.language_info);
if (format < 2.16 && params.language == "hebrew")
font.setLanguage(default_language);
LyXParagraph::footnote_flag & footnoteflag,
LyXParagraph::footnote_kind & footnotekind)
{
- int tmpret, tmpret2;
bool the_end_read = false;
if (token[0] != '\\') {
par->footnoteflag = footnoteflag;
par->footnotekind = footnotekind;
par->depth = depth;
- font = LyXFont(LyXFont::ALL_INHERIT,params.language_info);
+ font = LyXFont(LyXFont::ALL_INHERIT, params.language_info);
if (format < 2.16 && params.language == "hebrew")
font.setLanguage(default_language);
} else if (token == "\\end_float") {
if (format < 2.16 && params.language == "hebrew")
font.setLanguage(default_language);
} else if (token == "\\begin_float") {
- tmpret = lex.FindToken(string_footnotekinds);
+ int tmpret = lex.FindToken(string_footnotekinds);
if (tmpret == -1) ++tmpret;
if (tmpret != LYX_LAYOUT_DEFAULT)
footnotekind = static_cast<LyXParagraph::footnote_kind>(tmpret); // bad
} else if (token == "\\start_of_appendix") {
par->start_of_appendix = true;
} else if (token == "\\paragraph_separation") {
- tmpret = lex.FindToken(string_paragraph_separation);
+ int tmpret = lex.FindToken(string_paragraph_separation);
if (tmpret == -1) ++tmpret;
if (tmpret != LYX_LAYOUT_DEFAULT)
params.paragraph_separation =
// in existing documents are irretrivably lost. (Asger)
params.readGraphicsDriver(lex);
} else if (token == "\\quotes_language") {
- tmpret = lex.FindToken(string_quotes_language);
+ int tmpret = lex.FindToken(string_quotes_language);
if (tmpret == -1) ++tmpret;
if (tmpret != LYX_LAYOUT_DEFAULT) {
InsetQuotes::quote_language tmpl =
break;
}
} else if (token == "\\papersize") {
- tmpret = lex.FindToken(string_papersize);
+ int tmpret = lex.FindToken(string_papersize);
if (tmpret == -1)
++tmpret;
else
params.papersize2 = tmpret;
} else if (token == "\\paperpackage") {
- tmpret = lex.FindToken(string_paperpackages);
+ int tmpret = lex.FindToken(string_paperpackages);
if (tmpret == -1) {
++tmpret;
params.paperpackage = BufferParams::PACKAGE_NONE;
lex.nextToken();
params.use_amsmath = lex.GetInteger();
} else if (token == "\\paperorientation") {
- tmpret = lex.FindToken(string_orientation);
+ int tmpret = lex.FindToken(string_orientation);
if (tmpret == -1) ++tmpret;
if (tmpret != LYX_LAYOUT_DEFAULT)
params.orientation = static_cast<BufferParams::PAPER_ORIENTATION>(tmpret);
lex.next();
string tmp = strip(lex.GetString());
Spacing::Space tmp_space = Spacing::Default;
+ float tmp_val = 0.0;
if (tmp == "single") {
- params.spacing.set(Spacing::Single);
+ tmp_space = Spacing::Single;
} else if (tmp == "onehalf") {
- params.spacing.set(Spacing::Onehalf);
+ tmp_space = Spacing::Onehalf;
} else if (tmp == "double") {
- params.spacing.set(Spacing::Double);
+ tmp_space = Spacing::Double;
} else if (tmp == "other") {
lex.next();
- params.spacing.set(Spacing::Other,
- lex.GetFloat());
+ tmp_space = Spacing::Other;
+ tmp_val = lex.GetFloat();
} else {
lex.printError("Unknown spacing token: '$$Token'");
}
// Small hack so that files written with klyx will be
// parsed correctly.
if (return_par) {
- par->spacing.set(tmp_space);
+ par->spacing.set(tmp_space, tmp_val);
} else {
- params.spacing.set(tmp_space);
+ params.spacing.set(tmp_space, tmp_val);
}
} else if (token == "\\paragraph_spacing") {
lex.next();
font.setLanguage(params.language_info);
lex.printError("Unknown language `$$Token'");
}
-#if 0
- } else if (token == "\\direction") { // obsolete
- if (format >= 2.16)
- lex.printError("Command \\direction is obsolete");
- lex.next();
- string tok = lex.GetString();
- if (tok == "rtl")
- font.setLanguage(&languages["hebrew"]);
- else if (tok == "default")
- if (params.language == "hebrew")
- font.setLanguage(default_language);
- else
- font.setLanguage(params.language_info);
- else
- lex.printError("Unknown direction `$$Token'");
-#endif
} else if (token == "\\emph") {
lex.next();
font.setEmph(font.setLyXMisc(lex.GetString()));
lex.next();
font.setLyXColor(lex.GetString());
} else if (token == "\\align") {
- tmpret = lex.FindToken(string_align);
+ int tmpret = lex.FindToken(string_align);
if (tmpret == -1) ++tmpret;
if (tmpret != LYX_LAYOUT_DEFAULT) { // tmpret != 99 ???
- tmpret2 = 1;
+ int tmpret2 = 1;
for (; tmpret > 0; --tmpret)
tmpret2 = tmpret2 * 2;
par->align = LyXAlignment(tmpret2);
} else if (token == "\\labelwidthstring") {
lex.EatLine();
par->labelwidthstring = lex.GetString();
- /* do not delete this token, it is still needed! */
+ // do not delete this token, it is still needed!
} else if (token == "\\end_inset") {
- /* simple ignore this. The insets do not have
- * to read this */
- // but insets should read it, it is a part of
- //the inset isn't it? Lgb.
+ // Simply ignore this. The insets do not have
+ // to read this.
+ // But insets should read it, it is a part of
+ // the inset isn't it? Lgb.
} else if (token == "\\begin_inset") {
+ // Should be moved out into its own function/method. (Lgb)
lex.next();
string tmptok = lex.GetString();
- /* test the different insets */
+ // test the different insets
if (tmptok == "Quotes") {
Inset * inset = new InsetQuotes;
inset->Read(lex);
par->InsertInset(pos, inset);
par->SetFont(pos, font);
++pos;
+#if 0
} else if (tmptok == "\\i") {
Inset * inset = new InsetLatexAccent;
inset->Read(lex);
par->InsertInset(pos, inset);
par->SetFont(pos, font);
++pos;
+#endif
} else if (tmptok == "FormulaMacro") {
Inset * inset = new InsetFormulaMacro;
inset->Read(lex);
} else if (tmptok == "LatexCommand") {
InsetCommand inscmd;
inscmd.Read(lex);
- Inset * inset;
+ Inset * inset = 0;
if (inscmd.getCmdName() == "cite") {
inset = new InsetCitation(inscmd.getContents(), inscmd.getOptions());
} else if (inscmd.getCmdName() == "bibitem") {
if (!inscmd.getOptions().empty() || !inscmd.getContents().empty()) {
inset = new InsetRef(inscmd, this);
}
-#warning Check if this else clause is still needed. (Lgb)
+ // CHECK if this else clause
+ //is still needed. (Lgb)
#if 0
// This condition comes from a
// temporary solution to the latexdel
++pos;
}
}
+#if 0
} else if (token == "\\InsetQuotes") {
lyxerr << "InsetQuotes" << endl;
Inset * inset = new InsetQuotes;
par->InsertInset(pos, inset);
par->SetFont(pos, font);
++pos;
+#endif
+#if 0
} else if (token == "\\InsetFormula") {
lyxerr << "InsetFormula" << endl;
Inset * inset = new InsetFormula;
par->InsertInset(pos, inset);
par->SetFont(pos, font);
++pos;
+#endif
} else if (token == "\\SpecialChar") {
LyXLayout const & layout =
textclasslist.Style(params.textclass,
par->SetFont(pos, font);
}
++pos;
+#if 0
} else if (token == "\\Figure") {
lyxerr << "Figure" << endl;
Inset * inset = new InsetFig(100, 100, this);
par->InsertInset(pos, inset);
par->SetFont(pos, font);
++pos;
+#endif
} else if (token == "\\newline") {
par->InsertChar(pos, LyXParagraph::META_NEWLINE);
par->SetFont(pos, font);
par->SetFont(pos, font);
++pos;
} else if (token == "\\protected_separator") { // obsolete
+ // This is a backward compability thingie. (Lgb)
+ // Remove it later some time...introduced with fileformat
+ // 2.16. (Lgb)
LyXLayout const & layout =
textclasslist.Style(params.textclass,
par->GetLayout());
/* noindent ? */
/* what about the alignment */
- }
- else {
+ } else {
/* dummy layout, that means a footnote ended */
footnoteflag = LyXParagraph::NO_FOOTNOTE;
ofs << ") ";
noparbreak = 1;
}
- LyXLayout const & layout =
- textclasslist.Style(params.textclass,
- par->GetLayout());
+ //LyXLayout const & layout =
+ // textclasslist.Style(params.textclass,
+ // par->GetLayout()); // unused
//bool free_spc = layout.free_spacing; //unused
/* It might be a table */
clen[j] = h;
}
- font1 = LyXFont(LyXFont::ALL_INHERIT,params.language_info);
+ font1 = LyXFont(LyXFont::ALL_INHERIT, params.language_info);
actcell = 0;
for (i = 0, actpos = 1; i < par->size(); ++i, ++actpos) {
if (!i && !footnoteflag && !noparbreak){
islatex = 0;
else
islatex = 1;
- }
- else {
+ } else {
islatex = 0;
}
c = par->GetChar(i);
options += (*cit)->lang + ",";
}
if (default_language != params.language_info)
- options += default_language ->lang + ',';
+ options += default_language->lang + ',';
options += params.language_info->lang + ',';
}
texrow.newline();
}
- /* at the very beginning the text parameters */
+ // At the very beginning the text parameters.
if (params.paperpackage != BufferParams::PACKAGE_NONE) {
switch (params.paperpackage) {
case BufferParams::PACKAGE_A4:
string environment_stack[10];
string item_name;
- int depth = 0; /* paragraph depth */
+ int depth = 0; // paragraph depth
ofstream ofs(fname.c_str());
}
while (par) {
- int desc_on = 0; /* description mode*/
+ int desc_on = 0; // description mode
LyXLayout const & style =
textclasslist.Style(users->buffer()->params.textclass,
par->layout);
par->AutoDeleteInsets();
- /* treat <toc> as a special case for compatibility with old code */
+ // treat <toc> as a special case for compatibility with old code
if (par->GetChar(0) == LyXParagraph::META_INSET) {
Inset * inset = par->GetInset(0);
char lyx_code = inset->LyxCode();
case LATEX_COMMAND:
if (depth!= 0)
- LinuxDocError(par, 0, _("Error : Wrong depth for LatexType Command.\n"));
+ LinuxDocError(par, 0,
+ _("Error : Wrong depth for"
+ " LatexType Command.\n"));
if (!environment_stack[depth].empty()){
sgmlCloseTag(ofs, depth,
sgmlOpenTag(ofs, depth, temp);
}
environment_stack[depth] = style.latexname();
- sgmlOpenTag(ofs, depth, environment_stack[depth]);
+ sgmlOpenTag(ofs, depth,
+ environment_stack[depth]);
}
if(style.latextype == LATEX_ENVIRONMENT) break;
while(par && par->IsDummy());
ofs << "\n";
- /* write closing SGML tags */
+ // write closing SGML tags
switch(style.latextype) {
case LATEX_COMMAND:
case LATEX_ENVIRONMENT:
}
}
- /* Close open tags */
+ // Close open tags
for(; depth > 0; --depth)
sgmlCloseTag(ofs, depth, environment_stack[depth]);
sgmlCloseTag(os, depth + 1, inner_tag);
sgmlOpenTag(os, depth + 1, inner_tag);
}
- }
- else
+ } else {
os << "\n";
+ }
} else {
os << tmp_par;
if(!inner_tag.empty()) sgmlCloseTag(os, depth + 1,
}
-/* push a tag in a style stack */
+// push a tag in a style stack
void Buffer::push_tag(ostream & os, char const * tag,
int & pos, char stack[5][3])
{
- /* pop all previous tags */
+ // pop all previous tags
for (int j = pos; j >= 0; --j)
os << "</" << stack[j] << ">";
- /* add new tag */
+ // add new tag
sprintf(stack[++pos], "%s", tag);
- /* push all tags */
+ // push all tags
for (int i = 0; i <= pos; ++i)
os << "<" << stack[i] << ">";
}
}
-/* handle internal paragraph parsing -- layout already processed */
+// Handle internal paragraph parsing -- layout already processed.
// checks, if newcol chars should be put into this line
// writes newline, if necessary.
char shape_type = 0; // shape font flag
bool is_em = false; // emphasis (italic) font flag
- int stack_num = -1; // style stack position
+ int stack_num = -1; // style stack position
+ // Can this be rewritten to use a std::stack, please. (Lgb)
char stack[5][3]; // style stack
unsigned int char_line_count = 5; // Heuristic choice ;-)
else
main_body = par->BeginningOfMainBody();
- /* gets paragraph main font */
+ // gets paragraph main font
if (main_body > 0)
font1 = style.labelfont;
else
font1 = style.font;
- /* parsing main loop */
+ // parsing main loop
for (LyXParagraph::size_type i = 0;
i < par->size(); ++i) {
- /* handle quote tag */
+ // handle quote tag
if (i == main_body && !par->IsDummy()) {
if (main_body > 0)
font1 = style.font;
}
}
- /* handle bold face */
+ // handle bold face
if (font1.series() != font2.series()) {
if (font2.series() == LyXFont::BOLD_SERIES) {
push_tag(os, "bf", stack_num, stack);
}
}
- /* handle italic and slanted fonts */
+ // handle italic and slanted fonts
if (font1.shape() != font2.shape()) {
switch(shape_type) {
case 0:
}
}
}
- /* handle <em> tag */
+ // handle <em> tag
if (font1.emph() != font2.emph()) {
if (font2.emph() == LyXFont::ON) {
push_tag(os, "em", stack_num, stack);
font1 = font2;
}
- /* needed if there is an optional argument but no contents */
+ // needed if there is an optional argument but no contents
if (main_body > 0 && main_body == par->size()) {
font1 = style.font;
}
- /* pop all defined Styles */
+ // pop all defined Styles
for (j = stack_num; j >= 0; --j) {
linux_doc_line_break(os,
char_line_count,
os << "</" << stack[j] << ">";
}
- /* resets description flag correctly */
+ // resets description flag correctly
switch(desc_on){
case 1:
- /* <tag> not closed... */
+ // <tag> not closed...
linux_doc_line_break(os, char_line_count, 6);
os << "</tag>";
break;
case 2:
- /* fprintf(file, "</p>");*/
+ // fprintf(file, "</p>");
break;
}
}
-/* print an error message */
+// Print an error message.
void Buffer::LinuxDocError(LyXParagraph * par, int pos,
char const * message)
{
InsetError * new_inset;
- /* insert an error marker in text */
+ // insert an error marker in text
new_inset = new InsetError(message);
par->InsertChar(pos, LyXParagraph::META_INSET);
par->InsertInset(pos, new_inset);
LyXParagraph * par = paragraph;
string top_element= textclasslist.LatexnameOfClass(params.textclass);
+ // Please use a real stack.
string environment_stack[MAX_NEST_LEVEL];
string environment_inner[MAX_NEST_LEVEL];
+ // Please use a real stack.
string command_stack[MAX_NEST_LEVEL];
bool command_flag= false;
int command_depth= 0, command_base= 0, cmd_depth= 0;
string item_name, command_name;
string c_depth, c_params, tmps;
- int depth= 0; /* paragraph depth */
+ int depth = 0; // paragraph depth
tex_code_break_column = column;
}
while (par) {
- int desc_on = 0; /* description mode*/
+ int desc_on = 0; // description mode
LyXLayout const & style =
textclasslist.Style(users->buffer()->params.textclass,
par->layout);
par->AutoDeleteInsets();
- /* environment tag closing */
+ // environment tag closing
for( ; depth > par->depth; --depth) {
if(environment_inner[depth] != "!-- --") {
item_name= "listitem";
while(par && par->IsDummy());
string end_tag;
- /* write closing SGML tags */
+ // write closing SGML tags
switch(style.latextype) {
case LATEX_COMMAND:
end_tag = "title";
main_body = par->BeginningOfMainBody();
// gets paragraph main font
- //if (main_body > 0)
- // font1 = style.labelfont;
- //else
- // font1 = style.font;
LyXFont font1 = main_body > 0 ? style.labelfont : style.font;
int char_line_count = depth;
if (c != '\0')
os << c;
++char_line_count;
- }
- else {
+ } else {
string sgml_string;
if (par->linuxDocConvertChar(c, sgml_string)
&& !style.free_spacing) { // in freespacing
++char_line_count;
os << "\n</term><listitem><para>";
desc_on = 2;
- }
- else {
+ } else {
os << c;
}
- }
- else {
+ } else {
os << sgml_string;
}
}
font1 = font2;
}
- /* needed if there is an optional argument but no contents */
+ // needed if there is an optional argument but no contents
if (main_body > 0 && main_body == par->size()) {
font1 = style.font;
}
os << "</emphasis>";
}
- /* resets description flag correctly */
+ // resets description flag correctly
switch(desc_on){
case 1:
- /* <term> not closed... */
+ // <term> not closed...
os << "</term>";
break;
}
if (a || (res & LaTeX::ERRORS)){
users->redraw();
users->fitCursor();
- users->updateScrollbar();
+ //users->updateScrollbar();
}
AllowInput(users);
if (a || (res & Literate::ERRORS)){
users->redraw();
users->fitCursor();
- users->updateScrollbar();
+ //users->updateScrollbar();
}
AllowInput(users);
markNwClean();
}
- // if we removed error insets before we ran Literate/Build or if we inserted
- // error insets after we ran Literate/Build this must be run:
+ // if we removed error insets before we ran Literate/Build or
+ // if we inserted error insets after we ran Literate/Build this
+ // must be run:
if (a || (res & Literate::ERRORS)){
users->redraw();
users->fitCursor();
- users->updateScrollbar();
+ //users->updateScrollbar();
}
AllowInput(users);
if (a || res){
users->redraw();
users->fitCursor();
- users->updateScrollbar();
+ //users->updateScrollbar();
}
AllowInput(users);
} // end of switch
}
+
void Buffer::ChangeLanguage(Language const * from, Language const * to)
{
LyXParagraph * par = paragraph;
while (par) {
- par->ChangeLanguage(from,to);
+ par->ChangeLanguage(from, to);
par = par->next;
}
}
+
bool Buffer::isMultiLingual()
{
void redraw() {
users->redraw();
users->fitCursor();
- users->updateScrollbar();
+ //users->updateScrollbar();
}
///
::sleep(1);
XGrabServer(tempdisp);
}
+#ifdef HAVE_SSTREAM
XChangeProperty(tempdisp,
fl_get_canvas_id(figinset_canvas),
XInternAtom(tempdisp, "GHOSTVIEW", false),
XInternAtom(tempdisp, "STRING", false),
8, PropModeAppend,
-#ifdef HAVE_SSTREAM
reinterpret_cast<unsigned char*>(const_cast<char*>(t1.str().c_str())),
- t1.str().size()
+ t1.str().size());
#else
+
+ XChangeProperty(tempdisp,
+ fl_get_canvas_id(figinset_canvas),
+ XInternAtom(tempdisp, "GHOSTVIEW", false),
+ XInternAtom(tempdisp, "STRING", false),
+ 8, PropModeAppend,
reinterpret_cast<unsigned char*>(const_cast<char*>(t1.str())),
- strlen(t1.str())
+ ::strlen(t1.str()));
#endif
- );
XUngrabServer(tempdisp);
XFlush(tempdisp);
#ifdef HAVE_SSTREAM
ostringstream t3;
#else
- char tbuf3[384];
- ostrstream t3(tbuf3, sizeof(tbuf3));
+ //char tbuf[384];
+ ostrstream t3(tbuf, sizeof(tbuf));
#endif
switch (p->data->flags & 3) {
case 0: t3 << 'H'; break; // Hidden
#endif
XGrabServer(tempdisp);
+#ifdef HAVE_SSTREAM
XChangeProperty(tempdisp,
fl_get_canvas_id(figinset_canvas),
XInternAtom(tempdisp,
"GHOSTVIEW_COLORS", false),
XInternAtom(tempdisp, "STRING", false),
8, PropModeReplace,
-#ifdef HAVE_SSTREAM
reinterpret_cast<unsigned char*>(const_cast<char*>(t3.str().c_str())),
- t3.str().size()
+ t3.str().size());
#else
+ XChangeProperty(tempdisp,
+ fl_get_canvas_id(figinset_canvas),
+ XInternAtom(tempdisp,
+ "GHOSTVIEW_COLORS", false),
+ XInternAtom(tempdisp, "STRING", false),
+ 8, PropModeReplace,
reinterpret_cast<unsigned char*>(const_cast<char*>(t3.str())),
- strlen(t3.str())
+ ::strlen(t3.str()));
#endif
- );
XUngrabServer(tempdisp);
XFlush(tempdisp);
fl_hide_form(tmpfig->inset->form->Figure);
}
#if FL_REVISION == 89
-#warning Reactivate this free_form calls
+ // CHECK Reactivate this free_form calls
#else
fl_free_form(tmpfig->inset->form->Figure);
free(tmpfig->inset->form); // Why free?
fl_set_focus_object(form->Figure, form->OkBtn);
fl_hide_form(form->Figure);
#if FL_REVISION == 89
-#warning Reactivate this free_form calls
+ // CHECK Reactivate this free_form calls
#else
fl_free_form(form->Figure);
free(form); // Why free?
fl_set_focus_object(form->Figure, form->OkBtn);
fl_hide_form(form->Figure);
#if FL_REVISION == 89
-#warning Reactivate this free_form calls
-#warning Jug, is this still a problem?
+ // CHECK Reactivate this free_form calls
+ // Jug, is this still a problem?
#else
fl_free_form(form->Figure);
free(form); // Why free?
#include "gettext.h"
#include "lyxfont.h"
#include "BufferView.h"
-#include "lyxscreen.h"
#include "Painter.h"
#include "support/LOstream.h"
cursor.y = top_baseline;
y += cursor.y;
for(unsigned int i = 1;
- ((cursor.y + rows[i - 1].desc) < y) && (i < rows.size() - 1); ++i) {
+ (long(cursor.y + rows[i - 1].desc) < y)
+ && (i < rows.size() - 1); ++i) {
cursor.y = rows[i].baseline;
cursor.pos = rows[i].pos;
actrow = i;
#include "gettext.h"
Languages languages;
-Language const * default_language;
+Language const *default_language;
Language ignore_lang = {"ignore", "Ignore", false};
Language const * ignore_language = &ignore_lang;
bool RightToLeft;
};
+#if 0
+bool operator==(Language const & l1, Language const & l2)
+{
+ return l1.lang == l2.lang
+ && l1.display == l2.display
+ && l1.RightToLeft == l2.RightToLeft;
+}
+
+
+bool operator!=(Language const l1, Language const & l2)
+{
+ return !(l1 == l2);
+
+}
+#endif
+
typedef std::map<string, Language> Languages;
extern Languages languages;
extern Language const * default_language;
-extern Language const * ignore_language;
+extern Language const *ignore_language;
#endif
// the return code of the command. This means that all
// the code I added in PrintApplyCB is currently
// useless...
-#ifdef WITH_WARNINGS
-#warning What should we do here?
-#endif
+ // CHECK What should we do here?
ShowMessage(buffer, _("Executing command:"), cmd);
result = one.startscript(Systemcalls::System, cmd);
} else {
if (!bv->available())
return 0;
bv->buffer()->makeLinuxDocFile(name, 0);
-#ifdef WITH_WARNINGS
-#warning remove this once we have a proper geometry class
-#endif
+
+ // CHECK remove this once we have a proper geometry class
+
BufferParams::PAPER_SIZE ps =
static_cast<BufferParams::PAPER_SIZE>(bv->buffer()->params.papersize);
switch (ps) {
BufferParams * params = &(current_view->buffer()->params);
Language const * old_language = params->language_info;
- Language const * new_language;
params->language = combo_language->getline();
Languages::iterator lit = languages.find(params->language);
+
+ Language const * new_language;
if (lit != languages.end())
new_language = &(*lit).second;
else
Language const * lang =
current_view->text->cursor.par->getParLanguage();
- LyXFont font(LyXFont::ALL_INHERIT,lang);
+ LyXFont font(LyXFont::ALL_INHERIT, lang);
for (int i = 0; i < xsize * ysize - 1; ++i) {
current_view->text->cursor.par->InsertChar(0, LyXParagraph::META_NEWLINE);
current_view->text->cursor.par->SetFont(0, font);
///
int x_fix;
///
- long y;
+ unsigned long y;
///
Row * row;
};
/// Sets size after GUI name
LyXFont & LyXFont::setGUISize(string const & siz)
{
-#warning this might be wrong.
+ // CHECK this might be wrong.
/// ??????
// this is how it was how it was done in the lyx repository...
// but this does not make sense.
lang = l;
}
+
inline
LyXFont & LyXFont::operator=(LyXFont const & x)
{
if (selecting || owner->view()->text->mark_set) {
owner->view()->text->SetSelection();
owner->view()->toggleToggle();
- owner->view()->update(0);
- } else {
- owner->view()->update(-2); // this IS necessary
+ //owner->view()->update(0);
+ //} else {
+ //owner->view()->update(-2); // this IS necessary
// (Matthias)
}
-
+ owner->view()->update(0);
owner->view()->showCursor();
/* ---> Everytime the cursor is moved, show the current font state. */
if (owner->view()->removeAutoInsets()) {
owner->view()->redraw();
owner->view()->fitCursor();
- owner->view()->updateScrollbar();
+ //owner->view()->updateScrollbar();
}
break;
case LFUN_BREAKLINE:
owner->view()->beforeChange();
owner->view()->text->InsertChar(LyXParagraph::META_NEWLINE);
+#if 1
+ owner->view()->update(1);
+#else
owner->view()->smallUpdate(1);
+#endif
SetUpdateTimer(0.01);
moveCursorUpdate(false);
break;
owner->view()->text->Delete();
owner->view()->text->sel_cursor =
owner->view()->text->cursor;
+#if 1
+ owner->view()->update(1);
+#else
owner->view()->smallUpdate(1);
+#endif
// It is possible to make it a lot faster still
// just comment out the lone below...
owner->view()->showCursor();
owner->view()->text->Delete();
owner->view()->text->sel_cursor =
owner->view()->text->cursor;
+#if 1
+ owner->view()->update(1);
+#else
owner->view()->smallUpdate(1);
+#endif
}
} else {
owner->view()->text->Delete();
owner->view()->text->sel_cursor =
owner->view()->text->cursor;
+#if 1
+ owner->view()->update(1);
+#else
owner->view()->smallUpdate(1);
+#endif
}
} else {
owner->view()->cut();
owner->view()->text->Backspace();
owner->view()->text->sel_cursor =
owner->view()->text->cursor;
+#if 1
+ owner->view()->update(1);
+#else
owner->view()->smallUpdate(1);
+#endif
// It is possible to make it a lot faster still
// just comment out the lone below...
owner->view()->showCursor();
owner->view()->text->Backspace();
owner->view()->text->sel_cursor
= cursor;
+#if 1
+ owner->view()->update(1);
+#else
owner->view()->smallUpdate (1);
+#endif
}
} else
owner->view()->cut();
{
owner->view()->beforeChange();
owner->view()->text->BreakParagraph(0);
+#if 1
+ owner->view()->update(1);
+#else
owner->view()->smallUpdate(1);
+#endif
SetUpdateTimer(0.01);
owner->view()->text->sel_cursor =
owner->view()->text->cursor;
{
owner->view()->beforeChange();
owner->view()->text->BreakParagraph(1);
+#if 1
+ owner->view()->update(1);
+#else
owner->view()->smallUpdate(1);
+#endif
SetUpdateTimer(0.01);
owner->view()->text->sel_cursor =
owner->view()->text->cursor;
}
else {
owner->view()->text->BreakParagraph(0);
+#if 1
+ owner->view()->update(1);
+#else
owner->view()->smallUpdate(1);
+#endif
}
SetUpdateTimer(0.01);
owner->view()->text->sel_cursor = cursor;
case LFUN_QUOTE:
owner->view()->beforeChange();
owner->view()->text->InsertChar('\"'); // This " matches the single quote in the code
+#if 1
+ owner->view()->update(1);
+#else
owner->view()->smallUpdate(1);
+#endif
SetUpdateTimer();
moveCursorUpdate(false);
break;
keyseq.length = 0;
// copied verbatim from do_accent_char
+#if 1
+ owner->view()->update(1);
+#else
owner->view()->smallUpdate(1);
+#endif
SetUpdateTimer();
owner->view()->text->sel_cursor =
owner->view()->text->cursor;
owner->view()->text->InsertChar(argument[i]);
// This needs to be in the loop, or else we
// won't break lines correctly. (Asger)
+#if 1
+ owner->view()->update(1);
+#else
owner->view()->smallUpdate(1);
+#endif
}
SetUpdateTimer();
owner->view()->text->sel_cursor =
datetmp_len = (int) strftime(datetmp, 32, arg.c_str(), now_tm);
for (int i = 0; i < datetmp_len; i++) {
owner->view()->text->InsertChar(datetmp[i]);
+#if 1
+ owner->view()->update(1);
+#else
owner->view()->smallUpdate(1);
+#endif
}
SetUpdateTimer();
owner->view()->text->sel_cursor = owner->view()->text->cursor;
} else
owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->view()->text);
}
-
+
+#if 1
+ owner->view()->update(1);
+#else
owner->view()->smallUpdate(1);
+#endif
SetUpdateTimer();
owner->view()->text->sel_cursor =
///
struct Row {
///
- Row()
- : par(0), pos(0), baseline(0), fill(0), height(0),
- ascent_of_text(0), next(0), previous(0)
- {}
- ///
LyXParagraph * par;
///
LyXParagraph::size_type pos;
- ///
- unsigned short baseline;
/** what is missing to a full row can be negative.
Needed for hfills, flushright, block etc. */
mutable int fill;
unsigned short height;
///
unsigned short ascent_of_text;
-
+ ///
+ unsigned int baseline;
+ ///
+ Row()
+ : par(0), pos(0), fill(0), height(0),
+ ascent_of_text(0), baseline(0), next(0), previous(0)
+ {}
///
Row * next;
///
/** Draws the screen form textposition y. Uses as much of
the already printed pixmap as possible */
- void Draw(long y );
+ void Draw(unsigned long y );
/// Redraws the screen, without using existing pixmap
void Redraw();
/// Returns a new top so that the cursor is visible
- long TopCursorVisible();
+ unsigned long TopCursorVisible();
/// Redraws the screen such that the cursor is visible
- int FitCursor();
+ bool FitCursor();
///
void ShowCursor();
///
void ShowManualCursor(long x, long y, int asc, int desc,
Cursor_Shape shape);
/// returns 1 if first has changed, otherwise 0
- int FitManualCursor(long, long, int, int);
+ bool FitManualCursor(long, long, int, int);
///
void ToggleSelection(bool = true);
///
we only update the current row. */
void Update();
+#if 0
/** Updates part of the screen. Updates till row with cursor,
or only current row */
void SmallUpdate();
-
+#endif
/// first visible pixel-row
- long first;
+ unsigned long first;
///
bool cursor_visible;
/// y1 and y2 are coordinates of the screen
void DrawFromTo(int y1, int y2);
-
+
+#if 1
+ /// y is a coordinate of the text
+ void DrawOneRow(Row * row, long y_text);
+#else
/// y is a coordinate of the text
void DrawOneRow(Row * row, long & y_text);
+#endif
///
WorkArea & owner;
int cursor_pixmap_w;
///
int cursor_pixmap_h;
+#if 0
///
long screen_refresh_y;
///
Row * screen_refresh_row;
-
+#endif
///
GC gc_copy;
};
class Row;
class BufferView;
+
/**
This class holds the mapping between buffer paragraphs and screen rows.
*/
///
UNCHANGED,
///
- NEED_LITTLE_REFRESH,
- ///
NEED_MORE_REFRESH,
///
NEED_VERY_LITTLE_REFRESH
///
void InsertInset(Inset * inset);
- /// completes the insertion with a full rebreak
- int FullRebreak();
+ /** Completes the insertion with a full rebreak.
+ Returns true if something was broken. */
+ bool FullRebreak();
///
LyXParagraph::footnote_flag GetFootnoteFlag(int row);
mutable Row * firstrow;
///
mutable Row * lastrow;
-
+
/** Copybuffer for copy environment type
Asger has learned that this should be a buffer-property instead
Lgb has learned that 'char' is a lousy type for non-characters
*/
LyXTextClass::size_type copylayouttype;
- /// the currentrow is needed to access rows faster*/
- mutable Row * currentrow; // pointer to the current row
- /// position in the text
- mutable long currentrow_y;
-
/** inserts a new row behind the specified row, increments
* the touched counters */
void InsertRow(Row * row, LyXParagraph * par,
/// like NumberOfHfills, but only those in the manual label!
int NumberOfLabelHfills(Row const * row) const;
-
/** returns true, if a expansion is needed. Rules are given by
LaTeX
*/
bool HfillExpansion(Row const * row_ptr,
LyXParagraph::size_type pos) const;
+
///
mutable std::vector<LyXParagraph::size_type> log2vis_list;
//if it is not there? The reason why I want to avoid this is
// because of the "backlook" into the output stream.
// Lgb.
-#warning CHECK
#if 0
if (!suffixIs(outf, '\n')) {
// in batchmode we need to make sure
LyXFont font = GetFontSettings(i);
if (font.language() == from) {
font.setLanguage(to);
- SetFont(i,font);
+ SetFont(i, font);
}
}
}
/* the cursor isnt yet visible */
cursor_visible = false;
+#if 0
screen_refresh_y = -1;
-
+#endif
cursor_pixmap = 0;
cursor_pixmap_x = 0;
cursor_pixmap_y = 0;
void LyXScreen::Redraw()
{
DrawFromTo(0, owner.height());
+#if 0
screen_refresh_y = -1;
+#endif
expose(0, 0, owner.workWidth(), owner.height());
if (cursor_visible) {
cursor_visible = false;
}
+#if 1
+void LyXScreen::DrawOneRow(Row * row, long y_text)
+{
+ long y = y_text - first;
+
+ if (y + row->height > 0 && y - row->height <= long(owner.height())) {
+ /* ok there is something visible */
+ text->GetVisibleRow(y, row, y + first);
+ }
+}
+#else
void LyXScreen::DrawOneRow(Row * row, long & y_text)
{
long y = y_text - first;
- if (y + row->height > 0 && y - row->height <= owner.height()) {
+ if (y + row->height > 0 && y - row->height <= long(owner.height())) {
/* ok there is something visible */
text->GetVisibleRow(y, row, y + first);
}
y_text += row->height;
}
+#endif
/* draws the screen, starting with textposition y. uses as much already
* printed pixels as possible */
-void LyXScreen::Draw(long y)
+void LyXScreen::Draw(unsigned long y)
{
if (cursor_visible) HideCursor();
- if (y < 0) y = 0;
- long old_first = first;
+ //if (y < 0) y = 0;
+ unsigned long old_first = first;
first = y;
/* is any optimiziation possible? */
}
-/* returns 1 if first has changed, otherwise 0 */
-int LyXScreen::FitManualCursor(long /*x*/, long y, int asc, int desc)
+/* returns true if first has changed, otherwise false */
+bool LyXScreen::FitManualCursor(long /*x*/, long y, int asc, int desc)
{
- long newtop = first;
+ long newtop = first;
- if (y + desc - first >= owner.height())
+ if (y + desc - first >= owner.height())
newtop = y - 3 * owner.height() / 4; /* the scroll region must be so big!! */
- else if (y - asc < first
- && first > 0) {
+ else if (y - asc < long(first)
+ && first > 0) {
newtop = y - owner.height() / 4;
}
- if (newtop < 0)
- newtop = 0;
+ //if (newtop < 0)
+ newtop = max(newtop, 0L); // can newtop ever be < 0? (Lgb)
- if (newtop != first){
+ if (newtop != long(first)) {
Draw(newtop);
first = newtop;
- return 1;
+ return true;
}
- return 0;
+ return false;
}
-void LyXScreen::ShowManualCursor(long x, long y, int asc, int desc,
+void LyXScreen::ShowManualCursor(long x, long y, int asc, int desc,
Cursor_Shape shape)
{
- long y1 = max(y - first - asc, 0L);
- long y2 = min(y - first + desc, long(owner.height()));
+ unsigned long y1 = max(y - first - asc, 0UL);
+ typedef unsigned long ulong;
+
+ unsigned long y2 = min(y - first + desc, ulong(owner.height()));
// Secure against very strange situations
- if (y2 < y1) y2 = y1;
-
+ //if (y2 < y1) y2 = y1;
+ y2 = max(y2, y1);
+
if (cursor_pixmap){
XFreePixmap(fl_display, cursor_pixmap);
cursor_pixmap = 0;
}
- if (y2 > 0 && y1 <
- owner.height()) {
+ if (y2 > 0 && y1 < owner.height()) {
cursor_pixmap_h = y2 - y1 + 1;
cursor_pixmap_y = y1;
/* returns a new top so that the cursor is visible */
-long LyXScreen::TopCursorVisible()
+unsigned long LyXScreen::TopCursorVisible()
{
long newtop = first;
else
newtop = text->cursor.y
- 3 * owner.height() / 4; /* the scroll region must be so big!! */
- } else if (text->cursor.y - text->cursor.row->baseline < first
+ } else if (text->cursor.y - text->cursor.row->baseline < first
&& first > 0) {
if (text->cursor.row->height < owner.height()
&& text->cursor.row->height > owner.height() / 4)
newtop = text->cursor.y - text->cursor.row->baseline;
else {
newtop = text->cursor.y - owner.height() / 4;
- if (newtop > first)
- newtop = first;
+ //if (newtop > long(first))
+ newtop = min(newtop, long(first));
}
}
- if (newtop < 0)
- newtop = 0;
-
+ //if (newtop < 0)
+ // newtop = 0;
+ newtop = max(newtop, 0L);
+
return newtop;
}
/* scrolls the screen so that the cursor is visible, if necessary.
-* returns 1 if a change was made, otherwise 0 */
-int LyXScreen::FitCursor()
+* returns true if a change was made, otherwise false */
+bool LyXScreen::FitCursor()
{
- /* is a change necessary */
- long newtop = TopCursorVisible();
- int result = (newtop != first);
+ // Is a change necessary?
+ unsigned long newtop = TopCursorVisible();
+ bool result = (newtop != first);
if (result)
Draw(newtop);
return result;
void LyXScreen::Update()
{
+#if 1
+ switch(text->status) {
+ case LyXText::NEED_MORE_REFRESH:
+ {
+ long y = max(text->refresh_y - long(first), 0L);
+
+ DrawFromTo(y, owner.height());
+ text->refresh_y = 0;
+ text->status = LyXText::UNCHANGED;
+ expose(0, y,
+ owner.workWidth(), owner.height() - y);
+ }
+ break;
+ case LyXText::NEED_VERY_LITTLE_REFRESH:
+ {
+ /* ok I will update the current cursor row */
+ DrawOneRow(text->refresh_row, text->refresh_y);
+ text->status = LyXText::UNCHANGED;
+ expose(0, text->refresh_y - first,
+ owner.workWidth(), text->refresh_row->height);
+ }
+ break;
+ case LyXText::UNCHANGED:
+ // Nothing needs done
+ break;
+ }
+#else
if (text->status == LyXText::NEED_MORE_REFRESH
|| screen_refresh_y > -1 ) {
long y = 0;
else
y = text->refresh_y;
- if (y < first) y = first;
+ //if (y < first) y = first;
+ y = max(y, long(first));
DrawFromTo(y - first, owner.height());
text->refresh_y = 0;
expose(0, text->refresh_y - first,
owner.workWidth(), text->refresh_row->height);
}
+#endif
}
+#if 0
void LyXScreen::SmallUpdate()
{
+#if 1
+ Update();
+#else
if (text->status == LyXText::NEED_MORE_REFRESH) {
/* ok I will update till the current cursor row */
Row * row = text->refresh_row;
long y = text->refresh_y;
long y2 = y;
- if (y > text->cursor.y) {
+ if (y > long(text->cursor.y)) {
Update();
return;
}
while (row
&& row != text->cursor.row
- && y < first + owner.height()) {
+ && y < long(first + owner.height())) {
DrawOneRow(row, y);
row = row->next;
}
expose(0, text->refresh_y - first,
owner.workWidth(), text->refresh_row->height);
}
+#endif
}
+#endif
void LyXScreen::ToggleSelection(bool kill_selection)
/* only if there is a selection */
if (!text->selection) return;
- long top = text->sel_start_cursor.y
- - text->sel_start_cursor.row->baseline;
- long bottom = text->sel_end_cursor.y
- - text->sel_end_cursor.row->baseline
- + text->sel_end_cursor.row->height;
+ //long top = text->sel_start_cursor.y
+ // - text->sel_start_cursor.row->baseline;
+ //long bottom = text->sel_end_cursor.y
+ // - text->sel_end_cursor.row->baseline
+ // + text->sel_end_cursor.row->height;
- if (top < first)
- top = max(top, first);
- if (bottom < first)
- bottom = max(bottom, first);
+ //top = max(top, first);
+ //bottom = max(bottom, first);
- if (bottom > first + owner.height())
- bottom = first + owner.height();
- if (top > first + owner.height())
- top = first + owner.height();
+ //bottom = min(max(bottom, first), first + owner.height());
+ //top = min(max(top, first), first + owner.height());
+ long bottom = min(max(text->sel_end_cursor.y
+ - text->sel_end_cursor.row->baseline
+ + text->sel_end_cursor.row->height, first),
+ first + owner.height());
+ long top = min(max(text->sel_start_cursor.y
+ - text->sel_start_cursor.row->baseline, first),
+ first + owner.height());
if (kill_selection)
text->selection = 0;
- text->toggle_end_cursor.row->baseline
+ text->toggle_end_cursor.row->height;
- if (top - first < 0)
- top = first;
- if (bottom - first < 0)
- bottom = first;
+ //top = max(top, first);
+ //bottom = max(bottom, first);
+ typedef unsigned long ulong;
- if (bottom - first > owner.height())
- bottom = first + owner.height();
- if (top - first > owner.height())
- top = first + owner.height();
+ bottom = min(max(ulong(bottom), first), first + owner.height());
+ top = min(max(ulong(top), first), first + owner.height());
DrawFromTo(top - first, bottom - first);
expose(0, top - first, owner.workWidth(),
// Substitutes spaces with underscores in filename (and path)
string QuoteName(string const & name)
{
-#ifdef WITH_WARNINGS
-#warning Add proper emx support here!
-#endif
+ // CHECK Add proper emx support here!
#ifndef __EMX__
return '\'' + name + '\'';
#else
bool PutEnv(string const & envstr)
{
-#ifdef WITH_WARNINGS
-#warning Look at and fix this.
-#endif
+ // CHECK Look at and fix this.
// f.ex. what about error checking?
#if HAVE_PUTENV
// this leaks, but what can we do about it?
// Here, we should add the PID to a list of
// waiting processes to kill if they are not
// dead without tolerance seconds
-#ifdef WITH_WARNINGS
-#warning Implement this using the timer of the singleton systemcontroller (Asger)
-#endif
+
+ // CHECK Implement this using the timer of
+ // the singleton systemcontroller (Asger)
+
}
}
}
return x;
}
-
-
+
+
int LyXText::RightMargin(Row const * row) const
{
LyXLayout const & layout =
/* set the dimensions of the cursor row */
row->fill = Fill(row, paperwidth);
SetHeightOfRow(row);
-#warning See comment on top of text.C
+ // CHECK See comment on top of text.C
tmppar = tmppar->Next();
while (tmppar != endpar) {
/* redraw only the row */
LyXCursor tmpcursor = cursor;
SetCursorIntern(par, pos);
-#warning See comment on top of text.C
+ //CHECK See comment on top of text.C
refresh_y = y;
refresh_x = cursor.x;
refresh_row = row;
// The bug is triggered when we type in a description environment:
// The current_font is not changed when we go from label to main text
// and it should (along with realtmpfont) when we type the space.
-#ifdef WITH_WARNINGS
-#warning There is a bug here! (Asger)
-#endif
+ // CHECK There is a bug here! (Asger)
LyXFont realtmpfont = real_current_font;
LyXFont rawtmpfont = current_font; /* store the current font.
{
// treat floats, HFills and Insets as words
LyXCursor tmpcursor = cursor;
-#warning See comment on top of text.C
+ // CHECK See comment on top of text.C
if (tmpcursor.pos == tmpcursor.par->Last()
&& tmpcursor.par->Next())
if (!cursor.par->Last())
CursorRight();
-#warning See comment on top of text.C
+ // CHECK See comment on top of text.C
else {
/* -------> Skip initial non-word stuff. */
while ( cursor.pos < cursor.par->Last()
LyXCursor tmpcursor = cursor;
if (!cursor.par->Last())
CursorLeft();
-#warning See comment on top of text.C
+ // CHECK See comment on top of text.C
else{
selection = true; // to avoid deletion
CursorLeftOneWord();
LyXCursor tmpcursor = cursor;
if (!cursor.par->Last())
CursorRight();
-#warning See comment on top of text.C
+ // CHECK See comment on top of text.C
else {
CursorEnd();
sel_cursor = cursor;
// just move to the right
CursorRightIntern();
-#warning Look at the comment here.
+ // CHECK Look at the comment here.
// This check is not very good...
// The CursorRightIntern calls DeleteEmptyParagrapgMechanism
// and that can very well delete the par or par->previous in
PrepareToPrint(row_ptr, x, fill_separator,
fill_hfill, fill_label_hfill);
- /* initialize the pixmap */
-
+ // clear the area where we want to paint/print
pain.fillRectangle(0, offset, paperwidth, row_ptr->height);
if (selection) {
sel_end_cursor.x,
row_ptr->height,
LColor::selection);
- } else if (y > sel_start_cursor.y && y < sel_end_cursor.y) {
+ } else if (y > long(sel_start_cursor.y)
+ && y < long(sel_end_cursor.y)) {
pain.fillRectangle(0, offset,
paperwidth, row_ptr->height,
LColor::selection);
}
} else if ( sel_start_cursor.row != row_ptr &&
sel_end_cursor.row != row_ptr &&
- y > sel_start_cursor.y && y < sel_end_cursor.y) {
+ y > long(sel_start_cursor.y)
+ && y < long(sel_end_cursor.y)) {
pain.fillRectangle(0, offset,
paperwidth, row_ptr->height,
LColor::selection);
Row * LyXText::GetRow(LyXParagraph * par,
LyXParagraph::size_type pos, long & y) const
{
- Row * tmprow;
-
- if (currentrow) {
- if (par == currentrow->par
- || par == currentrow->par->Previous()) {
- // do not dereference par, it may have been deleted
- // already! (Matthias)
-
- // Walk backwards as long as the previous
- // rows par is not par
- while (currentrow->previous
- && currentrow->previous->par != par) {
- currentrow = currentrow->previous;
- currentrow_y -= currentrow->height;
- }
- // Walk backwards as long as the previous
- // rows par _is_ par
- while (currentrow->previous
- && currentrow->previous->par == par) {
- currentrow = currentrow->previous;
- currentrow_y -= currentrow->height;
- }
- }
-
- tmprow = currentrow;
- y = currentrow_y;
- // find the first row of the specified paragraph
- while (tmprow->next
- && tmprow->par != par) {
- y += tmprow->height;
- tmprow = tmprow->next;
- }
-
- if (tmprow->par == par){
- // now find the wanted row
- while (tmprow->pos < pos
- && tmprow->next
- && tmprow->next->par == par
- && tmprow->next->pos <= pos) {
- y += tmprow->height;
- tmprow = tmprow->next;
- }
- currentrow = tmprow;
- currentrow_y = y;
- return tmprow;
- }
- }
-
- tmprow = firstrow;
+ Row * tmprow = firstrow;
y = 0;
+
// find the first row of the specified paragraph
while (tmprow->next && tmprow->par != par) {
y += tmprow->height;
tmprow = tmprow->next;
}
- currentrow = tmprow;
- currentrow_y = y;
-
return tmprow;
}
owner_ = bv;
firstrow = 0;
lastrow = 0;
- currentrow = 0;
- currentrow_y = 0;
paperwidth = pw;
- //bparams = &p->params;
buffer = p;
number_of_rows = 0;
refresh_y = 0;
// Default layouttype for copy environment type
copylayouttype = 0;
+
+#if 0
+ // Dump all rowinformation:
+ Row * tmprow = firstrow;
+ lyxerr << "Baseline Paragraph Pos Height Ascent Fill\n";
+ while (tmprow) {
+ lyxerr << tmprow->baseline << '\t'
+ << tmprow->par << '\t'
+ << tmprow->pos << '\t'
+ << tmprow->height << '\t'
+ << tmprow->ascent_of_text << '\t'
+ << tmprow->fill << '\n';
+ tmprow = tmprow->next;
+ }
+ lyxerr.flush();
+#endif
}
row of this row */
long unused_y;
GetRow(row->par, row->pos, unused_y);
- currentrow = currentrow->previous;
- if (currentrow)
- currentrow_y -= currentrow->height;
- else
- currentrow_y = 0;
if (row->next)
row->next->previous = row->previous;
}
-int LyXText::FullRebreak()
+bool LyXText::FullRebreak()
{
if (need_break_row) {
BreakAgain(need_break_row);
need_break_row = 0;
- return 1;
+ return true;
}
- return 0;
+ return false;
}
/* returns a pointer to the row near the specified y-coordinate
* (relative to the whole text). y is set to the real beginning
-* of this row */
+* of this row */
Row * LyXText::GetRowNearY(long & y) const
{
- Row * tmprow;
- long tmpy;
-
- if (currentrow) {
- tmprow = currentrow;
- tmpy = currentrow_y;
- } else {
- tmprow = firstrow;
- tmpy = 0;
- }
-
- if (tmpy <= y)
- while (tmprow->next && tmpy + tmprow->height <= y) {
- tmpy += tmprow->height;
- tmprow = tmprow->next;
- }
- else
- while (tmprow->previous && tmpy > y) {
- tmprow = tmprow->previous;
- tmpy -= tmprow->height;
- }
+ Row * tmprow = firstrow;
+ long tmpy = 0;
- currentrow = tmprow;
- currentrow_y = tmpy;
+ while (tmprow->next && tmpy + tmprow->height <= y) {
+ tmpy += tmprow->height;
+ tmprow = tmprow->next;
+ }
y = tmpy; // return the real y
return tmprow;
}
-
+
void LyXText::ToggleFree(LyXFont const & font, bool toggleall)
{
void LyXText::CheckParagraph(LyXParagraph * par,
LyXParagraph::size_type pos)
{
-
- LyXCursor tmpcursor;
+ LyXCursor tmpcursor;
+
/* table stuff -- begin*/
if (undo->kind == Undo::EDIT) {
tmppar2->setContentsFromPar(tmppar);
tmppar->clearContents();
- //tmppar2->text = tmppar->text;
- //tmppar->text.clear();
tmppar2 = tmppar2->next;
}
- if ( currentrow && currentrow->par == tmppar )
- currentrow = currentrow -> previous;
- // Commenting out this might remove the error
- // reported by Purify, but it might also
- // introduce a memory leak. We need to
- // check this (Lgb)
- //delete tmppar;
}
}