Skip to content

Commit 455e1af

Browse files
committed
web: fix schematic port_directions and dark mode visibility
Add missing field(std::string, const char*) overload to JsonBuilder. Without it, field(getName(), ioTypeToDirection()) resolved to the bool overload (standard pointer-to-bool conversion beats user-defined const char*-to-string), writing true instead of "input"/"output"/"inout". Invert netlistsvg SVG colors in dark mode so strokes and text are visible against the dark background. Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
1 parent 64e3b44 commit 455e1af

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

src/web/src/json_builder.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ class JsonBuilder
155155
buf_ += val ? "true" : "false";
156156
}
157157

158+
void field(const std::string& key, const char* val)
159+
{
160+
field(key.c_str(), val);
161+
}
158162
void field(const std::string& key, int val) { field(key.c_str(), val); }
159163
void field(const std::string& key, float val) { field(key.c_str(), val); }
160164
void field(const std::string& key, double val) { field(key.c_str(), val); }

src/web/src/style.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,3 +1214,10 @@ html, body {
12141214
flex-direction: column;
12151215
gap: 4px;
12161216
}
1217+
1218+
/* ─── Schematic Widget ────────────────────────────────────────────────────── */
1219+
1220+
/* netlistsvg renders dark strokes/text on white fills — invert for dark mode */
1221+
html[data-theme="dark"] .schematic-widget svg {
1222+
filter: invert(1) hue-rotate(180deg);
1223+
}

src/web/test/cpp/TestRequestHandler.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,24 @@ TEST(JsonEscapeTest, ControlChars)
126126
EXPECT_EQ(json_escape(input), "\\u0001");
127127
}
128128

129+
//------------------------------------------------------------------------------
130+
// JsonBuilder overload tests
131+
//------------------------------------------------------------------------------
132+
133+
// Verify that field(std::string, const char*) writes a JSON string, not a bool.
134+
// Without an explicit overload, C++ prefers the standard pointer-to-bool
135+
// conversion over the user-defined const char*-to-std::string conversion,
136+
// silently writing "true" instead of the intended string value.
137+
TEST(JsonBuilderTest, FieldStringKeyCharPtrValueWritesString)
138+
{
139+
JsonBuilder b;
140+
b.beginObject();
141+
b.field(std::string("dir"), "input");
142+
b.endObject();
143+
EXPECT_NE(b.str().find("\"input\""), std::string::npos);
144+
EXPECT_EQ(b.str().find("true"), std::string::npos);
145+
}
146+
129147
//------------------------------------------------------------------------------
130148
// dispatch_request tests (BOUNDS, LAYERS, INFO)
131149
//------------------------------------------------------------------------------

0 commit comments

Comments
 (0)