Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
e346c0d7
Commit
e346c0d7
authored
Mar 30, 2009
by
hjk
Browse files
fakevim: move settings/action related code to files of their own
parent
99635528
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/plugins/fakevim/fakevim.pro
View file @
e346c0d7
...
...
@@ -14,10 +14,12 @@ include(../../shared/indenter/indenter.pri)
QT
+=
gui
SOURCES
+=
\
fakevimactions
.
cpp
\
fakevimhandler
.
cpp
\
fakevimplugin
.
cpp
HEADERS
+=
\
fakevimactions
.
h
\
fakevimhandler
.
h
\
fakevimplugin
.
h
...
...
src/plugins/fakevim/fakevimactions.cpp
0 → 100644
View file @
e346c0d7
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (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 qt-sales@nokia.com.
**
**************************************************************************/
#include
"fakevimactions.h"
// Please do not add any direct dependencies to other Qt Creator code here.
// Instead emit signals and let the FakeVimPlugin channel the information to
// Qt Creator. The idea is to keep this file here in a "clean" state that
// allows easy reuse with any QTextEdit or QPlainTextEdit derived class.
#include
<utils/qtcassert.h>
#include
<QtCore/QDebug>
#include
<QtCore/QFile>
#include
<QtCore/QObject>
#include
<QtCore/QPointer>
#include
<QtCore/QProcess>
#include
<QtCore/QRegExp>
#include
<QtCore/QTextStream>
#include
<QtCore/QtAlgorithms>
#include
<QtCore/QStack>
using
namespace
Core
::
Utils
;
///////////////////////////////////////////////////////////////////////
//
// FakeVimSettings
//
///////////////////////////////////////////////////////////////////////
namespace
FakeVim
{
namespace
Internal
{
FakeVimSettings
::
FakeVimSettings
()
{}
FakeVimSettings
::~
FakeVimSettings
()
{
qDeleteAll
(
m_items
);
}
void
FakeVimSettings
::
insertItem
(
int
code
,
SavedAction
*
item
,
const
QString
&
longName
,
const
QString
&
shortName
)
{
QTC_ASSERT
(
!
m_items
.
contains
(
code
),
qDebug
()
<<
code
<<
item
->
toString
();
return
);
m_items
[
code
]
=
item
;
if
(
!
longName
.
isEmpty
())
{
m_nameToCode
[
longName
]
=
code
;
m_codeToName
[
code
]
=
longName
;
}
if
(
!
shortName
.
isEmpty
())
{
m_nameToCode
[
shortName
]
=
code
;
}
}
void
FakeVimSettings
::
readSettings
(
QSettings
*
settings
)
{
foreach
(
SavedAction
*
item
,
m_items
)
item
->
readSettings
(
settings
);
}
void
FakeVimSettings
::
writeSettings
(
QSettings
*
settings
)
{
foreach
(
SavedAction
*
item
,
m_items
)
item
->
writeSettings
(
settings
);
}
SavedAction
*
FakeVimSettings
::
item
(
int
code
)
{
QTC_ASSERT
(
m_items
.
value
(
code
,
0
),
qDebug
()
<<
"CODE: "
<<
code
;
return
0
);
return
m_items
.
value
(
code
,
0
);
}
FakeVimSettings
*
theFakeVimSettings
()
{
static
FakeVimSettings
*
instance
=
0
;
if
(
instance
)
return
instance
;
instance
=
new
FakeVimSettings
;
SavedAction
*
item
=
0
;
item
=
new
SavedAction
(
instance
);
item
->
setText
(
QObject
::
tr
(
"Use vim-style editing"
));
item
->
setSettingsKey
(
"FakeVim"
,
"UseFakeVim"
);
instance
->
insertItem
(
ConfigUseFakeVim
,
item
);
item
=
new
SavedAction
(
instance
);
item
->
setDefaultValue
(
false
);
item
->
setSettingsKey
(
"FakeVim"
,
"StartOfLine"
);
instance
->
insertItem
(
ConfigStartOfLine
,
item
,
"startofline"
,
"sol"
);
item
=
new
SavedAction
(
instance
);
item
->
setDefaultValue
(
8
);
item
->
setSettingsKey
(
"FakeVim"
,
"TabStop"
);
instance
->
insertItem
(
ConfigTabStop
,
item
,
"tabstop"
,
"ts"
);
item
=
new
SavedAction
(
instance
);
item
->
setDefaultValue
(
false
);
item
->
setSettingsKey
(
"FakeVim"
,
"SmartTab"
);
instance
->
insertItem
(
ConfigSmartTab
,
item
,
"smarttab"
,
"sta"
);
item
=
new
SavedAction
(
instance
);
item
->
setDefaultValue
(
true
);
item
->
setSettingsKey
(
"FakeVim"
,
"HlSearch"
);
instance
->
insertItem
(
ConfigHlSearch
,
item
,
"hlsearch"
,
"hls"
);
item
=
new
SavedAction
(
instance
);
item
->
setDefaultValue
(
8
);
item
->
setSettingsKey
(
"FakeVim"
,
"ShiftWidth"
);
instance
->
insertItem
(
ConfigShiftWidth
,
item
,
"shiftwidth"
,
"sw"
);
item
=
new
SavedAction
(
instance
);
item
->
setDefaultValue
(
false
);
item
->
setSettingsKey
(
"FakeVim"
,
"ExpandTab"
);
instance
->
insertItem
(
ConfigExpandTab
,
item
,
"expandtab"
,
"et"
);
item
=
new
SavedAction
(
instance
);
item
->
setDefaultValue
(
false
);
item
->
setSettingsKey
(
"FakeVim"
,
"AutoIndent"
);
instance
->
insertItem
(
ConfigAutoIndent
,
item
,
"autoindent"
,
"ai"
);
item
=
new
SavedAction
(
instance
);
item
->
setDefaultValue
(
"indent,eol,start"
);
item
->
setSettingsKey
(
"FakeVim"
,
"Backspace"
);
instance
->
insertItem
(
ConfigBackspace
,
item
,
"backspace"
,
"bs"
);
item
=
new
SavedAction
(
instance
);
item
->
setText
(
QObject
::
tr
(
"FakeVim properties..."
));
instance
->
insertItem
(
SettingsDialog
,
item
);
return
instance
;
}
SavedAction
*
theFakeVimSetting
(
int
code
)
{
return
theFakeVimSettings
()
->
item
(
code
);
}
}
// namespace Internal
}
// namespace FakeVim
src/plugins/fakevim/fakevimactions.h
0 → 100644
View file @
e346c0d7
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (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 qt-sales@nokia.com.
**
**************************************************************************/
#ifndef FAKEVIM_ACTIONS_H
#define FAKEVIM_ACTIONS_H
#include
<utils/savedaction.h>
#include
<QtCore/QHash>
#include
<QtCore/QObject>
#include
<QtCore/QString>
namespace
FakeVim
{
namespace
Internal
{
enum
FakeVimSettingsCode
{
ConfigUseFakeVim
,
ConfigStartOfLine
,
ConfigHlSearch
,
ConfigTabStop
,
ConfigSmartTab
,
ConfigShiftWidth
,
ConfigExpandTab
,
ConfigAutoIndent
,
// indent allow backspacing over autoindent
// eol allow backspacing over line breaks (join lines)
// start allow backspacing over the start of insert; CTRL-W and CTRL-U
// stop once at the start of insert.
ConfigBackspace
,
// other actions
SettingsDialog
,
};
class
FakeVimSettings
:
public
QObject
{
public:
FakeVimSettings
();
~
FakeVimSettings
();
void
insertItem
(
int
code
,
Core
::
Utils
::
SavedAction
*
item
,
const
QString
&
longname
=
QString
(),
const
QString
&
shortname
=
QString
());
Core
::
Utils
::
SavedAction
*
item
(
int
code
);
Core
::
Utils
::
SavedAction
*
item
(
const
QString
&
name
);
void
readSettings
(
QSettings
*
settings
);
void
writeSettings
(
QSettings
*
settings
);
public:
QHash
<
int
,
Core
::
Utils
::
SavedAction
*>
m_items
;
QHash
<
QString
,
int
>
m_nameToCode
;
QHash
<
int
,
QString
>
m_codeToName
;
};
FakeVimSettings
*
theFakeVimSettings
();
Core
::
Utils
::
SavedAction
*
theFakeVimSetting
(
int
code
);
}
// namespace Internal
}
// namespace FakeVim
#endif // FAKEVIM_ACTTIONS_H
src/plugins/fakevim/fakevimhandler.cpp
View file @
e346c0d7
...
...
@@ -87,125 +87,9 @@
using
namespace
Core
::
Utils
;
///////////////////////////////////////////////////////////////////////
//
// FakeVimSettings
//
///////////////////////////////////////////////////////////////////////
namespace
FakeVim
{
namespace
Internal
{
FakeVimSettings
::
FakeVimSettings
(
QObject
*
parent
)
:
QObject
(
parent
)
{}
FakeVimSettings
::~
FakeVimSettings
()
{
qDeleteAll
(
m_items
);
}
void
FakeVimSettings
::
insertItem
(
int
code
,
SavedAction
*
item
,
const
QString
&
longName
,
const
QString
&
shortName
)
{
QTC_ASSERT
(
!
m_items
.
contains
(
code
),
qDebug
()
<<
code
<<
item
->
toString
();
return
);
m_items
[
code
]
=
item
;
if
(
!
longName
.
isEmpty
())
{
m_nameToCode
[
longName
]
=
code
;
m_codeToName
[
code
]
=
longName
;
}
if
(
!
shortName
.
isEmpty
())
{
m_nameToCode
[
shortName
]
=
code
;
}
}
void
FakeVimSettings
::
readSettings
(
QSettings
*
settings
)
{
foreach
(
SavedAction
*
item
,
m_items
)
item
->
readSettings
(
settings
);
}
void
FakeVimSettings
::
writeSettings
(
QSettings
*
settings
)
{
foreach
(
SavedAction
*
item
,
m_items
)
item
->
writeSettings
(
settings
);
}
SavedAction
*
FakeVimSettings
::
item
(
int
code
)
{
QTC_ASSERT
(
m_items
.
value
(
code
,
0
),
qDebug
()
<<
"CODE: "
<<
code
;
return
0
);
return
m_items
.
value
(
code
,
0
);
}
FakeVimSettings
*
theFakeVimSettings
()
{
static
FakeVimSettings
*
instance
=
0
;
if
(
instance
)
return
instance
;
instance
=
new
FakeVimSettings
;
SavedAction
*
item
=
0
;
item
=
new
SavedAction
(
instance
);
item
->
setText
(
QObject
::
tr
(
"Use vim-style editing"
));
item
->
setSettingsKey
(
"FakeVim"
,
"UseFakeVim"
);
instance
->
insertItem
(
ConfigUseFakeVim
,
item
);
item
=
new
SavedAction
(
instance
);
item
->
setDefaultValue
(
false
);
item
->
setSettingsKey
(
"FakeVim"
,
"StartOfLine"
);
instance
->
insertItem
(
ConfigStartOfLine
,
item
,
"startofline"
,
"sol"
);
item
=
new
SavedAction
(
instance
);
item
->
setDefaultValue
(
8
);
item
->
setSettingsKey
(
"FakeVim"
,
"TabStop"
);
instance
->
insertItem
(
ConfigTabStop
,
item
,
"tabstop"
,
"ts"
);
item
=
new
SavedAction
(
instance
);
item
->
setDefaultValue
(
false
);
item
->
setSettingsKey
(
"FakeVim"
,
"SmartTab"
);
instance
->
insertItem
(
ConfigSmartTab
,
item
,
"smarttab"
,
"sta"
);
item
=
new
SavedAction
(
instance
);
item
->
setDefaultValue
(
true
);
item
->
setSettingsKey
(
"FakeVim"
,
"HlSearch"
);
instance
->
insertItem
(
ConfigHlSearch
,
item
,
"hlsearch"
,
"hls"
);
item
=
new
SavedAction
(
instance
);
item
->
setDefaultValue
(
8
);
item
->
setSettingsKey
(
"FakeVim"
,
"ShiftWidth"
);
instance
->
insertItem
(
ConfigShiftWidth
,
item
,
"shiftwidth"
,
"sw"
);
item
=
new
SavedAction
(
instance
);
item
->
setDefaultValue
(
false
);
item
->
setSettingsKey
(
"FakeVim"
,
"ExpandTab"
);
instance
->
insertItem
(
ConfigExpandTab
,
item
,
"expandtab"
,
"et"
);
item
=
new
SavedAction
(
instance
);
item
->
setDefaultValue
(
false
);
item
->
setSettingsKey
(
"FakeVim"
,
"AutoIndent"
);
instance
->
insertItem
(
ConfigAutoIndent
,
item
,
"autoindent"
,
"ai"
);
item
=
new
SavedAction
(
instance
);
item
->
setDefaultValue
(
"indent,eol,start"
);
item
->
setSettingsKey
(
"FakeVim"
,
"Backspace"
);
instance
->
insertItem
(
ConfigBackspace
,
item
,
"backspace"
,
"bs"
);
item
=
new
SavedAction
(
instance
);
item
->
setText
(
QObject
::
tr
(
"FakeVim properties..."
));
instance
->
insertItem
(
SettingsDialog
,
item
);
return
instance
;
}
SavedAction
*
theFakeVimSetting
(
int
code
)
{
return
theFakeVimSettings
()
->
item
(
code
);
}
///////////////////////////////////////////////////////////////////////
//
// FakeVimHandler
...
...
@@ -1911,10 +1795,6 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
}
else
if
(
reSet
.
indexIn
(
cmd
)
!=
-
1
)
{
// :set
QString
arg
=
reSet
.
cap
(
2
);
if
(
arg
.
isEmpty
())
{
//QString info;
//foreach (const QString &key, m_config.keys())
// info += key + ": " + m_config.value(key) + "\n";
//emit q->extraInformationChanged(info);
theFakeVimSetting
(
SettingsDialog
)
->
trigger
(
QVariant
());
/*
} else if (theFakeVimSettings()->.contains(arg)) {
...
...
src/plugins/fakevim/fakevimhandler.h
View file @
e346c0d7
...
...
@@ -30,68 +30,14 @@
#ifndef FAKEVIM_HANDLER_H
#define FAKEVIM_HANDLER_H
#include
<utils/saved
action.h
>
#include
"fakevim
action
s
.h
"
#include
<QtCore/QObject>
#include
<QtGui/QTextEdit>
QT_BEGIN_NAMESPACE
class
QString
;
class
QEvent
;
QT_END_NAMESPACE
namespace
FakeVim
{
namespace
Internal
{
enum
FakeVimSettingsCode
{
ConfigUseFakeVim
,
ConfigStartOfLine
,
ConfigHlSearch
,
ConfigTabStop
,
ConfigSmartTab
,
ConfigShiftWidth
,
ConfigExpandTab
,
ConfigAutoIndent
,
// indent allow backspacing over autoindent
// eol allow backspacing over line breaks (join lines)
// start allow backspacing over the start of insert; CTRL-W and CTRL-U
// stop once at the start of insert.
ConfigBackspace
,
// other actions
SettingsDialog
,
};
class
FakeVimSettings
:
public
QObject
{
Q_OBJECT
public:
FakeVimSettings
(
QObject
*
parent
=
0
);
~
FakeVimSettings
();
void
insertItem
(
int
code
,
Core
::
Utils
::
SavedAction
*
item
,
const
QString
&
longname
=
QString
(),
const
QString
&
shortname
=
QString
());
Core
::
Utils
::
SavedAction
*
item
(
int
code
);
Core
::
Utils
::
SavedAction
*
item
(
const
QString
&
name
);
public
slots
:
void
readSettings
(
QSettings
*
settings
);
void
writeSettings
(
QSettings
*
settings
);
public:
QHash
<
int
,
Core
::
Utils
::
SavedAction
*>
m_items
;
QHash
<
QString
,
int
>
m_nameToCode
;
QHash
<
int
,
QString
>
m_codeToName
;
};
FakeVimSettings
*
theFakeVimSettings
();
Core
::
Utils
::
SavedAction
*
theFakeVimSetting
(
int
code
);
class
FakeVimHandler
:
public
QObject
{
Q_OBJECT
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment