diff --git a/Makefile b/Makefile index f2f6a37d16175a7878a94987df954db7ea3eb2bc..3229b77e5e0e71b900d9fdbf895e5c2add43c489 100644 --- a/Makefile +++ b/Makefile @@ -119,7 +119,7 @@ TOOLOBJ = $(SIMOBJ) \ $(TARGET_DIR)/tool.o $(TARGET_DIR)/utils.o \ $(TARGET_DIR)/pagewriter.o $(TARGET_DIR)/pagereader.o \ $(TARGET_DIR)/configreader.o $(TARGET_DIR)/attrs.o \ - $(TARGET_DIR)/keyboard.o + $(TARGET_DIR)/keyboard.o $(TARGET_DIR)/box.o $(TARGET_DIR)/ana/%.o: $(SRC_DIR)/ana/%.c diff --git a/include/box.h b/include/box.h new file mode 100644 index 0000000000000000000000000000000000000000..da4838b577cccc957ef3570ccc0e9be3d13bf11f --- /dev/null +++ b/include/box.h @@ -0,0 +1,21 @@ +#ifndef BOX_H +#define BOX_H + +#include <utils/newasm.h> + +typedef struct log_brec { + short x1, y1, x2, y2; + struct log_brec *next; + na_long temp; + unsigned f7 : 1, f6 : 1, f5 : 1, f4 : 1, f3 : 1, f2 : 1, f1 : 1, f0 : 1; +} log_brec; /* Dashed box */ + +void linkbox(log_brec *b); +void newbox(log_brec **b); +void unlinkbox(log_brec *b); +void dispbox(log_brec **b); + +void addboxat(short x1, short y1, short x2, short y2); +void addbox(); + +#endif diff --git a/include/log.h b/include/log.h index ee0ea4edeb97730d761a176d20647d99bfe6fb7a..a146e7f10dd591d21ab1b385a6b6e5dbe16e1a0d 100644 --- a/include/log.h +++ b/include/log.h @@ -31,7 +31,9 @@ void doimmedfunction(); void docnffunction(); void dofunction (); void assertfunc (char *name); +void clearfunc(); void refrfunc(); +void waitnear(); void confirmsimtype(log_nrec *n); void scancn(cnrec *cn, struct LOC_checkcombine *LINK); void addblobs(blobrec **blbase, short x1, short y1, short x2, short y2); @@ -43,7 +45,6 @@ void prealunit2(double r, short p, char *u, char *s); void beginerror(); void enderror(); void setvlsimode(int flag); -void newbox(log_brec **b); short readlibrary(char *n); void histdelsignals(); void histaddsignal(log_hnrec **hn, short sig, short y); diff --git a/include/logdef.h b/include/logdef.h index 7000ddfb830813b8ee1e2e73ee67453264782219..d9bd78e3d462be8a3be5ec9ab6f199cbf106d767 100644 --- a/include/logdef.h +++ b/include/logdef.h @@ -225,13 +225,7 @@ typedef struct log_hnrec { struct log_hnrec *next; } log_hnrec; /* History name */ -typedef struct log_brec { - short x1, y1, x2, y2; - struct log_brec *next; - na_long temp; - unsigned f7 : 1, f6 : 1, f5 : 1, f4 : 1, f3 : 1, f2 : 1, f1 : 1, f0 : 1; -} log_brec; /* Dashed box */ - +typedef struct log_brec log_brec; typedef enum { simst_null, simst_off, simst_notactive, simst_notready, simst_running diff --git a/src/box.c b/src/box.c new file mode 100644 index 0000000000000000000000000000000000000000..d284553c06a25c80cbf14487f0aed80f9ffe4de7 --- /dev/null +++ b/src/box.c @@ -0,0 +1,132 @@ +#include "box.h" +#include "logglobals.h" +#include "screen.h" +#include "log.h" +#include "utils.h" +#include "keyboard.h" + +/// Link box to the current page. +void linkbox(log_brec *b) +{ + b->next = gg.pages[gg.curpage - 1]->bbase; + gg.pages[gg.curpage - 1]->bbase = b; + stamp(&gg.boxstamp); +} + +/// Creates a Box +void newbox(log_brec **b) +{ + *b = (log_brec *)Malloc(sizeof(log_brec)); + (*b)->temp = (na_long)0; + linkbox(*b); +} + +/// Unlink box from the pages. +void unlinkbox(log_brec *b) +{ + log_brec *b1; + + b1 = gg.pages[gg.curpage - 1]->bbase; + while (b1 != NULL && b1->next != b) + b1 = b1->next; + if (b1 == NULL) + gg.pages[gg.curpage - 1]->bbase = b->next; + else + b1->next = b->next; + chpageplace(gg.pages[gg.curpage - 1], b->x1, b->y1, b->x2, b->y2); + stamp(&gg.boxstamp); +} + +/// Dispose of a dashed box. +void dispbox(log_brec **b) +{ + unlinkbox(*b); + Free(*b); +} + +/// Create a new dashed box. +void addboxat(short x1, short y1, short x2, short y2) +{ + log_brec *b; + + newbox(&b); + sortshints(&x1, &x2); + sortshints(&y1, &y2); + b->x1 = x1; + b->y1 = y1; + b->x2 = x2; + b->y2 = y2; + remcursor(); + clipon(); + drawboxc(b, gg.color.dashbox); + clipoff(); + chpageplace(gg.pages[gg.curpage - 1], x1, y1, x2, y2); + gg.nearbox = b; +} + + +void addbox() +{ + short x1, y1; + + log_setmode("BOX"); + clearfunc(); + cursortype = boxcursor; + waitnear(); + do + { + do + { + pass(); + trykbdscroll(); + pen(); + } while (!gg.t.dn && gg.stillnear && *gg.func == '\0'); + gg.posx = gg.gridx; + gg.posy = gg.gridy; + if (gg.incircuit && gg.stillnear && *gg.func == '\0') + { + x1 = gg.posx; + y1 = gg.posy; + do + { + pen(); + x1 = gg.gridx; + y1 = gg.gridy; + m_colormode((long)m_xor); + m_color((long)gg.color.dashbox); + m_linestyle(1L); + rect(gg.posx, gg.posy, x1, y1); + m_linestyle(0L); + m_colormode((long)m_normal); + do + { + pass(); + trykbd(); + pen(); + } while (gg.gridx == x1 && gg.gridy == y1 && gg.t.depressed && *gg.func == '\0'); + + m_colormode((long)m_xor); + m_color((long)gg.color.dashbox); + m_linestyle(1L); + rect(gg.posx, gg.posy, x1, y1); + m_linestyle(0L); + m_colormode((long)m_normal); + scroll(); + } while (gg.t.depressed || abs(x1 - gg.posx) < 2 || abs(y1 - gg.posy) < 2); + sortshints(&gg.posx, &x1); + sortshints(&gg.posy, &y1); + remcursor(); + if (gg.incircuit && *gg.func == '\0') + addboxat(gg.posx, gg.posy, x1, y1); + } + } while (gg.incircuit && gg.stillnear && *gg.func == '\0'); + gg.startpoint = false; + log_setmode(""); + if (gg.t.dn && !gg.incircuit) + { + gg.t.dn = false; + gg.t.depressed = false; + } + cursortype = normal; +} + diff --git a/src/gate.c b/src/gate.c index ea6e95bd3a4b96718ac25e317db8d5ff242d108f..d9b6d361e445bb4b1522ba007755317ff47572a3 100644 --- a/src/gate.c +++ b/src/gate.c @@ -13,6 +13,7 @@ #include "label.h" #include "page.h" #include "tool.h" +#include "box.h" /// Check if inside a gate's "yellow box." /** new version by Tim Edwards, Dec 1996 */ diff --git a/src/log.c b/src/log.c index 3ed0d430f9c698401415d86c8c9d2166bf8d41f4..3dfda579bcd7aaae148969e8fe2c78606f08a4af 100644 --- a/src/log.c +++ b/src/log.c @@ -74,6 +74,7 @@ #include "utils.h" #include "tool.h" #include "keyboard.h" +#include "box.h" #include "pagewriter.h" #include "pagereader.h" @@ -1754,45 +1755,6 @@ static void clearconflicts(log_tool *tool) short getsignal (int d, char *n); -/// Link box to the current page. -static void linkbox(log_brec *b) -{ - b->next = gg.pages[gg.curpage - 1]->bbase; - gg.pages[gg.curpage - 1]->bbase = b; - stamp(&gg.boxstamp); -} - -/// Creates a Box -void newbox(log_brec **b) -{ - *b = (log_brec *)Malloc(sizeof(log_brec)); - (*b)->temp = (na_long)0; - linkbox(*b); -} - -/// Unlink box from the pages. -static void unlinkbox(log_brec *b) -{ - log_brec *b1; - - b1 = gg.pages[gg.curpage - 1]->bbase; - while (b1 != NULL && b1->next != b) - b1 = b1->next; - if (b1 == NULL) - gg.pages[gg.curpage - 1]->bbase = b->next; - else - b1->next = b->next; - chpageplace(gg.pages[gg.curpage - 1], b->x1, b->y1, b->x2, b->y2); - stamp(&gg.boxstamp); -} - -/// Dispose of a dashed box. -static void dispbox(log_brec **b) -{ - unlinkbox(*b); - Free(*b); -} - static void defsimulator(log_action_t *act) { @@ -2281,7 +2243,7 @@ static void readlnpass(char *s, short mode) } -static void clearfunc() +void clearfunc() { if (doingcnffunction) *gg.func = '\0'; @@ -3237,7 +3199,7 @@ static void checkabort() } -static void waitnear() +void waitnear() { do { @@ -8591,92 +8553,6 @@ static void findboxmarker(log_krec *k, short num, short *x1, short *y1, short *x k->y2 = k->vector[i - 1].UU.U99.y2; } -/// Create a new dashed box. -void addboxat(short x1, short y1, short x2, short y2) -{ - log_brec *b; - - newbox(&b); - sortshints(&x1, &x2); - sortshints(&y1, &y2); - b->x1 = x1; - b->y1 = y1; - b->x2 = x2; - b->y2 = y2; - remcursor(); - clipon(); - drawboxc(b, gg.color.dashbox); - clipoff(); - chpageplace(gg.pages[gg.curpage - 1], x1, y1, x2, y2); - gg.nearbox = b; -} - - -static void addbox() -{ - short x1, y1; - - log_setmode("BOX"); - clearfunc(); - cursortype = boxcursor; - waitnear(); - do - { - do - { - pass(); - trykbdscroll(); - pen(); - } while (!gg.t.dn && gg.stillnear && *gg.func == '\0'); - gg.posx = gg.gridx; - gg.posy = gg.gridy; - if (gg.incircuit && gg.stillnear && *gg.func == '\0') - { - x1 = gg.posx; - y1 = gg.posy; - do - { - pen(); - x1 = gg.gridx; - y1 = gg.gridy; - m_colormode((long)m_xor); - m_color((long)gg.color.dashbox); - m_linestyle(1L); - rect(gg.posx, gg.posy, x1, y1); - m_linestyle(0L); - m_colormode((long)m_normal); - do - { - pass(); - trykbd(); - pen(); - } while (gg.gridx == x1 && gg.gridy == y1 && gg.t.depressed && *gg.func == '\0'); - - m_colormode((long)m_xor); - m_color((long)gg.color.dashbox); - m_linestyle(1L); - rect(gg.posx, gg.posy, x1, y1); - m_linestyle(0L); - m_colormode((long)m_normal); - scroll(); - } while (gg.t.depressed || abs(x1 - gg.posx) < 2 || abs(y1 - gg.posy) < 2); - sortshints(&gg.posx, &x1); - sortshints(&gg.posy, &y1); - remcursor(); - if (gg.incircuit && *gg.func == '\0') - addboxat(gg.posx, gg.posy, x1, y1); - } - } while (gg.incircuit && gg.stillnear && *gg.func == '\0'); - gg.startpoint = false; - log_setmode(""); - if (gg.t.dn && !gg.incircuit) - { - gg.t.dn = false; - gg.t.depressed = false; - } - cursortype = normal; -} - static void initcolors (); diff --git a/src/loghier.c b/src/loghier.c index f88835018c64957db52ef19e6407c17b9725f4f5..ba7bfa72d4361a06b4da9485bdb243603d560feb 100644 --- a/src/loghier.c +++ b/src/loghier.c @@ -31,6 +31,7 @@ #include <utils/strings.h> #include "loghier.h" #include "node.h" +#include "box.h" static log_action_t *lact; diff --git a/src/logsimh.c b/src/logsimh.c index 1d721dee0ef8d7a8fd341293b9a950564c2ec882..95069a2172c52a3a7eab43233c4f029c7d887a2e 100644 --- a/src/logsimh.c +++ b/src/logsimh.c @@ -39,6 +39,7 @@ #include <utils/strings.h> #include "logsimh.h" #include "node.h" +#include "box.h" /* caged_date="R lastmoddate = '$X by $U';" */ diff --git a/src/page.c b/src/page.c index 3a29f82ba2d4b6444626a6214cc09ec68dd6e155..696c11fc36ed0799d1e4741173ab4a4fa7528ef9 100644 --- a/src/page.c +++ b/src/page.c @@ -6,6 +6,7 @@ #include "utils.h" #include "page.h" #include "log.h" +#include "box.h" void chpage(log_page *page) { diff --git a/src/pagereader.c b/src/pagereader.c index 7214319e1df7ef95cce994bd0a963c04efcedee7..eeca5b5b3268373e8fc75cee025f5058d27ce810 100644 --- a/src/pagereader.c +++ b/src/pagereader.c @@ -10,6 +10,7 @@ #include "screen.h" #include "tool.h" #include "utils.h" +#include "box.h" void loadfail(char *msg, struct LOC_loadpage *LINK) { diff --git a/src/pagewriter.c b/src/pagewriter.c index b99bbcc945bf8521b442080d4e6a08ad82a25ac2..8acde3dcbe09ca52a83c13fc4990e6d6d1dba398 100644 --- a/src/pagewriter.c +++ b/src/pagewriter.c @@ -8,6 +8,7 @@ #include "screen.h" #include "tool.h" #include "utils.h" +#include "box.h" short countnode(log_nrec *n, struct LOC_savepage *LINK) { diff --git a/src/screen.c b/src/screen.c index f1096339991b2b3336bd92d14ec57b6bbc87c026..1dbd8d185cadd8537ce2a31fe4a785d5ba143ea4 100644 --- a/src/screen.c +++ b/src/screen.c @@ -41,6 +41,7 @@ #include "screen.h" #include "node.h" #include "log.h" +#include "box.h" static rablistrec rabtable[rabtabsize]; ///< Positions of rabbits