Commit 3ecced27 authored by con's avatar con
Browse files

Start implementing "edit in vi" for mac.

parent a22a30cf
......@@ -40,7 +40,7 @@
<executable>
<path>%{QT_INSTALL_BINS}/lrelease</path>
<path>lrelease</path>
<arguments>%{CurrentProjectFilePath}</arguments>
<workingdirectory>%{CurrentProjectPath}</workingdirectory>
<arguments>%{CurrentProject:FilePath}</arguments>
<workingdirectory>%{CurrentProject:Path}</workingdirectory>
</executable>
</externaltool>
......@@ -40,7 +40,7 @@
<executable>
<path>%{QT_INSTALL_BINS}/lupdate</path>
<path>lupdate</path>
<arguments>%{CurrentProjectFilePath}</arguments>
<workingdirectory>%{CurrentProjectPath}</workingdirectory>
<arguments>%{CurrentProject:FilePath}</arguments>
<workingdirectory>%{CurrentProject:Path}</workingdirectory>
</executable>
</externaltool>
......@@ -38,7 +38,7 @@
<category xml:lang="de">Text</category>
<executable output="replaceselection" error="ignore">
<path>sort</path>
<input>%{CurrentSelection}</input>
<workingdirectory>%{CurrentPath}</workingdirectory>
<input>%{CurrentDocument:Selection}</input>
<workingdirectory>%{CurrentDocument:Path}</workingdirectory>
</executable>
</externaltool>
......@@ -38,7 +38,7 @@
<category xml:lang="de">Text</category>
<executable output="reloaddocument">
<path>xterm</path>
<arguments>-geom %{EditorCharWidth}x%{EditorCharHeight}+%{EditorXPos}+%{EditorYPos} -e vi %{CurrentFilePath} +%{EditorLine} +"normal %{EditorColumn}|"</arguments>
<workingdirectory>%{CurrentPath}</workingdirectory>
<arguments>-geom %{CurrentDocument:Width}x%{CurrentDocument:Height}+%{CurrentDocument:XPos}+%{CurrentDocument:YPos} -e vi %{CurrentDocument:FilePath} +%{CurrentDocument:Line} +"normal %{CurrentDocument:Column}|"</arguments>
<workingdirectory>%{CurrentDocument:Path}</workingdirectory>
</executable>
</externaltool>
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
-->
<externaltool id="vi">
<description>Opens the current file in vi</description>
<description xml:lang="de">Öffnet die aktuelle Datei in vi</description>
<displayname>Edit with vi</displayname>
<displayname xml:lang="de">In vi öffnen</displayname>
<category>Text</category>
<category xml:lang="de">Text</category>
<executable output="reloaddocument">
<path>osascript</path>
<input>
tell application "Terminal"
do script "vi \"%{CurrentDocument:FilePath}\"; exit"
set currentTab to the result
activate
end tell
</input>
<workingdirectory>%{CurrentDocument:Path}</workingdirectory>
</executable>
</externaltool>
......@@ -44,7 +44,8 @@ DATA_FILES = \
externaltools/lupdate.xml
unix:DATA_FILES += externaltools/sort.xml
linux-*:DATA_FILES += externaltools/vi.xml
macx:DATA_FILES += runInTerminal.command
macx:DATA_FILES += externaltools/vi_mac.xml
#macx:DATA_FILES += runInTerminal.command
win32:DATA_FILES ~= s|\\\\|/|g
OTHER_FILES += $$DATA_FILES
......
......@@ -477,6 +477,9 @@ void EditorManager::init()
m_d->m_openEditorsFactory = new OpenEditorsViewFactory();
pluginManager()->addObject(m_d->m_openEditorsFactory);
connect(VariableManager::instance(), SIGNAL(variableUpdateRequested(QString)),
this, SLOT(updateVariable(QString)));
}
......@@ -2134,3 +2137,23 @@ QString EditorManager::windowTitleAddition() const
return m_d->m_titleAddition;
}
void EditorManager::updateVariable(const QString &variable)
{
static const char * const kCurrentDocumentFilePath = "CurrentDocument:FilePath";
static const char * const kCurrentDocumentPath = "CurrentDocument:Path";
if (variable == QLatin1String(kCurrentDocumentFilePath)
|| variable == QLatin1String(kCurrentDocumentPath)) {
QString value;
IEditor *curEditor = currentEditor();
if (curEditor) {
QString fileName = curEditor->file()->fileName();
if (!fileName.isEmpty()) {
if (variable == QLatin1String(kCurrentDocumentFilePath))
value = QFileInfo(fileName).filePath();
else if (variable == QLatin1String(kCurrentDocumentPath))
value = QFileInfo(fileName).path();
}
}
VariableManager::instance()->insert(variable, value);
}
}
......@@ -228,6 +228,7 @@ private slots:
void makeCurrentEditorWritable();
void updateWindowTitle();
void handleEditorStateChange();
void updateVariable(const QString &variable);
public slots:
void goBackInNavigationHistory();
......
......@@ -1001,16 +1001,16 @@ void ProjectExplorerPlugin::loadCustomWizards()
void ProjectExplorerPlugin::updateVariable(const QString &variable)
{
static const char * const currentProjectPathVar = "CurrentProjectPath";
static const char * const currentProjectFilePathVar = "CurrentProjectFilePath";
if (variable == QLatin1String(currentProjectFilePathVar)) {
static const char * const kCurrentProjectPath= "CurrentProject:Path";
static const char * const kCurrentProjectFilePath= "CurrentProject:FilePath";
if (variable == QLatin1String(kCurrentProjectFilePath)) {
if (currentProject() && currentProject()->file()) {
Core::VariableManager::instance()->insert(variable,
currentProject()->file()->fileName());
} else {
Core::VariableManager::instance()->remove(variable);
}
} else if (variable == QLatin1String(currentProjectPathVar)) {
} else if (variable == QLatin1String(kCurrentProjectPath)) {
if (currentProject() && currentProject()->file()) {
Core::VariableManager::instance()->insert(variable,
QFileInfo(currentProject()->file()->fileName()).filePath());
......
......@@ -179,16 +179,16 @@ void Qt4Manager::editorAboutToClose(Core::IEditor *editor)
void Qt4Manager::updateVariable(const QString &variable)
{
static const char * const installBinsVar = "QT_INSTALL_BINS";
if (variable == QLatin1String(installBinsVar)) {
static const char * const kInstallBins = "QT_INSTALL_BINS";
if (variable == QLatin1String(kInstallBins)) {
Qt4Project *qt4pro = qobject_cast<Qt4Project *>(projectExplorer()->currentProject());
if (!qt4pro) {
Core::VariableManager::instance()->remove(QLatin1String(installBinsVar));
Core::VariableManager::instance()->remove(QLatin1String(kInstallBins));
return;
}
QString value = qt4pro->activeTarget()->activeBuildConfiguration()
->qtVersion()->versionInfo().value(QLatin1String(installBinsVar));
Core::VariableManager::instance()->insert(QLatin1String(installBinsVar), value);
->qtVersion()->versionInfo().value(QLatin1String(kInstallBins));
Core::VariableManager::instance()->insert(QLatin1String(kInstallBins), value);
}
}
......
......@@ -216,8 +216,8 @@ void TextEditorPlugin::updateSearchResultsFont(const FontSettings &settings)
void TextEditorPlugin::updateVariable(const QString &variable)
{
static const char * const kCurrentSelectionVar = "CurrentSelection";
if (variable == QLatin1String(kCurrentSelectionVar)) {
static const char * const kCurrentDocumentSelection= "CurrentDocument:Selection";
if (variable == QLatin1String(kCurrentDocumentSelection)) {
QString selectedText;
Core::IEditor *iface = Core::EditorManager::instance()->currentEditor();
ITextEditor *editor = qobject_cast<ITextEditor *>(iface);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment