Lars Gullik Bjønnes wrote:
Abdelrazak Younes <[EMAIL PROTECTED]> writes:
| This back and forth conversion to utf8 is obviously extraneous and
| should be deleted. We have two solutions:
|
| 1) use something else that FuncRequest::argument to store the
| characters to be inserted. I am thinking of a new member data_
| accessible through data(). Question is docstring or vector<char_type>?
| (As a side note, I really don't understand why we still have to make
| this choice up until now.)
I'd rather change the FuncRequest::argument type to docstring.
Me too but it's a _huge_ task. So I'd rather migrate the code
progressively to use "data()" instead of "argument". If you don't like
the name, I could use "argument()" instead.
Attached the preliminary patch.
Abdel.
Index: funcrequest.C
===================================================================
--- funcrequest.C (revision 14854)
+++ funcrequest.C (working copy)
@@ -40,6 +40,14 @@
{}
+FuncRequest::FuncRequest(kb_action act,
+ std::vector<lyx::char_type>
const & data,
+ Origin o)
+ : action(act), data_(data), origin(o), x(0), y(0),
+ button_(mouse_button::none)
+{}
+
+
FuncRequest::FuncRequest(kb_action act, int ax, int ay,
mouse_button::state but, Origin o)
: action(act), origin(o), x(ax), y(ay), button_(but)
Index: funcrequest.h
===================================================================
--- funcrequest.h (revision 14854)
+++ funcrequest.h (working copy)
@@ -15,8 +15,11 @@
#include "lfuns.h"
#include "frontends/mouse_state.h"
+#include "support/types.h"
+
#include <string>
#include <iosfwd>
+#include <vector>
/**
@@ -43,6 +46,9 @@
/// actions with extra argument
FuncRequest(kb_action act, std::string const & arg,
Origin o = INTERNAL);
+ /// actions with extra unicode data
+ FuncRequest(kb_action act, std::vector<lyx::char_type> const & data,
+ Origin o = INTERNAL);
/// for changing requests a bit
FuncRequest(FuncRequest const & cmd, std::string const & arg,
Origin o = INTERNAL);
@@ -53,6 +59,11 @@
/// argument parsing, extract argument i as std::string
std::string getArg(unsigned int i) const;
+ /// data_ accessors
+ std::vector<lyx::char_type> const & data() const { return data_; }
+ void setData(std::vector<lyx::char_type> const & data)
+ { data_ = data; }
+
public: // should be private
/// the action
kb_action action;
@@ -66,6 +77,10 @@
int y;
/// some extra information (like button number)
mouse_button::state button_;
+
+private:
+ /// the action's data
+ std::vector<lyx::char_type> data_;
};
Index: lyxfunc.C
===================================================================
--- lyxfunc.C (revision 14854)
+++ lyxfunc.C (working copy)
@@ -323,12 +323,12 @@
if (func.action == LFUN_SELF_INSERT) {
if (encoded_last_key != 0) {
- std::vector<char> tmp = ucs4_to_utf8(encoded_last_key);
- string const arg(tmp.begin(), tmp.end());
- dispatch(FuncRequest(LFUN_SELF_INSERT, arg,
+ std::vector<lyx::char_type> keys;
+ keys.push_back(encoded_last_key);
+ dispatch(FuncRequest(LFUN_SELF_INSERT, keys,
FuncRequest::KEYBOARD));
lyxerr[Debug::KEY]
- << "SelfInsert arg[`" << arg << "']" << endl;
+ << "SelfInsert arg[`" << (char)
encoded_last_key << "']" << endl;
}
} else {
dispatch(func);
Index: text3.C
===================================================================
--- text3.C (revision 14854)
+++ text3.C (working copy)
@@ -1101,10 +1101,9 @@
bv->owner()->getIntl().getTransManager().
translateAndInsert(*cit, this);
#else
- std::vector<char> in(cmd.argument.begin(), cmd.argument.end());
- std::vector<boost::uint32_t> const res = utf8_to_ucs4(in);
- std::vector<boost::uint32_t>::const_iterator cit = res.begin();
- std::vector<boost::uint32_t>::const_iterator end = res.end();
+ std::vector<lyx::char_type> const & keys = cmd.data();
+ std::vector<boost::uint32_t>::const_iterator cit = keys.begin();
+ std::vector<boost::uint32_t>::const_iterator end = keys.end();
for (; cit != end; ++cit)
insertChar(bv->cursor(), *cit);
#endif