Commit Graph

50 Commits

Author SHA1 Message Date
Abdelrazak Younes
4d5ae916ad Fix bug 3293 by Bernhard Roider:
This changes the semantics of isOK() and operator(), comments from Bernhard below:

With the old version of lyxlex it was _impossible_ to check whether reading an integer, float, ... succeeded or not. The current solution to check for is.bad() in some cases and in other cases use is.good() does not give the desired information. Moreover the result of is.bad() depends on the stl implementation and behaves different for linux and windows.

the bug was introduced by the patch that fixed the bug that crashed lyx when "inset-insert ert" was executed from the command buffer.
The lexer has the method isOK() which reflects the status of the stream is.
The operators void* and ! are not really well defined (they depend on the value of is.bad()). What is missing is a test if the last reading operation was successful and thus the returned value is valid.
That's what i implemented in this patch.

The new rule for using the lexer:

if you want to know if the lexer still has data to read (either from the stream or from the pushed token) then use "lex.isOK()".
If you want to test if the last reading operation was successful then use eg. "if (lex) {...}" or unsuccessful then use eg. "if (!lex) {...}"

an example:

int readParam(LyxLex &lex) {

    int param = 1; // default value
    if (lex.isOK()) { // the lexer has data to read
        int p;    // temporary variable
        lex >> p;
        if (lex) param = p; // only use the input if the reading operation was successful
    }
    return param;
}




git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17569 a592a061-630c-0410-9148-cb99ea01b6c8
2007-03-26 13:43:49 +00:00
Abdelrazak Younes
a780e25d38 Preliminary safeguard code to fix bug 3189.
* DocIterator::prevInset(): return 0 if the mathed cell() is empty.

* LCursor::info(): use prevInset() only if different from zero.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17104 a592a061-630c-0410-9148-cb99ea01b6c8
2007-02-08 08:44:45 +00:00
Abdelrazak Younes
1357910dd2 Add a const. A second const as in:
InsetBase const * const nextinset = = nextInset();

is not possible because InsetBase::asInsetMath() is not const.




