Ejemplo n.º 1
0
// Read the command set from settings.
bool QsciCommandSet::readSettings(QSettings &qs, const char *prefix)
{
    bool rc = true;
    QString skey;

    for (int i = 0; i < cmds.count(); ++i)
    {
        QsciCommand *cmd = cmds.at(i);

        skey.sprintf("%s/keymap/c%d/", prefix,
                static_cast<int>(cmd->command()));

        int key;
        bool ok;

        // Read the key.
        key = qs.readNumEntry(skey + "key", 0, &ok);

        if (ok)
            cmd->setKey(key);
        else
            rc = false;

        // Read the alternate key.
        key = qs.readNumEntry(skey + "alt", 0, &ok);

        if (ok)
            cmd->setAlternateKey(key);
        else
            rc = false;
    }

    return rc;
}
Ejemplo n.º 2
0
// Find the command bound to a key.
QsciCommand *QsciCommandSet::boundTo(int key) const
{
    for (int i = 0; i < cmds.count(); ++i)
    {
        QsciCommand *cmd = cmds.at(i);

        if (cmd->key() == key || cmd->alternateKey() == key)
            return cmd;
    }

    return 0;
}
Ejemplo n.º 3
0
// Find a command.
QsciCommand *QsciCommandSet::find(QsciCommand::Command command) const
{
    for (int i = 0; i < cmds.count(); ++i)
    {
        QsciCommand *cmd = cmds.at(i);

        if (cmd->command() == command)
            return cmd;
    }

    // This should never happen.
    return 0;
}
Ejemplo n.º 4
0
ScintillaEditor::ScintillaEditor(QWidget *parent) : EditorInterface(parent)
{
  scintillaLayout = new QVBoxLayout(this);
  qsci = new QsciScintilla(this);


  //
  // Remapping some scintilla key binding which conflict with OpenSCAD global
  // key bindings, as well as some minor scintilla bugs
  //
  QsciCommand *c;
#ifdef Q_OS_MAC
  // Alt-Backspace should delete left word (Alt-Delete already deletes right word)
  c= qsci->standardCommands()->find(QsciCommand::DeleteWordLeft);
  c->setKey(Qt::Key_Backspace | Qt::ALT);
#endif
  // Cmd/Ctrl-T is handled by the menu
  c = qsci->standardCommands()->boundTo(Qt::Key_T | Qt::CTRL);
  c->setKey(0);
  // Cmd/Ctrl-D is handled by the menu
  c = qsci->standardCommands()->boundTo(Qt::Key_D | Qt::CTRL);
  c->setKey(0);
  // Ctrl-Shift-Z should redo on all platforms
  c= qsci->standardCommands()->find(QsciCommand::Redo);
  c->setKey(Qt::Key_Z | Qt::CTRL | Qt::SHIFT);

  scintillaLayout->setContentsMargins(0, 0, 0, 0);
  scintillaLayout->addWidget(qsci);

  qsci->setBraceMatching (QsciScintilla::SloppyBraceMatch);
  qsci->setWrapMode(QsciScintilla::WrapCharacter);
  qsci->setWrapVisualFlags(QsciScintilla::WrapFlagByBorder, QsciScintilla::WrapFlagNone, 0);
  qsci->setAutoIndent(true);
  qsci->indicatorDefine(QsciScintilla::RoundBoxIndicator, indicatorNumber);
  qsci->markerDefine(QsciScintilla::Circle, markerNumber);
  qsci->setUtf8(true);
  qsci->setTabIndents(true);
  qsci->setTabWidth(8);
  qsci->setIndentationWidth(4);
  qsci->setIndentationsUseTabs(false);  
  
  lexer = new ScadLexer(this);
  initLexer();
  initMargin();
  qsci->setFolding(QsciScintilla::BoxedTreeFoldStyle, 4);
  qsci->setCaretLineVisible(true);
  this->setHighlightScheme(Preferences::inst()->getValue("editor/syntaxhighlight").toString());

  connect(qsci, SIGNAL(textChanged()), this, SIGNAL(contentsChanged()));
  connect(qsci, SIGNAL(modificationChanged(bool)), this, SIGNAL(modificationChanged(bool)));
}
Ejemplo n.º 5
0
// Write the command set to settings.
bool QsciCommandSet::writeSettings(QSettings &qs, const char *prefix)
{
    bool rc = true;
    QString skey;

    for (int i = 0; i < cmds.count(); ++i)
    {
        QsciCommand *cmd = cmds.at(i);

        skey.sprintf("%s/keymap/c%d/", prefix,
                static_cast<int>(cmd->command()));

        // Write the key.
        qs.setValue(skey + "key", cmd->key());

        // Write the alternate key.
        qs.setValue(skey + "alt", cmd->key());
    }

    return rc;
}
Ejemplo n.º 6
0
// Write the command set to settings.
bool QsciCommandSet::writeSettings(QSettings &qs, const char *prefix)
{
    bool rc = true;
    QString skey;

    for (int i = 0; i < cmds.count(); ++i)
    {
        QsciCommand *cmd = cmds.at(i);

        skey.sprintf("%s/keymap/c%d/", prefix, cmd->msgId());

        // Write the key.
        if (!qs.writeEntry(skey + "key", cmd->key()))
            rc = false;

        // Write the alternate key.
        if (!qs.writeEntry(skey + "alt", cmd->alternateKey()))
            rc = false;
    }

    return rc;
}
Ejemplo n.º 7
0
ScintillaEditor::ScintillaEditor(QWidget *parent) : EditorInterface(parent)
{
	scintillaLayout = new QVBoxLayout(this);
	qsci = new QsciScintilla(this);

	// Force EOL mode to Unix, since QTextStream will manage local EOL modes.
	qsci->setEolMode(QsciScintilla::EolUnix);

	//
	// Remapping some scintilla key binding which conflict with OpenSCAD global
	// key bindings, as well as some minor scintilla bugs
	//
	QsciCommand *c;
#ifdef Q_OS_MAC
	// Alt-Backspace should delete left word (Alt-Delete already deletes right word)
	c = qsci->standardCommands()->find(QsciCommand::DeleteWordLeft);
	c->setKey(Qt::Key_Backspace | Qt::ALT);
#endif
	// Cmd/Ctrl-T is handled by the menu
	c = qsci->standardCommands()->boundTo(Qt::Key_T | Qt::CTRL);
	c->setKey(0);
	// Cmd/Ctrl-D is handled by the menu
	c = qsci->standardCommands()->boundTo(Qt::Key_D | Qt::CTRL);
	c->setKey(0);
	// Ctrl-Shift-Z should redo on all platforms
	c = qsci->standardCommands()->find(QsciCommand::Redo);
	c->setKey(Qt::Key_Z | Qt::CTRL | Qt::SHIFT);
	c->setAlternateKey(Qt::Key_Y | Qt::CTRL);

	scintillaLayout->setContentsMargins(0, 0, 0, 0);
	scintillaLayout->addWidget(qsci);

	qsci->indicatorDefine(QsciScintilla::RoundBoxIndicator, errorIndicatorNumber);
	qsci->indicatorDefine(QsciScintilla::RoundBoxIndicator , findIndicatorNumber); 
	qsci->markerDefine(QsciScintilla::Circle, markerNumber);
	qsci->setUtf8(true);
	qsci->setFolding(QsciScintilla::BoxedTreeFoldStyle, 4);

	this->lexer = new ScadLexer(this);
	qsci->setLexer(this->lexer);
	initMargin();

	connect(qsci, SIGNAL(textChanged()), this, SIGNAL(contentsChanged()));
	connect(qsci, SIGNAL(modificationChanged(bool)), this, SIGNAL(modificationChanged(bool)));
	qsci->installEventFilter(this);
}