d_ptr->highlighter->mark(str, sens);
}
+void GLSLEdit::indent()
+{
+ QTemporaryFile file(QLatin1String("shader.glsl"));
+ if (!file.open()) {
+ qDebug()<<"Couldn't create temporary file "<<file.fileName();
+ return;
+ }
+ file.write(toPlainText().toUtf8());
+ file.flush();
+
+ QString tempFileName =
+ QDir::toNativeSeparators(QFileInfo(file).canonicalFilePath());
+
+ QProcess astyle;
+ astyle.setStandardInputFile(tempFileName);
+ astyle.start("astyle");
+ if (!astyle.waitForStarted()) {
+ qDebug()<<"Couldn't start the 'astyle' process!";
+ return;
+ }
+
+ if (!astyle.waitForFinished()) {
+ qDebug()<<"Couldn't finish the 'astyle' process";
+ return;
+ }
+
+ QByteArray result = astyle.readAll();
+ setPlainText(QString::fromUtf8(result));
+}
+
+void GLSLEdit::contextMenuEvent(QContextMenuEvent *e)
+{
+ QMenu *menu = createStandardContextMenu();
+
+ menu->addAction(tr("Indent Code"), this, SLOT(indent()));
+
+ menu->exec(e->globalPos());
+ delete menu;
+}
+
#include "glsledit.moc"
void fold(int line);
void unfold(int line);
void toggleFold(int line);
+ void indent();
protected:
- void resizeEvent(QResizeEvent *e);
- void wheelEvent(QWheelEvent *e);
+ virtual void resizeEvent(QResizeEvent *e);
+ virtual void wheelEvent(QWheelEvent *e);
+ virtual void contextMenuEvent(QContextMenuEvent *e);
+
private slots:
void updateCursor();