From ef6e8602a6c3c86338e5c895e94b6fb1e21dee06 Mon Sep 17 00:00:00 2001
From: Etienne Brateau <etienne.brateau@ensiie.fr>
Date: Sun, 10 Feb 2019 17:01:37 +0100
Subject: [PATCH] Move some functions into wire (solder functions)

---
 include/wire.h |  8 +++++++
 src/log.c      | 57 --------------------------------------------------
 src/wire.c     | 56 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+), 57 deletions(-)

diff --git a/include/wire.h b/include/wire.h
index 34cf539..1d41322 100644
--- a/include/wire.h
+++ b/include/wire.h
@@ -60,4 +60,12 @@ void chghw(log_hwrec *hw, log_nrec *oldnode, log_nrec *n);
 
 void chgvw(log_vwrec *vw, log_nrec *oldnode, log_nrec *n);
 
+void unsoldernear();
+
+void unsolderwires(log_hwrec *hw, log_vwrec *vw);
+
+void soldernear();
+
+void solderat(short x, short y);
+
 #endif
diff --git a/src/log.c b/src/log.c
index 5ceba73..5ab5517 100644
--- a/src/log.c
+++ b/src/log.c
@@ -7357,63 +7357,6 @@ static void touchgate(log_grec *g)
 		flipgate(g);
 }
 
-static void unsoldernear()
-{
-	short oldx, oldy1, oldy2, oldcolr;
-	blobrec *blbase;
-
-	oldx = gg.nearvw->x;
-	oldy1 = gg.nearvw->y1;
-	oldy2 = gg.nearvw->y2;
-	oldcolr = gg.nearvw->wcolr;
-	if (gg.nearhw->y == oldy1 || gg.nearhw->y == oldy2 ||
-			gg.nearhw->x1 == oldx || gg.nearhw->x2 == oldx)
-		return;
-	remcursor();
-	blbase = NULL;
-	addblobs(&blbase, oldx, oldy1, oldx, gg.nearhw->y - 1);
-	addblobs(&blbase, oldx, gg.nearhw->y + 1, oldx, oldy2);
-	delvwire(gg.nearvw);
-	addvwire(oldx, oldy1, oldy2, oldcolr);
-	doblobs(blbase);
-	dispblobs(&blbase);
-}
-
-
-static void unsolderwires(log_hwrec *hw, log_vwrec *vw)
-{
-	if (hw == NULL || vw == NULL)
-		return;
-	gg.nearhw = hw;
-	gg.nearvw = vw;
-	unsoldernear();
-}
-
-
-static void soldernear()
-{
-	if (!trycombinenodes(&gg.nearvw->node, &gg.nearhw->node))
-	{
-		frysolder(gg.nearvw->x, gg.nearhw->y);
-		return;
-	}
-	clipon();
-	addsolder(gg.nearvw->x, gg.nearhw->y, gg.nearhw, NULL, gg.nearvw, NULL);
-	clipoff();
-}
-
-
-void solderat(short x, short y)
-{
-	if (findsolder(x, y) != NULL)
-		return;
-	closerwire(x, y);
-	if (gg.nearhw != NULL && gg.nearvw != NULL && gg.nearhw->x1 != x &&
-			gg.nearhw->x2 != x && gg.nearvw->y1 != y && gg.nearvw->y2 != y)
-		soldernear();
-}
-
-
 static void findattrnum2(short numattrs, log_kattrrec *kattr, strlist_t *lbl, char *name, char *kinds, short *num)
 {
 	strlist_t *l1;
diff --git a/src/wire.c b/src/wire.c
index 73100cf..b5738c0 100644
--- a/src/wire.c
+++ b/src/wire.c
@@ -974,3 +974,59 @@ void addvwire2(short x, short y1, short y2)
 	addvwire(x, y1, y2, log_wcol_normal);
 }
 
+void unsoldernear()
+{
+	short oldx, oldy1, oldy2, oldcolr;
+	blobrec *blbase;
+
+	oldx = gg.nearvw->x;
+	oldy1 = gg.nearvw->y1;
+	oldy2 = gg.nearvw->y2;
+	oldcolr = gg.nearvw->wcolr;
+	if (gg.nearhw->y == oldy1 || gg.nearhw->y == oldy2 ||
+			gg.nearhw->x1 == oldx || gg.nearhw->x2 == oldx)
+		return;
+	remcursor();
+	blbase = NULL;
+	addblobs(&blbase, oldx, oldy1, oldx, gg.nearhw->y - 1);
+	addblobs(&blbase, oldx, gg.nearhw->y + 1, oldx, oldy2);
+	delvwire(gg.nearvw);
+	addvwire(oldx, oldy1, oldy2, oldcolr);
+	doblobs(blbase);
+	dispblobs(&blbase);
+}
+
+
+void unsolderwires(log_hwrec *hw, log_vwrec *vw)
+{
+	if (hw == NULL || vw == NULL)
+		return;
+	gg.nearhw = hw;
+	gg.nearvw = vw;
+	unsoldernear();
+}
+
+
+void soldernear()
+{
+	if (!trycombinenodes(&gg.nearvw->node, &gg.nearhw->node))
+	{
+		frysolder(gg.nearvw->x, gg.nearhw->y);
+		return;
+	}
+	clipon();
+	addsolder(gg.nearvw->x, gg.nearhw->y, gg.nearhw, NULL, gg.nearvw, NULL);
+	clipoff();
+}
+
+
+void solderat(short x, short y)
+{
+	if (findsolder(x, y) != NULL)
+		return;
+	closerwire(x, y);
+	if (gg.nearhw != NULL && gg.nearvw != NULL && gg.nearhw->x1 != x &&
+			gg.nearhw->x2 != x && gg.nearvw->y1 != y && gg.nearvw->y2 != y)
+		soldernear();
+}
+
-- 
GitLab