]> git.lyx.org Git - lyx.git/blob - src/insets/insettext.C
cf3c5805e35016a8d640323aa6ed523c77708038
[lyx.git] / src / insets / insettext.C
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  * 
5  *           LyX, The Document Processor
6  *
7  *           Copyright 1998-2000 The LyX Team.
8  *
9  *           @author: Jürgen Vigna
10  *
11  * ======================================================
12  */
13
14 #include <config.h>
15
16 #include <fstream>
17 #include <algorithm>
18
19 #include <cstdlib>
20
21 #ifdef __GNUG__
22 #pragma implementation
23 #endif
24
25 #include "insettext.h"
26 #include "lyxparagraph.h"
27 #include "lyxlex.h"
28 #include "debug.h"
29 #include "lyxfont.h"
30 #include "commandtags.h"
31 #include "buffer.h"
32 #include "LyXView.h"
33 #include "BufferView.h"
34 #include "layout.h"
35 #include "LaTeXFeatures.h"
36 #include "Painter.h"
37 #include "lyx_gui_misc.h"
38 #include "lyxtext.h"
39 #include "lyxcursor.h"
40 #include "CutAndPaste.h"
41 #include "font.h"
42 #include "minibuffer.h"
43 #include "LColor.h"
44 #include "support/textutils.h"
45 #include "support/LAssert.h"
46 #include "lyxrow.h"
47 #include "lyxrc.h"
48 #include "intl.h"
49 #include "trans_mgr.h"
50 #include "lyxscreen.h"
51
52 using std::ostream;
53 using std::ifstream;
54 using std::endl;
55 using std::min;
56 using std::max;
57
58 extern unsigned char getCurrentTextClass(Buffer *);
59
60 InsetText::InsetText()
61 {
62     par = new LyXParagraph();
63     init();
64 }
65
66
67 InsetText::InsetText(InsetText const & ins)
68         : UpdatableInset()
69 {
70     par = 0;
71     init(&ins);
72     autoBreakRows = ins.autoBreakRows;
73 }
74
75
76 InsetText & InsetText::operator=(InsetText const & it)
77 {
78     init(&it);
79     autoBreakRows = it.autoBreakRows;
80     return * this;
81 }
82
83 void InsetText::init(InsetText const * ins)
84 {
85     top_y = last_width = last_height = 0;
86     insetAscent = insetDescent = insetWidth = 0;
87     the_locking_inset = 0;
88     cursor_visible = false;
89     interline_space = 1;
90     no_selection = false;
91     need_update = INIT;
92     drawTextXOffset = drawTextYOffset = 0;
93     autoBreakRows = false;
94     drawFrame = NEVER;
95     xpos = 0.0;
96     if (ins) {
97         SetParagraphData(ins->par);
98         autoBreakRows = ins->autoBreakRows;
99         drawFrame = ins->drawFrame;
100     }
101     par->SetInsetOwner(this);
102     frame_color = LColor::insetframe;
103     locked = false;
104     old_par = 0;
105 }
106
107
108 InsetText::~InsetText()
109 {
110     LyXParagraph * p = par->next;
111     delete par;
112     while(p) {
113         par = p;
114         p = p->next;
115         delete par;
116     }
117 }
118
119
120 void InsetText::clear()
121 {
122     LyXParagraph * p = par->next;
123     delete par;
124     while(p) {
125         par = p;
126         p = p->next;
127         delete par;
128     }
129     par = new LyXParagraph();
130 }
131
132
133 Inset * InsetText::Clone() const
134 {
135     InsetText * t = new InsetText(*this);
136     return t;
137 }
138
139
140 void InsetText::Write(Buffer const * buf, ostream & os) const
141 {
142     os << "Text\n";
143     WriteParagraphData(buf, os);
144 }
145
146
147 void InsetText::WriteParagraphData(Buffer const * buf, ostream & os) const
148 {
149     par->writeFile(buf, os, buf->params, 0, 0);
150 }
151
152
153 void InsetText::Read(Buffer const * buf, LyXLex & lex)
154 {
155     string token;
156     int pos = 0;
157     LyXParagraph * return_par = 0;
158     char depth = 0; // signed or unsigned?
159 #ifndef NEW_INSETS
160     LyXParagraph::footnote_flag footnoteflag = LyXParagraph::NO_FOOTNOTE;
161     LyXParagraph::footnote_kind footnotekind = LyXParagraph::FOOTNOTE;
162 #endif
163     LyXFont font(LyXFont::ALL_INHERIT);
164
165     LyXParagraph * p = par->next;
166     delete par;
167     while(p) {
168         par = p;
169         p = p->next;
170         delete par;
171     }
172     par = new LyXParagraph;
173     while (lex.IsOK()) {
174         lex.nextToken();
175         token = lex.GetString();
176         if (token.empty())
177             continue;
178         if (token == "\\end_inset")
179             break;
180         if (const_cast<Buffer*>(buf)->
181             parseSingleLyXformat2Token(lex, par, return_par,token, pos, depth,
182                                        font
183 #ifndef NEW_INSETS
184                                        , footnoteflag, footnotekind
185 #endif
186                                        ))
187         {
188             // the_end read this should NEVER happen
189             lex.printError("\\the_end read in inset! Error in document!");
190             return;
191         }
192     }
193     if (!return_par)
194             return_par = par;
195     par = return_par;
196     while(return_par) {
197         return_par->SetInsetOwner(this);
198         return_par = return_par->next;
199     }
200     
201     if (token != "\\end_inset") {
202         lex.printError("Missing \\end_inset at this point. "
203                        "Read: `$$Token'");
204     }
205     need_update = INIT;
206 }
207
208
209 int InsetText::ascent(BufferView * bv, LyXFont const &) const
210 {
211     long int y_temp = 0;
212     Row * row = TEXT(bv)->GetRowNearY(y_temp);
213     insetAscent = row->ascent_of_text() + TEXT_TO_INSET_OFFSET;
214     return insetAscent;
215 }
216
217
218 int InsetText::descent(BufferView * bv, LyXFont const &) const
219 {
220     long int y_temp = 0;
221     Row * row = TEXT(bv)->GetRowNearY(y_temp);
222     insetDescent = TEXT(bv)->height - row->ascent_of_text() +
223         TEXT_TO_INSET_OFFSET;
224     return insetDescent;
225 }
226
227
228 int InsetText::width(BufferView * bv, LyXFont const &) const
229 {
230     insetWidth = TEXT(bv)->width + (2 * TEXT_TO_INSET_OFFSET);
231     return insetWidth;
232 }
233
234
235 int InsetText::textWidth(Painter & pain) const
236 {
237     int w = getMaxWidth(pain, this);
238     return w;
239 }
240
241
242 void InsetText::draw(BufferView * bv, LyXFont const & f,
243                      int baseline, float & x, bool cleared) const
244 {
245     Painter & pain = bv->painter();
246
247     // no draw is necessary !!!
248     if ((drawFrame == LOCKED) && !locked && !par->size()) {
249         if (!cleared && (need_update == CLEAR_FRAME)) {
250             pain.rectangle(top_x + 1, baseline - insetAscent + 1,
251                            width(bv, f) - 1,
252                            insetAscent + insetDescent - 1,
253                            LColor::background);
254         }
255         top_x = int(x);
256         top_baseline = baseline;
257         x += width(bv, f);
258         need_update = NONE;
259         return;
260     }
261
262     xpos = x;
263     UpdatableInset::draw(bv, f, baseline, x, cleared);
264
265     if (!cleared && ((need_update==FULL) || (top_x!=int(x)) ||
266                      (top_baseline!=baseline))) {
267         int w =  insetWidth;
268         int h = insetAscent + insetDescent;
269         int ty = baseline - insetAscent;
270         
271         if (ty < 0) {
272             h += ty;
273             ty = 0;
274         }
275         if ((ty + h) > pain.paperHeight())
276             h = pain.paperHeight();
277         if ((top_x + drawTextXOffset + w) > pain.paperWidth())
278             w = pain.paperWidth();
279         pain.fillRectangle(top_x+drawTextXOffset, ty, w, h);
280         cleared = true;
281         need_update = FULL;
282     }
283     if (!cleared && (need_update == NONE))
284         return;
285
286     if (top_x != int(x)) {
287         need_update = INIT;
288         top_x = int(x);
289         bv->text->status = LyXText::CHANGED_IN_DRAW;
290         return;
291     }
292
293     top_baseline = baseline;
294     top_y = baseline - ascent(bv, f);
295     last_width = width(bv, f);
296     last_height = ascent(bv, f) + descent(bv, f);
297
298     if (the_locking_inset && (cpar(bv) == inset_par) && (cpos(bv) == inset_pos)) {
299         inset_x = cx(bv) - top_x + drawTextXOffset;
300         inset_y = cy(bv) + drawTextYOffset;
301     }
302     if (!cleared && (need_update == CURSOR) && !TEXT(bv)->selection) {
303         x += width(bv, f);
304         need_update = NONE;
305         return;
306     }
307     x += TEXT_TO_INSET_OFFSET;
308     long int y = 0;
309     Row * row = TEXT(bv)->GetRowNearY(y);
310     y += baseline - row->ascent_of_text();
311     if (cleared || !locked || (need_update == FULL)) {
312         while (row != 0) {
313             TEXT(bv)->GetVisibleRow(bv, y, int(x), row, y, cleared);
314             y += row->height();
315             row = row->next();
316         }
317     } else if (need_update == SELECTION) {
318         bv->screen()->ToggleToggle(TEXT(bv), y, int(x));
319     } else {
320         locked = false;
321         if (need_update == CURSOR) {
322             bv->screen()->ToggleSelection(TEXT(bv), true, y, int(x));
323             TEXT(bv)->ClearSelection();
324             TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
325         }
326         bv->screen()->Update(TEXT(bv), y, int(x));
327         locked = true;
328     }
329     TEXT(bv)->refresh_y = 0;
330     TEXT(bv)->status = LyXText::UNCHANGED;
331     if ((drawFrame == ALWAYS) || ((drawFrame == LOCKED) && locked)) {
332             pain.rectangle(top_x + 1, baseline - insetAscent + 1,
333                            width(bv, f) - 1, insetAscent + insetDescent - 1,
334                            frame_color);
335     } else if (need_update == CLEAR_FRAME) {
336             pain.rectangle(top_x + 1, baseline - insetAscent + 1,
337                            width(bv, f) - 1, insetAscent + insetDescent - 1,
338                            LColor::background);
339     }
340     x += width(bv, f) - TEXT_TO_INSET_OFFSET;
341     if (bv->text->status==LyXText::CHANGED_IN_DRAW)
342         need_update = INIT;
343     else if (need_update != INIT)
344         need_update = NONE;
345 }
346
347
348 void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
349 {
350     if (reinit) {  // && (need_update != CURSOR)) {
351         need_update = INIT;
352         resizeLyXText(bv);
353         if (owner())
354             owner()->update(bv, font, true);
355         return;
356     }
357     if (the_locking_inset) {
358         inset_x = cx(bv) - top_x + drawTextXOffset;
359         inset_y = cy(bv) + drawTextYOffset;
360         the_locking_inset->update(bv, font, reinit);
361     }
362     if (need_update == INIT) {
363         resizeLyXText(bv);
364         need_update = FULL;
365 //      if (!owner() && bv->text)
366 //          bv->text->UpdateInset(bv, this);
367     }
368     int oldw = insetWidth;
369 #if 1
370     insetWidth = TEXT(bv)->width + (2 * TEXT_TO_INSET_OFFSET);
371     // max(textWidth(bv->painter()),
372     // static_cast<int>(TEXT(bv)->width) + drawTextXOffset) +
373     // (2 * TEXT_TO_INSET_OFFSET);
374 #else
375     insetWidth = textWidth(bv->painter());
376     if (insetWidth < 0)
377             insetWidth = static_cast<int>(TEXT(bv)->width);
378 #endif
379     if (oldw != insetWidth) {
380 //          printf("TW(%p): %d-%d-%d-%d\n",this,insetWidth, oldw,
381 //                 textWidth(bv->painter()),static_cast<int>(TEXT(bv)->width));
382         resizeLyXText(bv);
383         need_update = FULL;
384 #if 0
385         if (owner()) {
386             owner()->update(bv, font, reinit);
387             return;
388         } else {
389             update(bv, font, reinit);
390         }
391 #else
392 #if 1
393         update(bv, font, reinit);
394 #else
395         UpdateLocal(bv, INIT, false);
396 #endif
397 #endif
398         return;
399     }
400     if ((need_update==CURSOR_PAR) && (TEXT(bv)->status==LyXText::UNCHANGED) &&
401         the_locking_inset)
402     {
403         TEXT(bv)->UpdateInset(bv, the_locking_inset);
404     }
405
406     if (TEXT(bv)->status == LyXText::NEED_MORE_REFRESH)
407         need_update = FULL;
408
409     long int y_temp = 0;
410     Row * row = TEXT(bv)->GetRowNearY(y_temp);
411     insetAscent = row->ascent_of_text() + TEXT_TO_INSET_OFFSET;
412     insetDescent = TEXT(bv)->height - row->ascent_of_text() +
413         TEXT_TO_INSET_OFFSET;
414 }
415
416
417 void InsetText::UpdateLocal(BufferView * bv, UpdateCodes what, bool mark_dirty)
418 {
419     TEXT(bv)->FullRebreak(bv);
420     if (need_update != INIT) {
421         if (TEXT(bv)->status == LyXText::NEED_MORE_REFRESH)
422             need_update = FULL;
423         else if (!the_locking_inset || (what != CURSOR))
424             need_update = what;
425     }
426     if ((need_update != CURSOR) || (TEXT(bv)->status != LyXText::UNCHANGED) ||
427         TEXT(bv)->selection)
428             bv->updateInset(this, mark_dirty);
429     bv->owner()->showState();
430     if (old_par != cpar(bv)) {
431             bv->owner()->setLayout(cpar(bv)->GetLayout());
432             old_par = cpar(bv);
433     }
434 }
435
436
437 char const * InsetText::EditMessage() const
438 {
439     return _("Opened Text Inset");
440 }
441
442
443 void InsetText::Edit(BufferView * bv, int x, int y, unsigned int button)
444 {
445 //    par->SetInsetOwner(this);
446     UpdatableInset::Edit(bv, x, y, button);
447
448     if (!bv->lockInset(this)) {
449         lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
450         return;
451     }
452     locked = true;
453     the_locking_inset = 0;
454     inset_pos = inset_x = inset_y = 0;
455     inset_par = 0;
456     old_par = 0;
457     if (!checkAndActivateInset(bv, x, y, button))
458         TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset,
459                                            y+TEXT(bv)->first+insetAscent);
460     TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
461     bv->text->FinishUndo();
462     UpdateLocal(bv, FULL, false);
463 }
464
465
466 void InsetText::InsetUnlock(BufferView * bv)
467 {
468     if (the_locking_inset) {
469         the_locking_inset->InsetUnlock(bv);
470         the_locking_inset = 0;
471     }
472     HideInsetCursor(bv);
473     no_selection = false;
474     locked = false;
475     TEXT(bv)->selection = 0;
476     UpdateLocal(bv, CLEAR_FRAME, false);
477     if (owner())
478             bv->owner()->setLayout(owner()->getLyXText(bv)
479                                     ->cursor.par()->GetLayout());
480     else
481             bv->owner()->setLayout(bv->text->cursor.par()->GetLayout());
482 }
483
484
485 bool InsetText::LockInsetInInset(BufferView * bv, UpdatableInset * inset)
486 {
487     lyxerr[Debug::INSETS] << "InsetText::LockInsetInInset(" << inset << "): ";
488     if (!inset)
489         return false;
490     if (inset == cpar(bv)->GetInset(cpos(bv))) {
491         lyxerr[Debug::INSETS] << "OK" << endl;
492         the_locking_inset = inset;
493         inset_x = cx(bv) - top_x + drawTextXOffset;
494         inset_y = cy(bv) + drawTextYOffset;
495         inset_pos = cpos(bv);
496         inset_par = cpar(bv);
497         TEXT(bv)->UpdateInset(bv, the_locking_inset);
498         return true;
499     } else if (the_locking_inset && (the_locking_inset == inset)) {
500         if (cpar(bv) == inset_par && cpos(bv) == inset_pos) {
501             lyxerr[Debug::INSETS] << "OK" << endl;
502             inset_x = cx(bv) - top_x + drawTextXOffset;
503             inset_y = cy(bv) + drawTextYOffset;
504         } else {
505             lyxerr[Debug::INSETS] << "cursor.pos != inset_pos" << endl;
506         }
507     } else if (the_locking_inset) {
508         lyxerr[Debug::INSETS] << "MAYBE" << endl;
509         return the_locking_inset->LockInsetInInset(bv, inset);
510     }
511     lyxerr[Debug::INSETS] << "NOT OK" << endl;
512     return false;
513 }
514
515
516 bool InsetText::UnlockInsetInInset(BufferView * bv, UpdatableInset * inset,
517                                    bool lr)
518 {
519     if (!the_locking_inset)
520         return false;
521     if (the_locking_inset == inset) {
522         the_locking_inset->InsetUnlock(bv);
523         TEXT(bv)->UpdateInset(bv, inset);
524         the_locking_inset = 0;
525         if (lr)
526             moveRight(bv, false);
527         old_par = 0; // force layout setting
528         UpdateLocal(bv, CURSOR_PAR, false);
529         return true;
530     }
531     return the_locking_inset->UnlockInsetInInset(bv, inset, lr);
532 }
533
534
535 bool InsetText::UpdateInsetInInset(BufferView * bv, Inset * inset)
536 {
537     if (!the_locking_inset)
538         return false;
539     if (the_locking_inset != inset) {
540         TEXT(bv)->UpdateInset(bv, the_locking_inset);
541         need_update = CURSOR_PAR;
542         return the_locking_inset->UpdateInsetInInset(bv, inset);
543     }
544 //    UpdateLocal(bv, FULL, false);
545     if (TEXT(bv)->UpdateInset(bv, inset))
546         UpdateLocal(bv, CURSOR_PAR, false);
547     if (cpar(bv) == inset_par && cpos(bv) == inset_pos) {
548         inset_x = cx(bv) - top_x + drawTextXOffset;
549         inset_y = cy(bv) + drawTextYOffset;
550     }
551     return true;
552 }
553
554
555 void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
556 {
557     no_selection = false;
558
559     int tmp_x = x - drawTextXOffset;
560     int tmp_y = y + insetAscent;
561     Inset * inset = bv->checkInsetHit(TEXT(bv), tmp_x, tmp_y, button);
562
563     HideInsetCursor(bv);
564     if (the_locking_inset) {
565         if (the_locking_inset == inset) {
566             the_locking_inset->InsetButtonPress(bv,x-inset_x,y-inset_y,button);
567             return;
568         } else if (inset) {
569             // otherwise unlock the_locking_inset and lock the new inset
570             the_locking_inset->InsetUnlock(bv);
571             inset_x = cx(bv) - top_x + drawTextXOffset;
572             inset_y = cy(bv) + drawTextYOffset;
573             inset->InsetButtonPress(bv, x - inset_x, y - inset_y, button);
574             inset->Edit(bv, x - inset_x, y - inset_y, button);
575             if (the_locking_inset) {
576                 UpdateLocal(bv, CURSOR_PAR, false);
577             }
578             return;
579         }
580         // otherwise only unlock the_locking_inset
581         the_locking_inset->InsetUnlock(bv);
582         the_locking_inset = 0;
583     }
584     if (bv->the_locking_inset) {
585         if (inset && inset->Editable() == Inset::HIGHLY_EDITABLE) {
586             UpdatableInset * uinset = static_cast<UpdatableInset*>(inset);
587             inset_x = cx(bv) - top_x + drawTextXOffset;
588             inset_y = cy(bv) + drawTextYOffset;
589             inset_pos = cpos(bv);
590             inset_par = cpar(bv);
591             uinset->InsetButtonPress(bv, x - inset_x, y - inset_y, button);
592             uinset->Edit(bv, x - inset_x, y - inset_y, 0);
593             if (the_locking_inset) {
594                 UpdateLocal(bv, CURSOR_PAR, false);
595             }
596             return;
597         }
598     }
599     if (!inset) {
600         TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset,
601                                            y+TEXT(bv)->first+insetAscent);
602         TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
603         UpdateLocal(bv, CURSOR, false);
604         bv->owner()->setLayout(cpar(bv)->GetLayout());
605         old_par = cpar(bv);
606     }
607     ShowInsetCursor(bv);
608 }
609
610
611 void InsetText::InsetButtonRelease(BufferView * bv, int x, int y, int button)
612 {
613     UpdatableInset * inset = 0;
614
615     if (the_locking_inset) {
616             the_locking_inset->InsetButtonRelease(bv,
617                                                   x - inset_x, y - inset_y,
618                                                   button);
619     } else {
620         if (cpar(bv)->GetChar(cpos(bv)) == LyXParagraph::META_INSET) {
621             inset = static_cast<UpdatableInset*>(cpar(bv)->GetInset(cpos(bv)));
622             if (inset->Editable() == Inset::HIGHLY_EDITABLE) {
623                 inset->InsetButtonRelease(bv, x - inset_x, y - inset_y,button);
624             } else {
625                 inset_x = cx(bv) - top_x + drawTextXOffset;
626                 inset_y = cy(bv) + drawTextYOffset;
627                 inset->InsetButtonRelease(bv, x - inset_x, y - inset_y,button);
628                 inset->Edit(bv, x - inset_x, y - inset_y, button);
629             }
630             UpdateLocal(bv, CURSOR_PAR, false);
631         }
632     }
633     no_selection = false;
634 }
635
636
637 void InsetText::InsetMotionNotify(BufferView * bv, int x, int y, int state)
638 {
639     if (the_locking_inset) {
640         the_locking_inset->InsetMotionNotify(bv, x - inset_x,
641                                              y - inset_y,state);
642         return;
643     }
644     if (!no_selection) {
645         HideInsetCursor(bv);
646         TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset,
647                                            y+TEXT(bv)->first+insetAscent);
648         TEXT(bv)->SetSelection();
649         if (TEXT(bv)->toggle_cursor.par()!=TEXT(bv)->toggle_end_cursor.par() ||
650             TEXT(bv)->toggle_cursor.pos()!=TEXT(bv)->toggle_end_cursor.pos())
651             UpdateLocal(bv, SELECTION, false);
652         ShowInsetCursor(bv);
653     }
654     no_selection = false;
655 }
656
657
658 void InsetText::InsetKeyPress(XKeyEvent * xke)
659 {
660     if (the_locking_inset) {
661         the_locking_inset->InsetKeyPress(xke);
662         return;
663     }
664 }
665
666
667 UpdatableInset::RESULT
668 InsetText::LocalDispatch(BufferView * bv,
669                          int action, string const & arg)
670 {
671     no_selection = false;
672     UpdatableInset::RESULT
673         result= UpdatableInset::LocalDispatch(bv, action, arg);
674     if (result != UNDISPATCHED) {
675         return DISPATCHED;
676     }
677
678     result=DISPATCHED;
679     if ((action < 0) && arg.empty())
680         return FINISHED;
681
682     if (the_locking_inset) {
683         result = the_locking_inset->LocalDispatch(bv, action, arg);
684         if (result == DISPATCHED_NOUPDATE)
685             return result;
686         else if (result == DISPATCHED) {
687             UpdateLocal(bv, CURSOR_PAR, false);
688             return result;
689         } else if (result == FINISHED) {
690             switch(action) {
691             case -1:
692             case LFUN_RIGHT:
693                 moveRight(bv, false);
694                 break;
695             case LFUN_DOWN:
696                 moveDown(bv);
697                 break;
698             }
699             the_locking_inset = 0;
700             return DISPATCHED;
701         }
702     }
703     HideInsetCursor(bv);
704     switch (action) {
705         // Normal chars
706     case -1:
707         if (bv->buffer()->isReadonly()) {
708             LyXBell();
709 //          setErrorMessage(N_("Document is read only"));
710             break;
711         }
712         if (!arg.empty()) {
713             /* Automatically delete the currently selected
714              * text and replace it with what is being
715              * typed in now. Depends on lyxrc settings
716              * "auto_region_delete", which defaults to
717              * true (on). */
718
719             bv->text->SetUndo(bv->buffer(), Undo::INSERT,
720 #ifndef NEW_INSETS
721                               bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
722                               bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next
723 #else
724                               bv->text->cursor.par()->previous,
725                               bv->text->cursor.par()->next
726 #endif
727                     );
728             if (lyxrc.auto_region_delete) {
729                 if (TEXT(bv)->selection){
730                     TEXT(bv)->CutSelection(bv, false);
731                 }
732             }
733             TEXT(bv)->ClearSelection();
734             for (string::size_type i = 0; i < arg.length(); ++i) {
735                 bv->owner()->getIntl()->getTrans()->TranslateAndInsert(arg[i], TEXT(bv));
736             }
737         }
738         UpdateLocal(bv, CURSOR_PAR, true);
739         break;
740         // --- Cursor Movements ---------------------------------------------
741     case LFUN_RIGHTSEL:
742         bv->text->FinishUndo();
743         moveRight(bv, false);
744         TEXT(bv)->SetSelection();
745         UpdateLocal(bv, SELECTION, false);
746         break;
747     case LFUN_RIGHT:
748         result = moveRight(bv);
749         bv->text->FinishUndo();
750         UpdateLocal(bv, CURSOR, false);
751         break;
752     case LFUN_LEFTSEL:
753         bv->text->FinishUndo();
754         moveLeft(bv, false);
755         TEXT(bv)->SetSelection();
756         UpdateLocal(bv, SELECTION, false);
757         break;
758     case LFUN_LEFT:
759         bv->text->FinishUndo();
760         result= moveLeft(bv);
761         UpdateLocal(bv, CURSOR, false);
762         break;
763     case LFUN_DOWNSEL:
764         bv->text->FinishUndo();
765         moveDown(bv);
766         TEXT(bv)->SetSelection();
767         UpdateLocal(bv, SELECTION, false);
768         break;
769     case LFUN_DOWN:
770         bv->text->FinishUndo();
771         result = moveDown(bv);
772         UpdateLocal(bv, CURSOR, false);
773         break;
774     case LFUN_UPSEL:
775         bv->text->FinishUndo();
776         moveUp(bv);
777         TEXT(bv)->SetSelection();
778         UpdateLocal(bv, SELECTION, false);
779         break;
780     case LFUN_UP:
781         bv->text->FinishUndo();
782         result = moveUp(bv);
783         UpdateLocal(bv, CURSOR, false);
784         break;
785     case LFUN_HOME:
786         bv->text->FinishUndo();
787         TEXT(bv)->CursorHome(bv);
788         UpdateLocal(bv, CURSOR, false);
789         break;
790     case LFUN_END:
791         TEXT(bv)->CursorEnd(bv);
792         UpdateLocal(bv, CURSOR, false);
793         break;
794     case LFUN_BACKSPACE:
795         bv->text->SetUndo(bv->buffer(), Undo::DELETE,
796 #ifndef NEW_INSETS
797           bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
798           bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next
799 #else
800           bv->text->cursor.par()->previous,
801           bv->text->cursor.par()->next
802 #endif
803                 );
804         TEXT(bv)->Backspace(bv);
805         UpdateLocal(bv, CURSOR_PAR, true);
806         break;
807     case LFUN_DELETE:
808         bv->text->SetUndo(bv->buffer(), Undo::DELETE,
809 #ifndef NEW_INSETS
810           bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
811           bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next
812 #else
813           bv->text->cursor.par()->previous,
814           bv->text->cursor.par()->next
815 #endif
816                 );
817         TEXT(bv)->Delete(bv);
818         UpdateLocal(bv, CURSOR_PAR, true);
819         break;
820     case LFUN_CUT:
821         bv->text->SetUndo(bv->buffer(), Undo::DELETE,
822 #ifndef NEW_INSETS
823           bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
824           bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next
825 #else
826           bv->text->cursor.par()->previous,
827           bv->text->cursor.par()->next
828 #endif
829                 );
830         TEXT(bv)->CutSelection(bv);
831         UpdateLocal(bv, CURSOR_PAR, true);
832         break;
833     case LFUN_COPY:
834         bv->text->FinishUndo();
835         TEXT(bv)->CopySelection(bv);
836         UpdateLocal(bv, CURSOR_PAR, false);
837         break;
838     case LFUN_PASTE:
839         if (!autoBreakRows) {
840             CutAndPaste cap;
841
842             if (cap.nrOfParagraphs() > 1) {
843                 WriteAlert(_("Impossible operation"),
844                            _("Cannot include more than one paragraph!"),
845                            _("Sorry."));
846                 break;
847             }
848         }
849         bv->text->SetUndo(bv->buffer(), Undo::INSERT,
850 #ifndef NEW_INSETS
851           bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
852           bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next
853 #else
854           bv->text->cursor.par()->previous,
855           bv->text->cursor.par()->next
856 #endif
857                 );
858         TEXT(bv)->PasteSelection(bv);
859         UpdateLocal(bv, CURSOR_PAR, true);
860         break;
861     case LFUN_BREAKPARAGRAPH:
862         if (!autoBreakRows)
863             return DISPATCHED;
864         TEXT(bv)->BreakParagraph(bv, 0);
865         UpdateLocal(bv, FULL, true);
866         break;
867     case LFUN_BREAKLINE:
868         if (!autoBreakRows)
869             return DISPATCHED;
870         bv->text->SetUndo(bv->buffer(), Undo::INSERT,
871 #ifndef NEW_INSETS
872             bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
873             bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next
874 #else
875             bv->text->cursor.par()->previous,
876             bv->text->cursor.par()->next
877 #endif
878                 );
879         TEXT(bv)->InsertChar(bv, LyXParagraph::META_NEWLINE);
880         UpdateLocal(bv, CURSOR_PAR, true);
881         break;
882     case LFUN_LAYOUT:
883     {
884       static LyXTextClass::size_type cur_layout = cpar(bv)->layout;
885       
886         // Derive layout number from given argument (string)
887         // and current buffer's textclass (number). */    
888         LyXTextClassList::ClassList::size_type tclass =
889             bv->buffer()->params.textclass;
890         std::pair <bool, LyXTextClass::size_type> layout = 
891             textclasslist.NumberOfLayout(tclass, arg);
892
893         // If the entry is obsolete, use the new one instead.
894         if (layout.first) {
895             string obs = textclasslist.Style(tclass,layout.second).
896                 obsoleted_by();
897             if (!obs.empty()) 
898                 layout = textclasslist.NumberOfLayout(tclass, obs);
899         }
900
901         // see if we found the layout number:
902         if (!layout.first) {
903             string msg = string(N_("Layout ")) + arg + N_(" not known");
904
905             bv->owner()->getMiniBuffer()->Set(msg);
906             break;
907         }
908
909         if (cur_layout != layout.second) {
910             cur_layout = layout.second;
911             TEXT(bv)->SetLayout(bv, layout.second);
912             bv->owner()->setLayout(cpar(bv)->GetLayout());
913             UpdateLocal(bv, CURSOR_PAR, true);
914         }
915     }
916     break;
917     case LFUN_PARAGRAPH_SPACING:
918             // This one is absolutely not working. When fiddling with this
919             // it also seems to me that the paragraphs inside the insettext
920             // inherit bufferparams/paragraphparams in a strange way. (Lgb)
921     {
922             LyXParagraph * par = TEXT(bv)->cursor.par();
923             Spacing::Space cur_spacing = par->spacing.getSpace();
924             float cur_value = 1.0;
925             if (cur_spacing == Spacing::Other) {
926                     cur_value = par->spacing.getValue();
927             }
928                         
929 #ifdef HAVE_SSTREAM
930             std::istringstream istr(arg.c_str());
931 #else
932             istrstream istr(arg.c_str());
933 #endif
934             string tmp;
935             istr >> tmp;
936             Spacing::Space new_spacing = cur_spacing;
937             float new_value = cur_value;
938             if (tmp.empty()) {
939                     lyxerr << "Missing argument to `paragraph-spacing'"
940                            << endl;
941             } else if (tmp == "single") {
942                     new_spacing = Spacing::Single;
943             } else if (tmp == "onehalf") {
944                     new_spacing = Spacing::Onehalf;
945             } else if (tmp == "double") {
946                     new_spacing = Spacing::Double;
947             } else if (tmp == "other") {
948                     new_spacing = Spacing::Other;
949                     float tmpval = 0.0;
950                     istr >> tmpval;
951                     lyxerr << "new_value = " << tmpval << endl;
952                     if (tmpval != 0.0)
953                             new_value = tmpval;
954             } else if (tmp == "default") {
955                     new_spacing = Spacing::Default;
956             } else {
957                     lyxerr << _("Unknown spacing argument: ")
958                            << arg << endl;
959             }
960             if (cur_spacing != new_spacing || cur_value != new_value) {
961                     par->spacing.set(new_spacing, new_value);
962                     //TEXT(bv)->RedoParagraph(owner->view());
963                     UpdateLocal(bv, CURSOR_PAR, true);
964                     //bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
965             }
966     }
967     break;
968         
969     default:
970         result = UNDISPATCHED;
971         break;
972     }
973     if (result != FINISHED) {
974         ShowInsetCursor(bv);
975     } else
976         bv->unlockInset(this);
977     return result;
978 }
979
980
981 int InsetText::Latex(Buffer const * buf, ostream & os, bool, bool) const
982 {
983     TexRow texrow;
984     buf->latexParagraphs(os, par, 0, texrow);
985     return texrow.rows();
986 }
987
988
989 void InsetText::Validate(LaTeXFeatures & features) const
990 {
991     LyXParagraph * p = par;
992     while(p) {
993         p->validate(features);
994         p = p->next;
995     }
996 }
997
998
999 int InsetText::BeginningOfMainBody(Buffer const * buf, LyXParagraph * p) const
1000 {
1001     if (textclasslist.Style(buf->params.textclass,
1002                             p->GetLayout()).labeltype != LABEL_MANUAL)
1003         return 0;
1004     else
1005         return p->BeginningOfMainBody();
1006 }
1007
1008
1009 void InsetText::GetCursorPos(BufferView * bv, int & x, int & y) const
1010 {
1011     x = cx(bv);
1012     y = cy(bv);
1013 }
1014
1015
1016 int InsetText::InsetInInsetY()
1017 {
1018     if (!the_locking_inset)
1019         return 0;
1020
1021     return (inset_y + the_locking_inset->InsetInInsetY());
1022 }
1023
1024
1025 void InsetText::ToggleInsetCursor(BufferView * bv)
1026 {
1027     if (the_locking_inset) {
1028         the_locking_inset->ToggleInsetCursor(bv);
1029         return;
1030     }
1031
1032     LyXFont font = TEXT(bv)->GetFont(bv->buffer(), cpar(bv), cpos(bv));
1033
1034     int asc = lyxfont::maxAscent(font);
1035     int desc = lyxfont::maxDescent(font);
1036   
1037     if (cursor_visible)
1038         bv->hideLockedInsetCursor();
1039     else
1040         bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc);
1041     cursor_visible = !cursor_visible;
1042 }
1043
1044
1045 void InsetText::ShowInsetCursor(BufferView * bv)
1046 {
1047     if (the_locking_inset) {
1048         the_locking_inset->ShowInsetCursor(bv);
1049         return;
1050     }
1051     if (!cursor_visible) {
1052         LyXFont font = TEXT(bv)->GetFont(bv->buffer(), cpar(bv), cpos(bv));
1053         
1054         int asc = lyxfont::maxAscent(font);
1055         int desc = lyxfont::maxDescent(font);
1056
1057         bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc);
1058         bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc);
1059         cursor_visible = true;
1060     }
1061 }
1062
1063
1064 void InsetText::HideInsetCursor(BufferView * bv)
1065 {
1066     if (cursor_visible) {
1067         bv->hideLockedInsetCursor();
1068         cursor_visible = false;
1069     }
1070     if (the_locking_inset)
1071         the_locking_inset->HideInsetCursor(bv);
1072 }
1073
1074
1075 UpdatableInset::RESULT
1076 InsetText::moveRight(BufferView * bv, bool activate_inset)
1077 {
1078     if (!cpar(bv)->next && (cpos(bv) >= cpar(bv)->Last()))
1079         return FINISHED;
1080     if (activate_inset && checkAndActivateInset(bv, false))
1081         return DISPATCHED;
1082     TEXT(bv)->CursorRight(bv);
1083     return DISPATCHED_NOUPDATE;
1084 }
1085
1086
1087 UpdatableInset::RESULT
1088 InsetText::moveLeft(BufferView * bv, bool activate_inset)
1089 {
1090     if (!cpar(bv)->previous && (cpos(bv) <= 0))
1091         return FINISHED;
1092     TEXT(bv)->CursorLeft(bv);
1093     if (activate_inset && checkAndActivateInset(bv, true))
1094         return DISPATCHED;
1095     return DISPATCHED_NOUPDATE;
1096 }
1097
1098
1099 UpdatableInset::RESULT
1100 InsetText::moveUp(BufferView * bv)
1101 {
1102     if (!crow(bv)->previous())
1103         return FINISHED;
1104     TEXT(bv)->CursorUp(bv);
1105     return DISPATCHED_NOUPDATE;
1106 }
1107
1108
1109 UpdatableInset::RESULT
1110 InsetText::moveDown(BufferView * bv)
1111 {
1112     if (!crow(bv)->next())
1113         return FINISHED;
1114     TEXT(bv)->CursorDown(bv);
1115     return DISPATCHED_NOUPDATE;
1116 }
1117
1118
1119 bool InsetText::InsertInset(BufferView * bv, Inset * inset)
1120 {
1121     if (the_locking_inset) {
1122         if (the_locking_inset->InsertInsetAllowed(inset))
1123             return the_locking_inset->InsertInset(bv, inset);
1124         return false;
1125     }
1126     bv->text->SetUndo(bv->buffer(), Undo::INSERT,
1127 #ifndef NEW_INSETS
1128               bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
1129               bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next
1130 #else
1131               bv->text->cursor.par()->previous,
1132               bv->text->cursor.par()->next
1133 #endif
1134             );
1135     if (inset->Editable() == Inset::IS_EDITABLE) {
1136         UpdatableInset * i = static_cast<UpdatableInset *>(inset);
1137         i->setOwner(static_cast<UpdatableInset *>(this));
1138     }
1139     TEXT(bv)->InsertInset(bv, inset);
1140     TEXT(bv)->selection = 0;
1141     UpdateLocal(bv, CURSOR_PAR, true);
1142     static_cast<UpdatableInset*>(inset)->Edit(bv, 0, 0, 0);
1143     return true;
1144 }
1145
1146
1147 UpdatableInset * InsetText::GetLockingInset()
1148 {
1149     return the_locking_inset ? the_locking_inset->GetLockingInset() : this;
1150 }
1151
1152
1153 UpdatableInset * InsetText::GetFirstLockingInsetOfType(Inset::Code c)
1154 {
1155     if (c == LyxCode())
1156         return this;
1157     if (the_locking_inset)
1158         return the_locking_inset->GetFirstLockingInsetOfType(c);
1159     return 0;
1160 }
1161
1162
1163 void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall)
1164 {
1165     TEXT(bv)->SetFont(bv, font, toggleall);
1166 }
1167
1168
1169 bool InsetText::checkAndActivateInset(BufferView * bv, bool behind)
1170 {
1171     if (cpar(bv)->GetChar(cpos(bv)) == LyXParagraph::META_INSET) {
1172         int x, y;
1173         Inset * inset =
1174             static_cast<UpdatableInset*>(cpar(bv)->GetInset(cpos(bv)));
1175         if (!inset || inset->Editable() != Inset::HIGHLY_EDITABLE)
1176             return false;
1177         LyXFont font = TEXT(bv)->GetFont(bv->buffer(), cpar(bv), cpos(bv));
1178         if (behind) {
1179             x = inset->width(bv, font);
1180             y = inset->descent(bv, font);
1181         } else {
1182             x = y = 0;
1183         }
1184         inset_x = cx(bv) - top_x + drawTextXOffset;
1185         inset_y = cy(bv) + drawTextYOffset;
1186         inset->Edit(bv, x-inset_x, y-inset_y, 0);
1187         if (!the_locking_inset)
1188             return false;
1189         UpdateLocal(bv, CURSOR_PAR, false);
1190         return true;
1191     }
1192     return false;
1193 }
1194
1195
1196 bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
1197                                       int button)
1198 {
1199     int tmp_x = x - drawTextXOffset;
1200     int tmp_y = y + insetAscent;
1201     Inset * inset = bv->checkInsetHit(TEXT(bv), tmp_x, tmp_y, button);
1202
1203     if (inset) {
1204         if (x < 0)
1205             x = insetWidth;
1206         if (y < 0)
1207             y = insetDescent;
1208         inset_x = cx(bv) - top_x + drawTextXOffset;
1209         inset_y = cy(bv) + drawTextYOffset;
1210         inset->Edit(bv, x - inset_x, y - inset_y, button);
1211         if (!the_locking_inset)
1212             return false;
1213         UpdateLocal(bv, CURSOR_PAR, false);
1214         return true;
1215     }
1216     return false;
1217 }
1218
1219
1220 int InsetText::getMaxWidth(Painter & pain, UpdatableInset const * inset) const
1221 {
1222     int w = UpdatableInset::getMaxWidth(pain, inset);
1223     if (w < 0) {
1224         return w;
1225     }
1226     if (owner()) {
1227         w = w - top_x + owner()->x();
1228         return w;
1229     }
1230     w -= (2 * TEXT_TO_INSET_OFFSET);
1231     return w - top_x;
1232 //    return  w - (2*TEXT_TO_INSET_OFFSET);
1233 }
1234
1235
1236 void InsetText::SetParagraphData(LyXParagraph *p)
1237 {
1238     LyXParagraph * np;
1239
1240     if (par) {
1241         np = par->next;
1242         delete par;
1243         while(np) {
1244             par = np;
1245             np = np->next;
1246             delete par;
1247         }
1248     }
1249     par = p->Clone();
1250     par->SetInsetOwner(this);
1251     np = par;
1252     while(p->next) {
1253         p = p->next;
1254         np->next = p->Clone();
1255         np->next->previous = np;
1256         np = np->next;
1257         np->SetInsetOwner(this);
1258     }
1259     need_update = INIT;
1260 }
1261
1262
1263 void InsetText::SetAutoBreakRows(bool flag)
1264 {
1265     if (flag != autoBreakRows) {
1266         autoBreakRows = flag;
1267         need_update = FULL;
1268         if (!flag)
1269             removeNewlines();
1270     }
1271 }
1272
1273
1274 void InsetText::SetDrawFrame(BufferView * bv, DrawFrame how)
1275 {
1276     if (how != drawFrame) {
1277         drawFrame = how;
1278         if (bv)
1279             UpdateLocal(bv, DRAW_FRAME, false);
1280     }
1281 }
1282
1283
1284 void InsetText::SetFrameColor(BufferView * bv, LColor::color col)
1285 {
1286     if (frame_color != col) {
1287         frame_color = col;
1288         if (bv)
1289             UpdateLocal(bv, DRAW_FRAME, false);
1290     }
1291 }
1292
1293 #if 0
1294 LyXFont InsetText::GetDrawFont(BufferView * bv, LyXParagraph * p, int pos) const
1295 {
1296     return TEXT(bv)->GetFont(bv->buffer(), p, pos);
1297 }
1298 #endif
1299
1300 int InsetText::cx(BufferView * bv) const
1301 {
1302     return TEXT(bv)->cursor.x() + top_x + TEXT_TO_INSET_OFFSET;
1303 }
1304
1305
1306 int InsetText::cy(BufferView * bv) const
1307 {
1308     LyXFont font;
1309     return TEXT(bv)->cursor.y() - ascent(bv, font) + TEXT_TO_INSET_OFFSET;
1310 }
1311
1312
1313 int InsetText::cpos(BufferView * bv) const
1314 {
1315     return TEXT(bv)->cursor.pos();
1316 }
1317
1318
1319 LyXParagraph * InsetText::cpar(BufferView * bv) const
1320 {
1321     return TEXT(bv)->cursor.par();
1322 }
1323
1324
1325 Row * InsetText::crow(BufferView * bv) const
1326 {
1327     return TEXT(bv)->cursor.row();
1328 }
1329
1330
1331 LyXText * InsetText::getLyXText(BufferView * bv) const
1332 {
1333     if (cache.find(bv) != cache.end())
1334         return cache[bv];
1335     LyXText * lt = new LyXText(const_cast<InsetText *>(this));
1336     lt->init(bv);
1337     cache[bv] = lt;
1338     if (the_locking_inset) {
1339         lt->SetCursor(bv, inset_par, inset_pos);
1340     }
1341     return lt;
1342 }
1343
1344
1345 void InsetText::deleteLyXText(BufferView * bv, bool recursive) const
1346 {
1347     cache.erase(bv);
1348     if (recursive) {
1349         /// then remove all LyXText in text-insets
1350         LyXParagraph * p = par;
1351         for(;p;p = p->next) {
1352             p->deleteInsetsLyXText(bv);
1353         }
1354     }
1355 }
1356
1357 void InsetText::resizeLyXText(BufferView * bv) const
1358 {
1359     if (!par->next && !par->size()) // resize not neccessary!
1360         return;
1361     if (cache.find(bv) == cache.end())
1362         return;
1363
1364     LyXParagraph * lpar = 0;
1365     LyXParagraph * selstartpar = 0;
1366     LyXParagraph * selendpar = 0;
1367     int pos = 0;
1368     int selstartpos = 0;
1369     int selendpos = 0;
1370     int selection = 0;
1371     int mark_set = 0;
1372
1373 //    ProhibitInput(bv);
1374
1375     lpar = TEXT(bv)->cursor.par();
1376     pos = TEXT(bv)->cursor.pos();
1377     selstartpar = TEXT(bv)->sel_start_cursor.par();
1378     selstartpos = TEXT(bv)->sel_start_cursor.pos();
1379     selendpar = TEXT(bv)->sel_end_cursor.par();
1380     selendpos = TEXT(bv)->sel_end_cursor.pos();
1381     selection = TEXT(bv)->selection;
1382     mark_set = TEXT(bv)->mark_set;
1383     deleteLyXText(bv, (the_locking_inset == 0));
1384
1385     if (lpar) {
1386         TEXT(bv)->selection = true;
1387         /* at this point just to avoid the Delete-Empty-Paragraph
1388          * Mechanism when setting the cursor */
1389         TEXT(bv)->mark_set = mark_set;
1390         if (selection) {
1391             TEXT(bv)->SetCursor(bv, selstartpar, selstartpos);
1392             TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
1393             TEXT(bv)->SetCursor(bv, selendpar, selendpos);
1394             TEXT(bv)->SetSelection();
1395             TEXT(bv)->SetCursor(bv, lpar, pos);
1396         } else {
1397             TEXT(bv)->SetCursor(bv, lpar, pos);
1398             TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
1399             TEXT(bv)->selection = false;
1400         }
1401     }
1402     if (bv->screen())
1403             TEXT(bv)->first = bv->screen()->TopCursorVisible(TEXT(bv));
1404     // this will scroll the screen such that the cursor becomes visible 
1405     bv->updateScrollbar();
1406 //    AllowInput(bv);
1407     if (the_locking_inset) {
1408         /// then resize all LyXText in text-insets
1409         inset_x = cx(bv) - top_x + drawTextXOffset;
1410         inset_y = cy(bv) + drawTextYOffset;
1411         LyXParagraph * p = par;
1412         for(;p;p = p->next) {
1413             p->resizeInsetsLyXText(bv);
1414         }
1415     }
1416     need_update = FULL;
1417 }
1418
1419
1420 void InsetText::removeNewlines()
1421 {
1422     LyXParagraph * p = par;
1423
1424     for(;p; p = p->next) {
1425         for(int i = 0; i < p->Last(); ++i) {
1426             if (p->GetChar(i) == LyXParagraph::META_NEWLINE)
1427                 p->Erase(i);
1428         }
1429     }
1430 }