add completions for unit styles
This commit is contained in:
@ -129,7 +129,7 @@ CodeEditor::CodeEditor(QWidget *parent) :
|
|||||||
improper_comp(new QCompleter(this)), kspace_comp(new QCompleter(this)),
|
improper_comp(new QCompleter(this)), kspace_comp(new QCompleter(this)),
|
||||||
region_comp(new QCompleter(this)), integrate_comp(new QCompleter(this)),
|
region_comp(new QCompleter(this)), integrate_comp(new QCompleter(this)),
|
||||||
minimize_comp(new QCompleter(this)), variable_comp(new QCompleter(this)),
|
minimize_comp(new QCompleter(this)), variable_comp(new QCompleter(this)),
|
||||||
highlight(NO_HIGHLIGHT)
|
units_comp(new QCompleter(this)), highlight(NO_HIGHLIGHT)
|
||||||
{
|
{
|
||||||
help_action = new QShortcut(QKeySequence::fromString("Ctrl+?"), parent);
|
help_action = new QShortcut(QKeySequence::fromString("Ctrl+?"), parent);
|
||||||
connect(help_action, &QShortcut::activated, this, &CodeEditor::get_help);
|
connect(help_action, &QShortcut::activated, this, &CodeEditor::get_help);
|
||||||
@ -159,6 +159,7 @@ CodeEditor::CodeEditor(QWidget *parent) :
|
|||||||
COMPLETER_SETUP(integrate_comp);
|
COMPLETER_SETUP(integrate_comp);
|
||||||
COMPLETER_SETUP(minimize_comp);
|
COMPLETER_SETUP(minimize_comp);
|
||||||
COMPLETER_SETUP(variable_comp);
|
COMPLETER_SETUP(variable_comp);
|
||||||
|
COMPLETER_SETUP(units_comp);
|
||||||
#undef COMPLETER_SETUP
|
#undef COMPLETER_SETUP
|
||||||
|
|
||||||
// initialize help system
|
// initialize help system
|
||||||
@ -221,6 +222,7 @@ CodeEditor::~CodeEditor()
|
|||||||
delete integrate_comp;
|
delete integrate_comp;
|
||||||
delete minimize_comp;
|
delete minimize_comp;
|
||||||
delete variable_comp;
|
delete variable_comp;
|
||||||
|
delete units_comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CodeEditor::lineNumberAreaWidth()
|
int CodeEditor::lineNumberAreaWidth()
|
||||||
@ -351,6 +353,7 @@ COMPLETER_INIT_FUNC(region, Region)
|
|||||||
COMPLETER_INIT_FUNC(integrate, Integrate)
|
COMPLETER_INIT_FUNC(integrate, Integrate)
|
||||||
COMPLETER_INIT_FUNC(minimize, Minimize)
|
COMPLETER_INIT_FUNC(minimize, Minimize)
|
||||||
COMPLETER_INIT_FUNC(variable, Variable)
|
COMPLETER_INIT_FUNC(variable, Variable)
|
||||||
|
COMPLETER_INIT_FUNC(units, Units)
|
||||||
|
|
||||||
#undef COMPLETER_INIT_FUNC
|
#undef COMPLETER_INIT_FUNC
|
||||||
|
|
||||||
@ -625,6 +628,8 @@ void CodeEditor::runCompletion()
|
|||||||
current_comp = integrate_comp;
|
current_comp = integrate_comp;
|
||||||
else if (words[0] == "minimize_style")
|
else if (words[0] == "minimize_style")
|
||||||
current_comp = minimize_comp;
|
current_comp = minimize_comp;
|
||||||
|
else if (words[0] == "units")
|
||||||
|
current_comp = units_comp;
|
||||||
|
|
||||||
if (current_comp) {
|
if (current_comp) {
|
||||||
current_comp->setCompletionPrefix(words[1].c_str());
|
current_comp->setCompletionPrefix(words[1].c_str());
|
||||||
|
|||||||
@ -55,6 +55,7 @@ public:
|
|||||||
void setIntegrateList(const QStringList &words);
|
void setIntegrateList(const QStringList &words);
|
||||||
void setMinimizeList(const QStringList &words);
|
void setMinimizeList(const QStringList &words);
|
||||||
void setVariableList(const QStringList &words);
|
void setVariableList(const QStringList &words);
|
||||||
|
void setUnitsList(const QStringList &words);
|
||||||
|
|
||||||
static constexpr int NO_HIGHLIGHT = 1 << 30;
|
static constexpr int NO_HIGHLIGHT = 1 << 30;
|
||||||
|
|
||||||
@ -81,7 +82,7 @@ private:
|
|||||||
QShortcut *help_action;
|
QShortcut *help_action;
|
||||||
QCompleter *current_comp, *command_comp, *fix_comp, *compute_comp, *dump_comp, *atom_comp,
|
QCompleter *current_comp, *command_comp, *fix_comp, *compute_comp, *dump_comp, *atom_comp,
|
||||||
*pair_comp, *bond_comp, *angle_comp, *dihedral_comp, *improper_comp, *kspace_comp,
|
*pair_comp, *bond_comp, *angle_comp, *dihedral_comp, *improper_comp, *kspace_comp,
|
||||||
*region_comp, *integrate_comp, *minimize_comp, *variable_comp;
|
*region_comp, *integrate_comp, *minimize_comp, *variable_comp, *units_comp;
|
||||||
|
|
||||||
int highlight;
|
int highlight;
|
||||||
bool reformat_on_return;
|
bool reformat_on_return;
|
||||||
|
|||||||
@ -333,6 +333,13 @@ LammpsGui::LammpsGui(QWidget *parent, const char *filename) :
|
|||||||
style_list.sort();
|
style_list.sort();
|
||||||
ui->textEdit->setVariableList(style_list);
|
ui->textEdit->setVariableList(style_list);
|
||||||
|
|
||||||
|
style_list.clear();
|
||||||
|
const char *unitstyles[] = {"lj", "real", "metal", "si", "cgs", "electron", "micro", "nano"};
|
||||||
|
for (const auto unit : unitstyles)
|
||||||
|
style_list << unit;
|
||||||
|
style_list.sort();
|
||||||
|
ui->textEdit->setUnitsList(style_list);
|
||||||
|
|
||||||
#define ADD_STYLES(keyword, Type) \
|
#define ADD_STYLES(keyword, Type) \
|
||||||
style_list.clear(); \
|
style_list.clear(); \
|
||||||
ncmds = lammps.style_count(#keyword); \
|
ncmds = lammps.style_count(#keyword); \
|
||||||
|
|||||||
Reference in New Issue
Block a user