D25 tech component editor: line numbers shown, more syntax variants

This commit is contained in:
Matthias Koefferlein 2020-04-18 00:37:15 +02:00
parent 07ecaac598
commit 2cdcf621d8
6 changed files with 59 additions and 5 deletions

View File

@ -237,8 +237,31 @@ D25TechnologyComponent::compile_from_source (const std::string &src)
info.set_zstop (z1.to_double ());
}
} else if (args.size () == 1) {
info.set_zstop ((! z0.is_nil () ? z0.to_double () : info.zstart ()) + args[0]);
if (! h.is_nil ()) {
if (! z0.is_nil ()) {
throw tl::Exception (tl::to_string (tr ("Rundundant parameters: zstart already given")));
}
if (! z1.is_nil ()) {
throw tl::Exception (tl::to_string (tr ("Rundundant parameters: zstop implicitly given")));
}
info.set_zstart (args[0]);
info.set_zstop (args[0] + h.to_double ());
} else {
if (! z1.is_nil ()) {
throw tl::Exception (tl::to_string (tr ("Rundundant parameters: zstop implicitly given")));
}
info.set_zstop ((! z0.is_nil () ? z0.to_double () : info.zstart ()) + args[0]);
}
} else if (args.size () == 2) {
if (! z0.is_nil ()) {
throw tl::Exception (tl::to_string (tr ("Rundundant parameters: zstart already given")));
}
if (! z1.is_nil ()) {
throw tl::Exception (tl::to_string (tr ("Rundundant parameters: zstop already given")));
}
if (! h.is_nil ()) {
throw tl::Exception (tl::to_string (tr ("Rundundant parameters: height implicitly given")));
}
info.set_zstart (args[0]);
info.set_zstop (args[1]);
} else {

View File

@ -39,6 +39,9 @@ TEST(1)
comp.compile_from_source ("1/0: zstart=1.0 height=0.5");
EXPECT_EQ (comp.to_string (), "1/0: zstart=1, zstop=1.5");
comp.compile_from_source ("1/0: 1.0 height=0.5");
EXPECT_EQ (comp.to_string (), "1/0: zstart=1, zstop=1.5");
comp.compile_from_source ("1/0: zstop=1.5 height=0.5");
EXPECT_EQ (comp.to_string (), "1/0: zstart=1, zstop=1.5");

View File

@ -13,15 +13,31 @@
<property name="windowTitle">
<string>Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>2.5d Vertical Stack Information</string>
</property>
</widget>
</item>
<item>
<item row="0" column="1">
<widget class="QLabel" name="lnum_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Line</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QTextEdit" name="src_te">
<property name="font">
<font>

View File

@ -52,6 +52,15 @@ D25TechnologyComponentEditor::D25TechnologyComponentEditor (QWidget *parent)
input.close ();
hl->setDocument (src_te->document ());
connect (src_te, SIGNAL (cursorPositionChanged ()), this, SLOT (cursor_position_changed ()));
}
void
D25TechnologyComponentEditor::cursor_position_changed ()
{
int line = src_te->textCursor ().block ().firstLineNumber () + 1;
lnum_label->setText (tl::to_qstring (tl::sprintf (tl::to_string (tr ("Line %d")), line)));
}
void

View File

@ -44,6 +44,9 @@ public:
void commit ();
void setup ();
private slots:
void cursor_position_changed ();
private:
std::auto_ptr<lay::GenericSyntaxHighlighterAttributes> mp_hl_attributes, mp_hl_basic_attributes;
};

View File

@ -63,7 +63,7 @@
<itemData name="Comment" defStyleNum="dsComment"/>
<itemData name="Float" defStyleNum="dsFloat"/>
<itemData name="Dec" defStyleNum="dsDecVal"/>
<itemData name="Symbol" defStyleNum="dsString" color="#D40000"/>
<itemData name="Symbol" defStyleNum="dsKeyword"/>
<itemData name="String" defStyleNum="dsString"/>
<itemData name="Raw String" defStyleNum="dsString" color="#DD4A4A" selColor="#DD4A4A"/>