git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16660 a592a061-630c-0410-9148-cb99ea01b6c8
2007-01-12 10:19:51 +00:00
Abdelrazak Younes
5078b7ab57 tiny optimisation.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16652 a592a061-630c-0410-9148-cb99ea01b6c8
2007-01-11 18:25:11 +00:00
Abdelrazak Younes
c7aac5e1c6 revert mistake.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16651 a592a061-630c-0410-9148-cb99ea01b6c8
2007-01-11 18:20:20 +00:00
Abdelrazak Younes
d4c037a427 optimization.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16650 a592a061-630c-0410-9148-cb99ea01b6c8
2007-01-11 18:05:09 +00:00
Abdelrazak Younes
8121036b50 optimization.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16649 a592a061-630c-0410-9148-cb99ea01b6c8
2007-01-11 17:40:23 +00:00
Abdelrazak Younes
a2e981066b properly inline inMathed() and inTexted().
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16607 a592a061-630c-0410-9148-cb99ea01b6c8
2007-01-08 15:30:17 +00:00
Abdelrazak Younes
47adc642a3 header cleanup following rev 16332.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16333 a592a061-630c-0410-9148-cb99ea01b6c8
2006-12-19 14:09:47 +00:00
Abdelrazak Younes
4eb12c683b Moves textRow() from DocIterator to cursor.C where it belongs.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16332 a592a061-630c-0410-9148-cb99ea01b6c8
2006-12-19 13:39:46 +00:00
Jean-Marc Lasgouttes
1248ce1acb * dociterator.C (forwardPar): remove debug code.
(forwardInset): speed up (like forwardPar).



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15848 a592a061-630c-0410-9148-cb99ea01b6c8
2006-11-10 23:31:21 +00:00
André Pönitz
6c300f72a2 move everything into namespace lyx
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15422 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-21 00:16:43 +00:00
André Pönitz
e89625ef28 rename mathed/math_xinset into mathed/InsetMathX
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15026 a592a061-630c-0410-9148-cb99ea01b6c8
2006-09-17 09:14:18 +00:00
André Pönitz
2805c29734 rename Math*Inset into InsetMath*
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15023 a592a061-630c-0410-9148-cb99ea01b6c8
2006-09-16 18:11:38 +00:00
Jean-Marc Lasgouttes
904fde99e2 * dociterator.C (forwardPosNoDescend): when at the end of the
inset, leave it, like forwardPos does (bug 2510).



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14645 a592a061-630c-0410-9148-cb99ea01b6c8
2006-08-13 15:29:59 +00:00
Lars Gullik Bjønnes
3b9338a3a8 Whitespace cleanup.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13565 a592a061-630c-0410-9148-cb99ea01b6c8
2006-04-05 23:56:29 +00:00
Jürgen Spitzmüller
02127298e7 Implement a dociterator::forwardPos() variant that skips collapsed insets and use that in bruteFind() (fixes bug 2241 and bug 2094)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10782 a592a061-630c-0410-9148-cb99ea01b6c8
2006-01-28 09:46:58 +00:00
Jürgen Spitzmüller
f200823716 fix initialization of insetOwner after undo (bug 1952).
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10619 a592a061-630c-0410-9148-cb99ea01b6c8
2005-11-24 16:22:39 +00:00
Jean-Marc Lasgouttes
8679982264 fix crash with DEPM when the cursor goes in a deeper inset
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10573 a592a061-630c-0410-9148-cb99ea01b6c8
2005-10-25 09:14:11 +00:00
Lars Gullik Bjønnes
a97c06ef62 fix init order
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10277 a592a061-630c-0410-9148-cb99ea01b6c8
2005-07-17 12:26:25 +00:00
Jürgen Vigna
4126b3f828 Add parameter boundary for getRow() function
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10276 a592a061-630c-0410-9148-cb99ea01b6c8
2005-07-17 12:02:48 +00:00
Jean-Marc Lasgouttes
cae1cb6830 initialize boundary
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10241 a592a061-630c-0410-9148-cb99ea01b6c8
2005-07-16 14:35:33 +00:00
Jürgen Spitzmüller
3cfdaf0a9a fix undo in tabular cells (bug 1808)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10115 a592a061-630c-0410-9148-cb99ea01b6c8
2005-07-01 12:36:28 +00:00
Angus Leeming
fb70c52b05 Whitespace, only whitespace.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9877 a592a061-630c-0410-9148-cb99ea01b6c8
2005-04-26 11:12:20 +00:00
Jean-Marc Lasgouttes
1fa17d5389 compilation fix when assertions are disabled
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9697 a592a061-630c-0410-9148-cb99ea01b6c8
2005-03-07 11:03:45 +00:00
Jean-Marc Lasgouttes
1e7112db43 fix counters updating mechanism
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9682 a592a061-630c-0410-9148-cb99ea01b6c8
2005-02-25 11:55:36 +00:00
Jürgen Spitzmüller
3c4af0ffbf Andr�'s font changes fix
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9621 a592a061-630c-0410-9148-cb99ea01b6c8
2005-02-14 08:17:23 +00:00
Lars Gullik Bjønnes
aa491cdb98 dociterator dont inherit from std::vector and updates
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9602 a592a061-630c-0410-9148-cb99ea01b6c8
2005-02-08 13:18:05 +00:00
Angus Leeming
e22c5f4d97 Asger's commentary, const-correct and bug-squashing little beauty.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9558 a592a061-630c-0410-9148-cb99ea01b6c8
2005-01-31 16:29:48 +00:00
Alfredo Braunstein
a2cd656e25 CoordBranch merge
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9325 a592a061-630c-0410-9148-cb99ea01b6c8
2004-11-30 01:59:49 +00:00
Alfredo Braunstein
ed064bdee6 par->pit renaming
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9300 a592a061-630c-0410-9148-cb99ea01b6c8
2004-11-24 21:53:46 +00:00
André Pönitz
292e28b228 fix redo creation crash, explanation later
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9172 a592a061-630c-0410-9148-cb99ea01b6c8
2004-11-05 06:12:21 +00:00
André Pönitz
f7a01cc616 workaround crash in undo. This is not a proper fix but 'works'.
Have a look at the new 'FIXME' if yiou are interested...


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9112 a592a061-630c-0410-9148-cb99ea01b6c8
2004-10-23 11:04:41 +00:00
André Pönitz
11c69712d3 *** empty log message ***
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8931 a592a061-630c-0410-9148-cb99ea01b6c8
2004-08-14 21:03:55 +00:00
Lars Gullik Bjønnes
e34a1e90af obvious stuff
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8851 a592a061-630c-0410-9148-cb99ea01b6c8
2004-07-25 00:04:42 +00:00
André Pönitz
b447408de2 macro rework
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8644 a592a061-630c-0410-9148-cb99ea01b6c8
2004-04-13 06:27:29 +00:00
André Pönitz
6c9b23105c fix table crash;
selection by mouse


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8617 a592a061-630c-0410-9148-cb99ea01b6c8
2004-04-07 08:07:26 +00:00
Lars Gullik Bjønnes
68b7ef25fb simple ws changes only
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8594 a592a061-630c-0410-9148-cb99ea01b6c8
2004-04-03 08:37:12 +00:00
Alfredo Braunstein
303a6c126c s/DocumentIterator/DocIterator/g a.k.a showing off my sed abilities. Sorry for the cvs spam.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8574 a592a061-630c-0410-9148-cb99ea01b6c8
2004-03-31 19:11:56 +00:00
Angus Leeming
72dd20be15 Added/corrected header blurb.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8563 a592a061-630c-0410-9148-cb99ea01b6c8
2004-03-30 12:14:01 +00:00
Alfredo Braunstein
610e905ed3 change iterators ctors, implement backwardPos
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8562 a592a061-630c-0410-9148-cb99ea01b6c8
2004-03-30 08:18:09 +00:00
Alfredo Braunstein
3e80b0b318 the pariterator stuff
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8554 a592a061-630c-0410-9148-cb99ea01b6c8
2004-03-28 22:00:22 +00:00
André Pönitz
f16f69eb0c add forwardInset, operator! etc
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8541 a592a061-630c-0410-9148-cb99ea01b6c8
2004-03-27 12:37:41 +00:00
André Pönitz
0d43ba149a the stuff from the sneak preview:
For one, it still contains a few things that are already in CVS (the
'brown paperbag' changes).

