]> git.lyx.org Git - lyx.git/blobdiff - src/text.C
remove more forms.h cruft
[lyx.git] / src / text.C
index 06d534a349fc6755416cedc01cba1d864a57007d..5f69db7ed7079fe5809635366c916d87f39f4da9 100644 (file)
@@ -2018,7 +2018,7 @@ void LyXText::prepareToPrint(BufferView * bview,
           if (row->par()->getChar(row->pos()) == Paragraph::META_INSET
               && (inset=row->par()->getInset(row->pos()))
               && (inset->display())) // || (inset->scroll() < 0)))
-            align = (inset->LyxCode() == Inset::MATHMACRO_CODE)
+            align = (inset->lyxCode() == Inset::MATHMACRO_CODE)
                     ? LYX_ALIGN_BLOCK : LYX_ALIGN_CENTER;
 
           switch (align) {
@@ -2271,7 +2271,7 @@ string const LyXText::selectNextWord(BufferView * bview,
               && (cursor.par()->isLetter(cursor.pos())) 
                   || (cursor.par()->getChar(cursor.pos()) == Paragraph::META_INSET
                       && cursor.par()->getInset(cursor.pos()) != 0
-                      && cursor.par()->getInset(cursor.pos())->Latex(bview->buffer(), latex, false, false) == 0
+                      && cursor.par()->getInset(cursor.pos())->latex(bview->buffer(), latex, false, false) == 0
                       && latex.str() == "\\-"
                           ))
                cursor.pos(cursor.pos() + 1);
@@ -2304,7 +2304,7 @@ void LyXText::selectSelectedWord(BufferView * bview)
               && (cursor.par()->isLetter(cursor.pos())
                   || (cursor.par()->getChar(cursor.pos()) == Paragraph::META_INSET
                       && cursor.par()->getInset(cursor.pos()) != 0
-                      && cursor.par()->getInset(cursor.pos())->Latex(bview->buffer(), latex, false, false) == 0
+                      && cursor.par()->getInset(cursor.pos())->latex(bview->buffer(), latex, false, false) == 0
                       && latex.str() == "\\-"
                           )))
                cursor.pos(cursor.pos() + 1);
@@ -2396,49 +2396,14 @@ void LyXText::changeCase(BufferView * bview, LyXText::TextCase action)
        LyXCursor to;
 
        if (selection.set()) {
-               from = selection.cursor;
-               to = cursor;
+               from = selection.start;
+               to = selection.end;
        } else {
                getWord(from, to, PARTIAL_WORD);
-               setCursor(bview, to.par(), to.pos()+1);
+               setCursor(bview, to.par(), to.pos() + 1);
        }
 
-       setUndo(bview->buffer(), Undo::FINISH,
-               from.par()->previous(), to.par()->next()); 
-
-#if 1
-       changeRegionCase(bview, to, from, action);
-#else
-       while(from != to) {
-               unsigned char c = from.par()->getChar(from.pos());
-               if (!IsInsetChar(c) && !IsHfillChar(c)) {
-                       switch (action) {
-                       case text_lowercase:
-                               c = tolower(c);
-                               break;
-                       case text_capitalization:
-                               c = toupper(c);
-                               action = text_lowercase;
-                               break;
-                       case text_uppercase:
-                               c = toupper(c);
-                               break;
-                       }
-               }
-               from.par()->setChar(from.pos(), c);
-               checkParagraph(bview, from.par(), from.pos());
-               from.pos(from.pos() + 1);
-               if (from.pos() >= from.par()->size()) {
-                       from.par(from.par()->next());
-                       from.pos(0);
-               }
-       }
-       if (to.row() != from.row()) {
-               refresh_y = from.y() - from.row()->baseline();
-               refresh_row = from.row();
-               status = LyXText::NEED_MORE_REFRESH;
-       }
-#endif
+       changeRegionCase(bview, from, to, action);
 }
 
 
@@ -2447,13 +2412,16 @@ void LyXText::changeRegionCase(BufferView * bview,
                               LyXCursor const & to,
                               LyXText::TextCase action)
 {
+       lyx::Assert(from <= to);
+       
        setUndo(bview->buffer(), Undo::FINISH,
                from.par()->previous(), to.par()->next());
 
-       LyXCursor tmp(from);
-       
-       while(tmp != to) {
-               unsigned char c = tmp.par()->getChar(tmp.pos());
+       Paragraph::size_type pos = from.pos();
+       Paragraph * par = from.par();
+
+       while (par && (pos != to.pos() || par != to.par())) {
+               unsigned char c = par->getChar(pos);
                if (!IsInsetChar(c) && !IsHfillChar(c)) {
                        switch (action) {
                        case text_lowercase:
@@ -2468,17 +2436,18 @@ void LyXText::changeRegionCase(BufferView * bview,
                                break;
                        }
                }
-               tmp.par()->setChar(tmp.pos(), c);
-               checkParagraph(bview, tmp.par(), tmp.pos());
-               tmp.pos(tmp.pos() + 1);
-               if (tmp.pos() >= tmp.par()->size()) {
-                       tmp.par(tmp.par()->next());
-                       tmp.pos(0);
+               par->setChar(pos, c);
+               checkParagraph(bview, par, pos);
+
+               ++pos;
+               if (pos == par->size()) {
+                       par = par->next();
+                       pos = 0;
                }
        }
-       if (to.row() != tmp.row()) {
-               refresh_y = tmp.y() - tmp.row()->baseline();
-               refresh_row = tmp.row();
+       if (to.row() != from.row()) {
+               refresh_y = from.y() - from.row()->baseline();
+               refresh_row = from.row();
                status = LyXText::NEED_MORE_REFRESH;
        }
 }
@@ -2680,7 +2649,7 @@ void LyXText::backspace(BufferView * bview)
                
                // some insets are undeletable here
                if (cursor.par()->getChar(cursor.pos()) == Paragraph::META_INSET) {
-                       if (!cursor.par()->getInset(cursor.pos())->Deletable())
+                       if (!cursor.par()->getInset(cursor.pos())->deletable())
                                return; 
                        // force complete redo when erasing display insets
                        // this is a cruel method but safe..... Matthias