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;
+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
{ 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 }
};
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 */
};
};
/// 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.
+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<<):
#include <config.h>
+#include <iostream>
+
#ifdef __GNUG__
#pragma implementation
#endif
#include <config.h>
+#include <iostream>
+
#ifdef __GNUG__
#pragma implementation
#endif
+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.
using std::count;
using std::transform;
+
#ifndef CXX_GLOBAL_CSTD
using std::tolower;
using std::toupper;
}
+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;
}
string const subst(string const & a,
- char const * oldstr, string const & newstr)
+ char const * oldstr, string const & newstr)
{
lyx::Assert(oldstr);
}
+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