Secondly, this changes the ParagraphList to a std::vector but does not
yet take full advantage of it except removing LyXText::parOffset() and
similar.

I had an extensive talk with my profiler and we are happy nevertheless.

This also moves almost all Cut&Paste specific stuff from text.C to
CutAndPaste.C. Much smaller interface now... Namespace CutAndPaste is
now  lyx::cap::. Was inconsistent with the rest....

Make ParagraphList a proper class. We'll need this later for a
specialized erase/insert.

Remove some unneeded prototypes and function declarations

Use ParameterStruct directly instead of ShareContainer<ParameterStruct>

Inline a few accesses to CursorSlice members as suggested by the profiler.

Fix commandline conversion crash reported by Kayvan.

Replace PosIterator by DocumentIterator. The latter can also iterate
through math and nested text in math...

Remove math specific hack from Documentiterator

Derive InsetCollapsable from InsetText instead of using an InsetText
member. This give us the opportunity to get rid of the InsetOld::owner_
backpointer.

Cosmetics in CutAndPaste.C and cursor.C. Fix nasty crash (popping slices
off an empty selection anchor). Add a few asserts.

Remove all 'manual' update calls. We do now one per user interaction which
is completely sufficient.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8527 a592a061-630c-0410-9148-cb99ea01b6c8
2004-03-25 09:16:36 +00:00
André Pönitz
bddfd8ff66 more privacy for CursorSlice members
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8505 a592a061-630c-0410-9148-cb99ea01b6c8
2004-03-18 16:41:45 +00:00
André Pönitz
5198e1d9a3 The Buffer::LyXText -> Buffer::InsetText patch
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8498 a592a061-630c-0410-9148-cb99ea01b6c8
2004-03-18 12:53:43 +00:00
André Pönitz
ec4ab8ce18 revert Buffer LyxText->InsetText commit
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8489 a592a061-630c-0410-9148-cb99ea01b6c8
2004-03-11 17:16:38 +00:00
André Pönitz
1b3f5ee46f the Buffer::text -> inset change
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8488 a592a061-630c-0410-9148-cb99ea01b6c8
2004-03-11 16:09:42 +00:00
André Pönitz
4c8d536692 redo undo
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8481 a592a061-630c-0410-9148-cb99ea01b6c8
2004-03-08 21:14:45 +00:00
André Pönitz
fc52df8243 the DocIterator stuff
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8472 a592a061-630c-0410-9148-cb99ea01b6c8
2004-03-01 17:12:09 +00:00