mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-29 21:05:12 +00:00
make macrfos readable again
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15479 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0aaa8c5bcc
commit
dc94575f2b
@ -90,7 +90,7 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
|
||||
: QApplication(argc, argv), Application(argc, argv)
|
||||
{
|
||||
#ifdef Q_WS_X11
|
||||
// doubleClickInterval() is 400 ms on X11 witch is just too long.
|
||||
// doubleClickInterval() is 400 ms on X11 which is just too long.
|
||||
// On Windows and Mac OS X, the operating system's value is used.
|
||||
// On Microsoft Windows, calling this function sets the double
|
||||
// click interval for all applications. So we don't!
|
||||
|
@ -39,12 +39,12 @@
|
||||
#include "QCommandBuffer.h"
|
||||
#include "qt_helpers.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QCloseEvent>
|
||||
#include <QPixmap>
|
||||
#include <QStatusBar>
|
||||
#include <QToolBar>
|
||||
#include <QCloseEvent>
|
||||
#include <QAction>
|
||||
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
@ -93,13 +93,15 @@ GuiView::~GuiView()
|
||||
void GuiView::init()
|
||||
{
|
||||
menubar_.reset(new QLMenubar(this, menubackend));
|
||||
QObject::connect(menuBar(), SIGNAL(triggered(QAction *)), this, SLOT(updateMenu(QAction *)));
|
||||
QObject::connect(menuBar(), SIGNAL(triggered(QAction *)),
|
||||
this, SLOT(updateMenu(QAction *)));
|
||||
|
||||
getToolbars().init();
|
||||
|
||||
statusBar()->setSizeGripEnabled(false);
|
||||
|
||||
QObject::connect(&statusbar_timer_, SIGNAL(timeout()), this, SLOT(update_view_state_qt()));
|
||||
QObject::connect(&statusbar_timer_, SIGNAL(timeout()),
|
||||
this, SLOT(update_view_state_qt()));
|
||||
|
||||
// make sure the buttons are disabled if needed
|
||||
updateToolbars();
|
||||
|
@ -17,21 +17,20 @@
|
||||
#include "QCommandBuffer.h"
|
||||
#include "QCommandEdit.h"
|
||||
#include "qt_helpers.h"
|
||||
//Added by qt3to4:
|
||||
#include <QVBoxLayout>
|
||||
#include <QMouseEvent>
|
||||
#include <QPixmap>
|
||||
#include <QHBoxLayout>
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include "controllers/ControlCommandBuffer.h"
|
||||
|
||||
#include "support/filetools.h"
|
||||
|
||||
#include <QListWidget>
|
||||
#include <QHBoxLayout>
|
||||
#include <QKeyEvent>
|
||||
#include <QLayout>
|
||||
#include <QToolTip>
|
||||
#include <QListWidget>
|
||||
#include <QMouseEvent>
|
||||
#include <QPixmap>
|
||||
#include <QPushButton>
|
||||
#include <QToolTip>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
using lyx::support::libFileSearch;
|
||||
|
||||
@ -53,9 +52,9 @@ public:
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
}
|
||||
protected:
|
||||
void mouseReleaseEvent(QMouseEvent * e) {
|
||||
if (e->x() < 0 || e->y() < 0
|
||||
|| e->x() > width() || e->y() > height()) {
|
||||
void mouseReleaseEvent(QMouseEvent * ev) {
|
||||
if (ev->x() < 0 || ev->y() < 0
|
||||
|| ev->x() > width() || ev->y() > height()) {
|
||||
hide();
|
||||
} else {
|
||||
// emit signal
|
||||
@ -63,19 +62,20 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
void keyPressEvent(QKeyEvent * e) {
|
||||
if (e->key() == Qt::Key_Escape) {
|
||||
void keyPressEvent(QKeyEvent * ev) {
|
||||
if (ev->key() == Qt::Key_Escape) {
|
||||
hide();
|
||||
return;
|
||||
}
|
||||
QListWidget::keyPressEvent(e);
|
||||
QListWidget::keyPressEvent(ev);
|
||||
}
|
||||
};
|
||||
|
||||
} // end of anon
|
||||
|
||||
|
||||
QCommandBuffer::QCommandBuffer(GuiView * view, ControlCommandBuffer & control, QWidget * parent)
|
||||
QCommandBuffer::QCommandBuffer(GuiView * view, ControlCommandBuffer & control,
|
||||
QWidget * parent)
|
||||
: QWidget(parent), view_(view), controller_(control)
|
||||
{
|
||||
QPixmap qpup(toqstr(libFileSearch("images", "up", "xpm")));
|
||||
@ -104,7 +104,9 @@ QCommandBuffer::QCommandBuffer(GuiView * view, ControlCommandBuffer & control, Q
|
||||
layout->addWidget(up, 0);
|
||||
layout->addWidget(down, 0);
|
||||
layout->addWidget(edit_, 10);
|
||||
layout->setMargin(0);
|
||||
top->addLayout(layout);
|
||||
top->setMargin(0);
|
||||
}
|
||||
|
||||
|
||||
@ -118,7 +120,7 @@ void QCommandBuffer::focus_command()
|
||||
void QCommandBuffer::cancel()
|
||||
{
|
||||
view_->centralWidget()->setFocus();
|
||||
edit_->setText("");
|
||||
edit_->setText(QString());
|
||||
}
|
||||
|
||||
|
||||
@ -126,7 +128,7 @@ void QCommandBuffer::dispatch()
|
||||
{
|
||||
controller_.dispatch(fromqstr(edit_->text()));
|
||||
view_->centralWidget()->setFocus();
|
||||
edit_->setText("");
|
||||
edit_->setText(QString());
|
||||
edit_->clearFocus();
|
||||
}
|
||||
|
||||
@ -156,17 +158,13 @@ void QCommandBuffer::complete()
|
||||
// than the number of actual items...
|
||||
vector<string>::const_iterator cit = comp.begin();
|
||||
vector<string>::const_iterator end = comp.end();
|
||||
for (; cit != end; ++cit) {
|
||||
for (; cit != end; ++cit)
|
||||
list->addItem(toqstr(*cit));
|
||||
}
|
||||
|
||||
// width() is not big enough by a few pixels. Qt Sucks.
|
||||
// list->setMinimumWidth(list->sizeHint().width() + 10);
|
||||
|
||||
list->resize(list->sizeHint());
|
||||
QPoint pos(edit_->mapToGlobal(QPoint(0, 0)));
|
||||
QPoint const pos = edit_->mapToGlobal(QPoint(0, 0));
|
||||
|
||||
int y = std::max(0, pos.y() - list->height());
|
||||
int const y = std::max(0, pos.y() - list->height());
|
||||
|
||||
list->move(pos.x(), y);
|
||||
|
||||
@ -189,8 +187,8 @@ void QCommandBuffer::complete_selected(QListWidgetItem * item)
|
||||
|
||||
void QCommandBuffer::up()
|
||||
{
|
||||
string const input(fromqstr(edit_->text()));
|
||||
string const h(controller_.historyUp());
|
||||
string const input = fromqstr(edit_->text());
|
||||
string const h = controller_.historyUp();
|
||||
|
||||
if (h.empty()) {
|
||||
// show_info_suffix(qt_("[Beginning of history]"), input);
|
||||
@ -202,8 +200,8 @@ void QCommandBuffer::up()
|
||||
|
||||
void QCommandBuffer::down()
|
||||
{
|
||||
string const input(fromqstr(edit_->text()));
|
||||
string const h(controller_.historyDown());
|
||||
string const input = fromqstr(edit_->text());
|
||||
string const h = controller_.historyDown();
|
||||
|
||||
if (h.empty()) {
|
||||
// show_info_suffix(qt_("[End of history]"), input);
|
||||
|
@ -26,7 +26,8 @@ class ControlCommandBuffer;
|
||||
class QCommandBuffer : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QCommandBuffer(GuiView * view, ControlCommandBuffer & control, QWidget * parent=NULL);
|
||||
QCommandBuffer(GuiView * view, ControlCommandBuffer & control,
|
||||
QWidget * parent=NULL);
|
||||
|
||||
/// focus the edit widget
|
||||
void focus_command();
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "QCommandEdit.h"
|
||||
//Added by qt3to4:
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QEvent>
|
||||
|
||||
|
@ -26,19 +26,17 @@ public:
|
||||
Q_SIGNALS:
|
||||
/// cancel
|
||||
void escapePressed();
|
||||
|
||||
/// up history
|
||||
void upPressed();
|
||||
|
||||
/// down history
|
||||
void downPressed();
|
||||
|
||||
/// complete
|
||||
void tabPressed();
|
||||
|
||||
protected:
|
||||
///
|
||||
virtual bool event(QEvent * e);
|
||||
|
||||
///
|
||||
virtual void keyPressEvent(QKeyEvent * e);
|
||||
};
|
||||
|
||||
|
@ -333,9 +333,10 @@ int LyX::priv_exec(int & argc, char * argv[])
|
||||
// Start the real execution loop.
|
||||
|
||||
// FIXME
|
||||
/* Create a CoreApplication class that will provide the main event loop and
|
||||
* the socket callback registering. With Qt4, only QtCore library would be needed.
|
||||
* When this done, a server_mode could be created and the following two
|
||||
/* Create a CoreApplication class that will provide the main event loop
|
||||
* and the socket callback registering. With Qt4, only QtCore
|
||||
* library would be needed.
|
||||
* When this is done, a server_mode could be created and the following two
|
||||
* line would be moved out from here.
|
||||
*/
|
||||
pimpl_->lyx_server_.reset(new LyXServer(&pimpl_->lyxfunc_, lyxrc.lyxpipes));
|
||||
|
@ -102,8 +102,7 @@ void MacroTable::insert(docstring const & name, MacroData const & data)
|
||||
void MacroTable::insert(docstring const & def)
|
||||
{
|
||||
//lyxerr << "MacroTable::insert, def: " << to_utf8(def) << endl;
|
||||
std::istringstream is(to_utf8(def));
|
||||
MathMacroTemplate mac(is);
|
||||
MathMacroTemplate mac(def);
|
||||
insert(mac.name(), mac.asMacroData());
|
||||
}
|
||||
|
||||
|
@ -57,15 +57,15 @@ MathMacroTemplate::MathMacroTemplate(docstring const & name, int numargs,
|
||||
}
|
||||
|
||||
|
||||
MathMacroTemplate::MathMacroTemplate(std::istream & is)
|
||||
MathMacroTemplate::MathMacroTemplate(docstring const & str)
|
||||
: InsetMathNest(2), numargs_(0), name_()
|
||||
{
|
||||
initMath();
|
||||
|
||||
MathArray ar;
|
||||
mathed_parse_cell(ar, is);
|
||||
mathed_parse_cell(ar, str);
|
||||
if (ar.size() != 1 || !ar[0]->asMacroTemplate()) {
|
||||
lyxerr << "cannot read macro from '" << ar << "'" << endl;
|
||||
lyxerr << "Cannot read macro from '" << ar << "'" << endl;
|
||||
return;
|
||||
}
|
||||
operator=( *(ar[0]->asMacroTemplate()) );
|
||||
@ -173,9 +173,15 @@ void MathMacroTemplate::draw(PainterInfo & p, int x, int y) const
|
||||
void MathMacroTemplate::read(Buffer const &, LyXLex & lex)
|
||||
{
|
||||
MathArray ar;
|
||||
mathed_parse_cell(ar, lex.getDocString());
|
||||
lex.next(); // eat \begin_inset FormulaMacro line
|
||||
docstring const str = lex.getDocString();
|
||||
lex.next(); // eat that macro definition
|
||||
lex.next(); // eat the \\end_insrt line
|
||||
lyxerr << "Got to read from: " << to_utf8(str) << endl;
|
||||
mathed_parse_cell(ar, str);
|
||||
if (ar.size() != 1 || !ar[0]->asMacroTemplate()) {
|
||||
lyxerr << "cannot read macro from '" << ar << "'" << endl;
|
||||
lyxerr << "Cannot read macro from '" << ar << "'" << endl;
|
||||
lyxerr << "Read: " << to_utf8(asString(ar)) << endl;
|
||||
return;
|
||||
}
|
||||
operator=( *(ar[0]->asMacroTemplate()) );
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
MathArray const & = MathArray(),
|
||||
MathArray const & = MathArray());
|
||||
///
|
||||
explicit MathMacroTemplate(std::istream & is);
|
||||
explicit MathMacroTemplate(const docstring & str);
|
||||
///
|
||||
void edit(LCursor & cur, bool left);
|
||||
///
|
||||
|
13
src/text3.C
13
src/text3.C
@ -136,7 +136,7 @@ namespace {
|
||||
void mathDispatch(LCursor & cur, FuncRequest const & cmd, bool display)
|
||||
{
|
||||
recordUndo(cur);
|
||||
string sel = to_utf8(cur.selectionAsString(false));
|
||||
docstring sel = cur.selectionAsString(false);
|
||||
//lyxerr << "selection is: '" << sel << "'" << endl;
|
||||
|
||||
// It may happen that sel is empty but there is a selection
|
||||
@ -162,11 +162,11 @@ namespace {
|
||||
// create a macro if we see "\\newcommand"
|
||||
// somewhere, and an ordinary formula
|
||||
// otherwise
|
||||
istringstream is(sel);
|
||||
if (sel.find("\\newcommand") == string::npos
|
||||
&& sel.find("\\def") == string::npos)
|
||||
if (sel.find(from_ascii("\\newcommand")) == string::npos
|
||||
&& sel.find(from_ascii("\\def")) == string::npos)
|
||||
{
|
||||
InsetMathHull * formula = new InsetMathHull;
|
||||
istringstream is(to_utf8(sel));
|
||||
LyXLex lex(0, 0);
|
||||
lex.setStream(is);
|
||||
formula->read(cur.buffer(), lex);
|
||||
@ -175,8 +175,9 @@ namespace {
|
||||
// delimiters are left out
|
||||
formula->mutate(hullSimple);
|
||||
cur.insert(formula);
|
||||
} else
|
||||
cur.insert(new MathMacroTemplate(is));
|
||||
} else {
|
||||
cur.insert(new MathMacroTemplate(sel));
|
||||
}
|
||||
}
|
||||
cur.message(from_utf8(N_("Math editor mode")));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user