]> git.lyx.org Git - features.git/commitdiff
small fix for gcc 3.0, use std::transform in lstrings, implement chars-transpose
authorLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 25 Apr 2001 19:33:52 +0000 (19:33 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 25 Apr 2001 19:33:52 +0000 (19:33 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1955 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView_pimpl.C
src/ChangeLog
src/LyXAction.C
src/commandtags.h
src/lyxtext.h
src/mathed/ChangeLog
src/mathed/math_macrotable.C
src/minibuffer.C
src/support/ChangeLog
src/support/lstrings.C
src/text.C

index 37c1640ee3d14f8bf91f61434803a5ca77684d59..a6f510b7e2279b96d1d0ae1e54a8c6ce4235153b 100644 (file)
@@ -1769,7 +1769,16 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                        bv_->updateInset(TEXT(bv_)->inset_owner, true);
                update(TEXT(bv_), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
                break;
+
+       case LFUN_TRANSPOSE_CHARS:
+               update(TEXT(bv_), BufferView::SELECT|BufferView::FITCUR);
+               TEXT(bv_)->TransposeChars(*bv_);
+               if (TEXT(bv_)->inset_owner)
+                       bv_->updateInset(TEXT(bv_)->inset_owner, true);
+               update(TEXT(bv_), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+               break;
                
+                                         
        case LFUN_INSERT_LABEL:
                MenuInsertLabel(bv_, argument);
                break;
index 206c8b995ef41703c14e3e3af420158344f04f6d..6ef14d75e76a7f76bec861bd137ce887034453bf 100644 (file)
@@ -1,3 +1,15 @@
+2001-04-25  Lars Gullik Bjønnes  <larsbj@birdstep.com>
+
+       * minibuffer.C: include <iostream>
+
+       * BufferView_pimpl.C: implement LFUN_TRANSPOSE_CHARS
+
+       * LyXAction.C (init): add LFUN_TRANSPOSE_CHARS
+
+       * commandtags.h: add LFUN_TRANSPOSE_CHARS
+
+       * text.[Ch] (TransposeChars): new method
+
 2001-04-24  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * call message directly through LyXView instead of through LyXFunc
index 4a4c09a3befff1f4d68fe669d178b595903f8267..d9f6b8c3c7eb960f1bcaaa48f5c7cf29f4857a1e 100644 (file)
@@ -439,6 +439,7 @@ void LyXAction::init()
                { LFUN_MESSAGE_POP, "message-pop",
                  N_("Pop old message and show it in the minibuffer"),
                  NoBuffer },
+               { LFUN_TRANSPOSE_CHARS, "chars-transpose", "", Noop },
                { LFUN_NOACTION, "", "", Noop }
        };
 
index 3d687b18e40d38d62067e633677f7dfee9cfdf9f..b40b042f55998aac9bb587f522a7b81a1bd01ce5 100644 (file)
@@ -283,6 +283,7 @@ enum kb_action {
        LFUN_MESSAGE,                   // Lgb 20010408
        LFUN_MESSAGE_PUSH,              // Lgb 20010410
        LFUN_MESSAGE_POP,               // Lgb 20010410
+       LFUN_TRANSPOSE_CHARS,           // Lgb 20010425
        LFUN_LASTACTION  /* this marks the end of the table */
 };
 
index 8b2443e6821e2220cfcf6f0b712c8d099be49a4b..1c3ec4d6fc8483bb2701b7e912cf0dac2d63602a 100644 (file)
@@ -329,7 +329,8 @@ public:
        };
        /// Change the case of the word at cursor position.
        void ChangeWordCase(BufferView *, TextCase action);
-
+       void TransposeChars(BufferView const &);
+       
        /** returns a printed row in a pixmap. The y value is needed to
          decide, wether it is selected text or not. This is a strange
          solution but faster.
index bcfc2a10a243e6173bb87a5c90cdef78a9d589c0..74906a1cd414952b71da356b22cb93365a03dc43 100644 (file)
@@ -1,3 +1,7 @@
+2001-04-25  Lars Gullik Bjønnes  <larsbj@birdstep.com>
+
+       * math_macrotable.C: include <iostream>
+
 2001-04-25  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * array.h (operator<<):
index 7173b236f4d780dffe69408076520b0a8156fe72..8eeb66fe0e2785e7dec807c639fc8ce985827408 100644 (file)
@@ -1,5 +1,7 @@
 #include <config.h>
 
+#include <iostream>
+
 #ifdef __GNUG__
 #pragma implementation
 #endif
index 5e1f324423498ae8cfe5147d3245c247aee8bae3..659b12a5d06d1d7004c2db742a2f8266991b6657 100644 (file)
@@ -12,6 +12,8 @@
 
 #include <config.h>
 
+#include <iostream>
+
 #ifdef __GNUG__
 #pragma implementation
 #endif
index a211a329f0bd203769935f94d723722571b6e620..e84f04f1514e90060ea66592d41abf5725a9f725 100644 (file)
@@ -1,3 +1,10 @@
+2001-04-25  Lars Gullik Bjønnes  <larsbj@birdstep.com>
+
+       * lstrings.C : add two helper structs, local_lowercase and
+       local_uppercase. 
+       (lowercase): change to use std::transform
+       (uppercase): change to use std::transform
+
 2001-04-25  Allan Rae  <rae@lyx.org>
 
        * lyxstring.C : Assert got moved and Lars missed a few.
index 20c92ff16e35b29c285dd7df03ea918b05128df1..03296f824edfd86e626f386112f75fb8f07d3708 100644 (file)
@@ -26,6 +26,7 @@
 
 using std::count;
 using std::transform;
+
 #ifndef CXX_GLOBAL_CSTD
 using std::tolower;
 using std::toupper;
@@ -193,38 +194,36 @@ char uppercase(char c)
 }
 
 
+namespace {
+
+// since we cannot use std::tolower and std::toupper directly in the
+// calls to std::transform yet, we use these helper clases. (Lgb)
+
+struct local_lowercase {
+       char operator()(char c) const {
+               return tolower(c);
+       }
+};
+       
+struct local_uppercase {
+       char operator()(char c) const {
+               return toupper(c);
+       }
+};
+
+} // end of anon namespace
+
 string const lowercase(string const & a)
 {
        string tmp(a);
-#if 1
-       string::iterator result = tmp.begin();
-       string::iterator end = tmp.end();
-       for (string::iterator first = tmp.begin();
-            first != end; ++first, ++result) {
-               *result = lowercase(*first);
-       }
-#else
-       // We want to use this one. (Lgb)
-       transform(tmp.begin(), tmp.end(), tmp.begin(), lowercase);
-#endif
+       transform(tmp.begin(), tmp.end(), tmp.begin(), local_lowercase());
        return tmp;
 }
 
-
 string const uppercase(string const & a)
 {
        string tmp(a);
-#if 1
-       string::iterator result = tmp.begin();
-       string::iterator end = tmp.end();
-       for (string::iterator first = tmp.begin();
-            first != end; ++first, ++result) {
-               *result = uppercase(*first);
-       }
-#else
-       // We want to use this one. (Lgb)
-       transform(tmp.begin(), tmp.end(), tmp.begin(), uppercase);
-#endif
+       transform(tmp.begin(), tmp.end(), tmp.begin(), local_uppercase());
        return tmp;
 }
 
@@ -473,7 +472,7 @@ string const subst(string const & a, char oldchar, char newchar)
 
 
 string const subst(string const & a,
-            char const * oldstr, string const & newstr)
+                  char const * oldstr, string const & newstr)
 {
        lyx::Assert(oldstr);
        
index 1dca2666d945ce6a070b42b431ae6b4af7b79222..9dea165c555e8fbeabbaa3dacb30a4cf5c246369 100644 (file)
@@ -2842,6 +2842,37 @@ void LyXText::ChangeWordCase(BufferView * bview, LyXText::TextCase action)
 }
 
 
+void LyXText::TransposeChars(BufferView const & bview)
+{
+       LyXParagraph * tmppar = cursor.par();
+
+       SetUndo(bview.buffer(), Undo::FINISH,
+               tmppar->previous(), tmppar->next()); 
+
+       LyXParagraph::size_type tmppos = cursor.pos();
+
+       // First decide if it is possible to transpose at all
+
+       // We are at the beginning of a paragraph.
+       if (tmppos == 0) return;
+
+       // We are at the end of a paragraph.
+       if (tmppos == tmppar->size() - 1) return;
+
+       unsigned char c1 = tmppar->GetChar(tmppos);
+       unsigned char c2 = tmppar->GetChar(tmppos - 1);
+
+       if (c1 != LyXParagraph::META_INSET
+           && c2 != LyXParagraph::META_INSET) {
+               tmppar->SetChar(tmppos, c2);
+               tmppar->SetChar(tmppos - 1, c1);
+       }
+       // We should have an implementation that handles insets
+       // as well, but that will have to come later. (Lgb)
+       CheckParagraph(const_cast<BufferView*>(&bview), tmppar, tmppos);
+}
+
+
 void LyXText::Delete(BufferView * bview)
 {
        // this is a very easy implementation