diff --git a/src/frontend/wdisp/windisp.c b/src/frontend/wdisp/windisp.c index 6999fd113..47272fc55 100644 --- a/src/frontend/wdisp/windisp.c +++ b/src/frontend/wdisp/windisp.c @@ -44,7 +44,6 @@ typedef tWindowData *tpWindowData; /* pointer to it */ #define pWindowData(g) ((tpWindowData)(g->devdep)) -/* forwards */ LRESULT CALLBACK PlotWindowProc(HWND hwnd, /* window procedure */ UINT uMsg, WPARAM wParam, LPARAM lParam); void WPRINT_PrintInit(HWND hwnd); /* Windows printer init */ @@ -56,7 +55,6 @@ static LRESULT HcpyPlotBW(HWND hwnd); static LRESULT PrintPlot(HWND hwnd); static LRESULT PrintInit(HWND hwnd); //static void RealClose(void); -/* externals */ extern HINSTANCE hInst; /* application instance */ extern int WinLineWidth; /* width of text window */ @@ -109,7 +107,8 @@ WIN_Init() returns 0, if no error ocurred. WIN_Init() does not yet open a window, this happens only in WIN_NewViewport() ******************************************************************************/ -int WIN_Init(void) +int +WIN_Init(void) { char colorstring[BSIZE_SP]; @@ -122,15 +121,14 @@ int WIN_Init(void) /* always, user may have set color0 to white */ /* get background color information from spinit, only "white" is recognized as a suitable option! */ - if (cp_getvar("color0", CP_STRING, colorstring)) { - if (cieq(colorstring, "white")) isblack = FALSE; - else isblack = TRUE; - } + if (cp_getvar("color0", CP_STRING, colorstring)) + isblack = !cieq(colorstring, "white"); /* get linewidth information from spinit */ if (!cp_getvar("xbrushwidth", CP_NUM, &linewidth)) linewidth = 0; - if (linewidth < 0) linewidth = 0; + if (linewidth < 0) + linewidth = 0; /* only for the first time: */ if (!IsRegistered) { @@ -138,9 +136,11 @@ int WIN_Init(void) isblackold = isblack; /* get linewidth information from spinit - if (!cp_getvar("xbrushwidth", CP_NUM, &linewidth)) - linewidth = 0; - if (linewidth < 0) linewidth = 0; */ + * if (!cp_getvar("xbrushwidth", CP_NUM, &linewidth)) + * linewidth = 0; + * if (linewidth < 0) + * linewidth = 0; + */ /* Initialize colors */ if (isblack) { @@ -200,7 +200,8 @@ int WIN_Init(void) TheWndClass.cbClsExtra = 0; TheWndClass.cbWndExtra = sizeof(GRAPH *); - if (!RegisterClass(&TheWndClass)) return 1; + if (!RegisterClass(&TheWndClass)) + return 1; } /* not first time */ else if (isblackold != isblack) { @@ -222,20 +223,22 @@ int WIN_Init(void) IsRegistered = 1; /* ready */ - return (0); + return 0; } /* get pointer to graph */ /* (attach to window) */ -static GRAPH *pGraph(HWND hwnd) +static GRAPH * +pGraph(HWND hwnd) { return (GRAPH *) GetWindowLongPtr(hwnd, 0); } /* return line style for plotting */ -static int LType(int ColorIndex) +static int +LType(int ColorIndex) { if (ColorIndex >= 12) return PS_DOT; @@ -246,7 +249,8 @@ static int LType(int ColorIndex) /* postscript hardcopy from a plot window */ /* called by SystemMenue / Postscript hardcopy */ -static LRESULT HcpyPlot(HWND hwnd) +static LRESULT +HcpyPlot(HWND hwnd) { int colorval = isblack? 0 : 1; NG_IGNORE(hwnd); @@ -256,7 +260,8 @@ static LRESULT HcpyPlot(HWND hwnd) } -static LRESULT HcpyPlotBW(HWND hwnd) +static LRESULT +HcpyPlotBW(HWND hwnd) { int bgcolor; NG_IGNORE(hwnd); @@ -269,28 +274,33 @@ static LRESULT HcpyPlotBW(HWND hwnd) /* print a plot window */ /* called by SystemMenue / Print */ -static LRESULT PrintPlot(HWND hwnd) +static LRESULT +PrintPlot(HWND hwnd) { GRAPH *graph; GRAPH *temp; /* get pointer to graph */ graph = pGraph(hwnd); - if (!graph) return 0; + if (!graph) + return 0; /* switch to printer */ /* (results in WPRINT_Init()) */ - if (DevSwitch("WinPrint")) return 0; + if (DevSwitch("WinPrint")) + return 0; /* Cursor = wait */ SetCursor(LoadCursor(NULL, IDC_WAIT)); /* copy graph */ temp = CopyGraph(graph); - if (!temp) goto PrintEND; + if (!temp) + goto PrintEND; /* add to the copy the new printer data */ - if (NewViewport(temp)) goto PrintEND2; + if (NewViewport(temp)) + goto PrintEND2; /* make correction to placement of grid (copy from gr_init) */ temp->viewportxoff = temp->fontwidth * 8; @@ -315,7 +325,8 @@ static LRESULT PrintPlot(HWND hwnd) /* initialze printer */ -static LRESULT PrintInit(HWND hwnd) +static LRESULT +PrintInit(HWND hwnd) { /* hand over to printer module */ WPRINT_PrintInit(hwnd); @@ -324,8 +335,8 @@ static LRESULT PrintInit(HWND hwnd) /* window procedure */ -LRESULT CALLBACK PlotWindowProc(HWND hwnd, - UINT uMsg, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK +PlotWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { static int x0, y0, xep, yep; int xe, ye, prevmix; @@ -364,9 +375,9 @@ LRESULT CALLBACK PlotWindowProc(HWND hwnd, goto WIN_DEFAULT; case WM_MOUSEMOVE: + { /* left mouse button: connect coordinate pair by dashed pair of x, y lines */ - if (wParam & MK_LBUTTON) - { + if (wParam & MK_LBUTTON) { hdc = GetDC(hwnd); if (isblack) prevmix = SetROP2(hdc, R2_XORPEN); @@ -429,7 +440,8 @@ LRESULT CALLBACK PlotWindowProc(HWND hwnd, yep = ye; xep = xe; } - goto WIN_DEFAULT; + } + goto WIN_DEFAULT; /* get final coordinates upon left mouse up */ /* calculate and print out the data */ @@ -444,9 +456,9 @@ LRESULT CALLBACK PlotWindowProc(HWND hwnd, /* print it out */ if (xe == x0 && ye == y0) { /* only one location */ fprintf(stdout, "\nx0 = %g, y0 = %g\n", fx0, fy0); - if (gr->grid.gridtype == GRID_POLAR - || gr->grid.gridtype == GRID_SMITH - || gr->grid.gridtype == GRID_SMITHGRID) + if (gr->grid.gridtype == GRID_POLAR || + gr->grid.gridtype == GRID_SMITH || + gr->grid.gridtype == GRID_SMITHGRID) { angle = RAD_TO_DEG * atan2(fy0, fx0); fprintf(stdout, "r0 = %g, a0 = %g\n", @@ -588,7 +600,8 @@ LRESULT CALLBACK PlotWindowProc(HWND hwnd, ******************************************************************************/ -int WIN_NewViewport(GRAPH *graph) +int +WIN_NewViewport(GRAPH *graph) { int i; HWND window; @@ -598,17 +611,19 @@ int WIN_NewViewport(GRAPH *graph) HMENU sysmenu; /* test the parameters */ - if (!graph) return 1; + if (!graph) + return 1; /* initialize if not yet done */ if (WIN_Init() != 0) { externalerror("Can't initialize GDI."); - return(1); + return 1; } /* allocate device dependency info */ wd = calloc(1, sizeof(tWindowData)); - if (!wd) return 1; + if (!wd) + return 1; graph->devdep = wd; @@ -616,7 +631,8 @@ int WIN_NewViewport(GRAPH *graph) i = GetSystemMetrics(SM_CYSCREEN) / 3; window = CreateWindow(WindowName, graph->plotname, WS_OVERLAPPEDWINDOW, 0, 0, WinLineWidth, i * 2 - 22, NULL, NULL, hInst, NULL); - if (!window) return 1; + if (!window) + return 1; /* change the background color of all windows (both new and already plotted) by assessing the registered window class */ @@ -681,7 +697,7 @@ int WIN_NewViewport(GRAPH *graph) WaitForIdle(); /* ready */ - return(0); + return 0; } @@ -692,14 +708,16 @@ to the printer. Therefore WIN_Close is not allowed to do anything, cancelling of the structures occurs at program termination. ******************************************************************************/ -int WIN_Close(void) +int +WIN_Close(void) { - return (0); + return 0; } -/* -static void RealClose(void) +#if 0 +static void +RealClose(void) { // delete window class if (IsRegistered) { @@ -711,17 +729,20 @@ static void RealClose(void) IsRegistered = FALSE; } } -*/ +#endif -int WIN_Clear(void) +int +WIN_Clear(void) { tpWindowData wd; - if (!currentgraph) return 0; + if (!currentgraph) + return 0; wd = pWindowData(currentgraph); - if (!wd) return 0; + if (!wd) + return 0; /* this is done by the window itself */ if (!wd->PaintFlag) /* not necessary with WM_PAINT */ @@ -731,16 +752,19 @@ int WIN_Clear(void) } -int WIN_DrawLine(int x1, int y1, int x2, int y2) +int +WIN_DrawLine(int x1, int y1, int x2, int y2) { tpWindowData wd; HPEN OldPen; HPEN NewPen; - if (!currentgraph) return 0; + if (!currentgraph) + return 0; wd = pWindowData(currentgraph); - if (!wd) return 0; + if (!wd) + return 0; MoveToEx(wd->hDC, x1, wd->Area.bottom - y1, NULL); NewPen = CreatePen(LType(wd->ColorIndex), linewidth, ColorTable[wd->ColorIndex]); @@ -749,11 +773,12 @@ int WIN_DrawLine(int x1, int y1, int x2, int y2) OldPen = SelectObject(wd->hDC, OldPen); DeleteObject(NewPen); - return (0); + return 0; } -int WIN_Arc(int x0, int y0, int radius, double theta, double delta_theta) +int +WIN_Arc(int x0, int y0, int radius, double theta, double delta_theta) /* * Notes: * Draws an arc of and center at (x0,y0) beginning at @@ -771,14 +796,16 @@ int WIN_Arc(int x0, int y0, int radius, double theta, double delta_theta) double dx0; double dy0; - if (!currentgraph) return 0; + if (!currentgraph) + return 0; wd = pWindowData(currentgraph); - if (!wd) return 0; + if (!wd) + return 0; direction = AD_COUNTERCLOCKWISE; if (delta_theta < 0) { - theta = theta + delta_theta; + theta += delta_theta; delta_theta = - delta_theta; direction = AD_CLOCKWISE; } @@ -810,25 +837,29 @@ int WIN_Arc(int x0, int y0, int radius, double theta, double delta_theta) } -/* -int WIN_Text_old(char * text, int x, int y, int degrees) +#if 0 +int +WIN_Text_old(char *text, int x, int y, int degrees) { tpWindowData wd; - if (!currentgraph) return 0; + if (!currentgraph) + return 0; wd = pWindowData(currentgraph); - if (!wd) return 0; + if (!wd) + return 0; SetTextColor(wd->hDC, ColorTable[wd->ColorIndex]); TextOut(wd->hDC, x, wd->Area.bottom - y - currentgraph->fontheight, text, strlen(text)); - return (0); + return 0; } -*/ +#endif -int WIN_Text(char * text, int x, int y) +int +WIN_Text(char *text, int x, int y) { tpWindowData wd; HFONT hfont; @@ -836,10 +867,12 @@ int WIN_Text(char * text, int x, int y) int CentiDegrees = 0; - if (!currentgraph) return 0; + if (!currentgraph) + return 0; wd = pWindowData(currentgraph); - if (!wd) return 0; + if (!wd) + return 0; lf.lfHeight = (int) (1.1 * currentgraph->fontheight); lf.lfWidth = 0; @@ -856,13 +889,11 @@ int WIN_Text(char * text, int x, int y) lf.lfPitchAndFamily = 0; /* set up fonts */ - if (!cp_getvar("wfont", CP_STRING, lf.lfFaceName)) { + if (!cp_getvar("wfont", CP_STRING, lf.lfFaceName)) (void) lstrcpy(lf.lfFaceName, DEF_FONTW); - } - if (!cp_getvar("wfont_size", CP_NUM, &(lf.lfHeight))) { + if (!cp_getvar("wfont_size", CP_NUM, &(lf.lfHeight))) lf.lfHeight = (int) (1.1 * currentgraph->fontheight); - } // lstrcpy (lf.lfFaceName, "Courier"/*"Times New Roman"*/); @@ -874,61 +905,67 @@ int WIN_Text(char * text, int x, int y) DeleteObject(SelectObject(wd->hDC, GetStockObject(SYSTEM_FONT))); - return (0); + return 0; } -int WIN_DefineColor(int colorid, double red, double green, double blue) +int +WIN_DefineColor(int colorid, double red, double green, double blue) { - /* nothing */ NG_IGNORE(colorid); NG_IGNORE(red); NG_IGNORE(green); NG_IGNORE(blue); - return (0); + return 0; } -int WIN_DefineLinestyle(int num, int mask) +int +WIN_DefineLinestyle(int num, int mask) { - /* nothing */ NG_IGNORE(num); NG_IGNORE(mask); - return (0); + return 0; } -int WIN_SetLinestyle(int style) +int +WIN_SetLinestyle(int style) { - /* nothing */ NG_IGNORE(style); - return (0); + return 0; } -int WIN_SetColor(int color) +int +WIN_SetColor(int color) { tpWindowData wd; - if (!currentgraph) return 0; + if (!currentgraph) + return 0; wd = pWindowData(currentgraph); - if (!wd) return 0; + if (!wd) + return 0; wd->ColorIndex = color % NumWinColors; - return (0); + return 0; } -int WIN_Update(void) +int +WIN_Update(void) { tpWindowData wd; - if (!currentgraph) return 0; + if (!currentgraph) + return 0; wd = pWindowData(currentgraph); - if (!wd) return 0; + if (!wd) + return 0; /* After the first run of Update() */ /* FirstFlag again handles WM_PAINT messages. */ @@ -938,15 +975,17 @@ int WIN_Update(void) } -/* -int WIN_DiagramReady(void) +#if 0 +int +WIN_DiagramReady(void) { return 0; } -*/ +#endif -void RemoveWindow(GRAPH* dgraph) +void +RemoveWindow(GRAPH *dgraph) { tpWindowData wd; @@ -961,30 +1000,28 @@ static void WIN_ScreentoData(GRAPH *graph, int x, int y, double *fx, double *fy) { double lmin, lmax; - if (graph->grid.gridtype == GRID_XLOG - || graph->grid.gridtype == GRID_LOGLOG) + if (graph->grid.gridtype == GRID_XLOG || + graph->grid.gridtype == GRID_LOGLOG) { lmin = log10(graph->datawindow.xmin); lmax = log10(graph->datawindow.xmax); - *fx = exp(((x - graph->viewportxoff) - * (lmax - lmin) / graph->viewport.width + lmin) - * M_LN10); + *fx = exp(((x - graph->viewportxoff) * + (lmax - lmin) / graph->viewport.width + lmin) * M_LN10); } else { *fx = (x - graph->viewportxoff) * graph->aspectratiox + graph->datawindow.xmin; } - if (graph->grid.gridtype == GRID_YLOG - || graph->grid.gridtype == GRID_LOGLOG) + if (graph->grid.gridtype == GRID_YLOG || + graph->grid.gridtype == GRID_LOGLOG) { lmin = log10(graph->datawindow.ymin); lmax = log10(graph->datawindow.ymax); - *fy = exp(((graph->absolute.height - y - graph->viewportxoff) - * (lmax - lmin) / graph->viewport.height + lmin) - * M_LN10); + *fy = exp(((graph->absolute.height - y - graph->viewportxoff) * + (lmax - lmin) / graph->viewport.height + lmin) * M_LN10); } else { - *fy = ((graph->absolute.height - y) - graph->viewportyoff) - * graph->aspectratioy + graph->datawindow.ymin; + *fy = ((graph->absolute.height - y) - graph->viewportyoff) * + graph->aspectratioy + graph->datawindow.ymin; } } diff --git a/src/include/ngspice/wstdio.h b/src/include/ngspice/wstdio.h index dfa106786..d5ec52631 100644 --- a/src/include/ngspice/wstdio.h +++ b/src/include/ngspice/wstdio.h @@ -1,6 +1,6 @@ /* I/O Redirection for Spice 3F4 under Win32s - Autor: Wolfgang Muees - Stand: 21.05.95 + * Autor: Wolfgang Muees + * Stand: 21.05.95 */ #ifndef ngspice_WSTDIO_H @@ -100,6 +100,6 @@ int win_x_fputchar(int c); #define ferror win_x_ferror #define fputchar win_x_fputchar -/*----------------------------------------------------------------------------*/ +/* --------------------------------------------------------------------------- */ #endif diff --git a/src/winmain.c b/src/winmain.c index 76550e7cf..3b5f54b4a 100644 --- a/src/winmain.c +++ b/src/winmain.c @@ -102,7 +102,8 @@ extern FILE *flogp; /* definition see xmain.c, stdout redirected to file */ /* -------------------------------------------------------- */ /* Clear history buffer, set pointer to the beginning */ -static void HistoryInit(void) +static void +HistoryInit(void) { int i; HistIndex = 0; @@ -113,21 +114,27 @@ static void HistoryInit(void) /* Delete first line of buffer, all other lines move one down */ -static void HistoryScroll(void) +static void +HistoryScroll(void) { memmove(&(HistBuffer[0]), &(HistBuffer[1]), sizeof(SBufLine) * (HistSize-1)); HistBuffer[HistSize-1][0] = SE; - if (HistIndex) HistIndex--; - if (HistPtr) HistPtr--; + if (HistIndex) + HistIndex--; + if (HistPtr) + HistPtr--; } /* Enter new input line into history buffer */ -static void HistoryEnter(char *newLine) +static void +HistoryEnter(char *newLine) { - if (!newLine || !*newLine) return; + if (!newLine || !*newLine) + return; - if (HistPtr == HistSize) HistoryScroll(); + if (HistPtr == HistSize) + HistoryScroll(); strcpy(HistBuffer[HistPtr], newLine); HistPtr++; @@ -136,18 +143,23 @@ static void HistoryEnter(char *newLine) // Mit dem Index eine Zeile zurueckgehen und den dort stehenden Eintrag zurueckgeben -static char *HistoryGetPrev(void) +static char * +HistoryGetPrev(void) { - if (HistIndex) HistIndex--; + if (HistIndex) + HistIndex--; return &(HistBuffer[HistIndex][0]); } // Mit dem Index eine Zeile vorgehen und den dort stehenden Eintrag zurueckgeben -static char *HistoryGetNext(void) +static char * +HistoryGetNext(void) { - if (HistIndex < HistPtr) HistIndex++; - if (HistIndex == HistPtr) return ""; //HistIndex--; + if (HistIndex < HistPtr) + HistIndex++; + if (HistIndex == HistPtr) + return ""; //HistIndex--; return &(HistBuffer[HistIndex][0]); } @@ -155,7 +167,8 @@ static char *HistoryGetNext(void) // ---------------------------------------------------------- // Warte, bis keine Messages mehr zu bearbeiten sind -void WaitForIdle(void) +void +WaitForIdle(void) { MSG m; // arbeite alle Nachrichten ab @@ -170,7 +183,8 @@ void WaitForIdle(void) // Warte, bis keine Messages mehr zu bearbeiten sind, // dann warte auf neue Message (Input handling ohne Dauerloop) -static void WaitForMessage(void) +static void +WaitForMessage(void) { MSG m; // arbeite alle Nachrichten ab @@ -185,7 +199,8 @@ static void WaitForMessage(void) // ------------------------------------------------------------- // Loeschen des Stringfensters -static void ClearInput(void) +static void +ClearInput(void) { // Darstellen Edit_SetText(swString, ""); @@ -194,7 +209,8 @@ static void ClearInput(void) // -------------------------------------------------------- /* New text to Source file window */ -void SetSource(char *Name) +void +SetSource(char *Name) { if (hwSource) { SetWindowText(hwSource, Name); @@ -210,11 +226,10 @@ void SetSource(char *Name) #define DELTATIME 150 -void SetAnalyse( - char *Analyse, /* in: analysis type */ - int DecaPercent /* in: 10 times the progress [%]*/ - /* HWND hwAnalyse, in: global handle to analysis window */ - ) { +void +SetAnalyse(char *Analyse, /* in: analysis type */ + int DecaPercent) /* in: 10 times the progress [%] */ +{ static int OldPercent = -2; /* Previous progress value */ static char OldAn[128]; /* Previous analysis type */ char s[128], t[128]; /* outputs to analysis window and task bar */ @@ -224,7 +239,8 @@ void SetAnalyse( WaitForIdle(); - if ((DecaPercent == OldPercent) && !strcmp(OldAn, Analyse)) return; + if ((DecaPercent == OldPercent) && !strcmp(OldAn, Analyse)) + return; /* get actual time */ ftime(&timenow); @@ -234,9 +250,8 @@ void SetAnalyse( actual time, progress, to catch linearity of progress of simulation */ if (ft_ngdebug && !strcmp(Analyse, "tran")) - if ((int)((double)DecaPercent/10.) > (int)((double)OldPercent/10.)) { + if ((int)((double)DecaPercent/10.) > (int)((double)OldPercent/10.)) win_x_printf("%3.1f%% percent progress after %4.2f seconds.\n", (double)DecaPercent/10., seconds()); - } OldPercent = DecaPercent; /* output only into hwAnalyse window and if time elapsed is larger than @@ -283,7 +298,8 @@ void SetAnalyse( // Anpassen des Scrollers im Textfenster // Stellt gleichzeitig den Text neu dar -static void AdjustScroller(void) +static void +AdjustScroller(void) { int LineCount; int FirstLine; @@ -292,7 +308,8 @@ static void AdjustScroller(void) FirstLine = Edit_GetFirstVisibleLine(twText); MyFirstLine = LineCount - VisibleRows; - if (MyFirstLine < 0 ) MyFirstLine = 0; + if (MyFirstLine < 0 ) + MyFirstLine = 0; Edit_Scroll(twText, MyFirstLine - FirstLine, 0); // Das wars @@ -301,7 +318,8 @@ static void AdjustScroller(void) // Loeschen einer Zeile im Textbuffer -static void _DeleteFirstLine(void) +static void +_DeleteFirstLine(void) { char *cp = strchr(TBuffer, LF); if (!cp) { @@ -318,7 +336,8 @@ static void _DeleteFirstLine(void) // Anfuegen eines chars an den TextBuffer -static void AppendChar(char c) +static void +AppendChar(char c) { // Textbuffer nicht zu grosz werden lassen while ((TBufEnd + 4) >= TBufSize) @@ -334,10 +353,12 @@ static void AppendChar(char c) // Anfuegen eines Strings an den TextBuffer -static void AppendString(const char *Line) +static void +AppendString(const char *Line) { size_t i; - if (!Line) return; + if (!Line) + return; // Zeilenlaenge bestimmen i = strlen(Line); @@ -352,7 +373,8 @@ static void AppendString(const char *Line) // Text neu darstellen -static void DisplayText(void) +static void +DisplayText(void) { // Darstellen Edit_SetText(twText, TBuffer); @@ -361,11 +383,13 @@ static void DisplayText(void) } -/* // Anfuegen einer Zeile an den Textbuffer -void AppendLine(const char *Line) +#if 0 +void +AppendLine(const char *Line) { - if (!Line) return; + if (!Line) + return; // String anhaengen AppendString(Line); @@ -373,13 +397,14 @@ void AppendLine(const char *Line) // CRLF anhaengen AppendString(CRLF); } -*/ +#endif // ------------------------------------------------------------------- // Lese ein Zeichen ein -static int w_getch(void) +static int +w_getch(void) { int c; @@ -412,7 +437,8 @@ static int w_getch(void) // Gebe ein Zeichen aus -static int w_putch(int c) +static int +w_putch(int c) { if (c) AppendChar((char) c); @@ -423,7 +449,8 @@ static int w_putch(int c) /* --------------------------------------------------------- */ /* Main window changes size */ -static void Main_OnSize(HWND hwnd, UINT state, int cx, int cy) +static void +Main_OnSize(HWND hwnd, UINT state, int cx, int cy) { int h = cy - LineHeight - StatusHeight; @@ -441,15 +468,18 @@ static void Main_OnSize(HWND hwnd, UINT state, int cx, int cy) /* Expand Status Elements */ h = cy - LineHeight + StatusFrame - 1; MoveWindow(hwSource, StatusFrame, h, SourceLength, StatusElHeight, TRUE); - MoveWindow(hwAnalyse, cx - 3 * StatusFrame - QuitButtonLength - AnalyseLength - 20, + MoveWindow(hwAnalyse, + cx - 3 * StatusFrame - QuitButtonLength - AnalyseLength - 20, h, AnalyseLength, StatusElHeight, TRUE); - MoveWindow(hwQuitButton, cx - StatusFrame - QuitButtonLength - 20, + MoveWindow(hwQuitButton, + cx - StatusFrame - QuitButtonLength - 20, h, QuitButtonLength, StatusElHeight, TRUE); } /* Write a command into the command buffer */ -static void PostSpiceCommand(const char *const cmd) +static void +PostSpiceCommand(const char * const cmd) { strcpy(SBuffer, cmd); strcat(SBuffer, CRLF); @@ -457,20 +487,22 @@ static void PostSpiceCommand(const char *const cmd) /* Main Window procedure */ -static LRESULT CALLBACK MainWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +static LRESULT CALLBACK +MainWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { /* command issued by pushing the "Quit" button */ case WM_COMMAND: if (HIWORD(wParam) == BN_CLICKED) - if (ft_batchmode && (MessageBox(NULL, "Do you want to quit ngspice?", "Quit", MB_OKCANCEL|MB_ICONERROR) - == IDCANCEL)) goto DEFAULT_AFTER; - if (LOWORD(wParam) == QUIT_BUTTON_ID) { + if (ft_batchmode && + (MessageBox(NULL, "Do you want to quit ngspice?", "Quit", MB_OKCANCEL | MB_ICONERROR) == IDCANCEL)) + goto DEFAULT_AFTER; + if (LOWORD(wParam) == QUIT_BUTTON_ID) SendMessage(GetParent((HWND)lParam), WM_CLOSE, 0, 0); - } /* write all achieved so far to log file */ - if (flogp) win_x_fflush(flogp); + if (flogp) + win_x_fflush(flogp); goto DEFAULT_AFTER; case WM_CLOSE: @@ -493,7 +525,8 @@ static LRESULT CALLBACK MainWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPAR /* Procedure for string window */ -static LRESULT CALLBACK StringWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +static LRESULT CALLBACK +StringWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { char c; UINT i; @@ -504,7 +537,7 @@ static LRESULT CALLBACK StringWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP i = (UINT) wParam; if ((i == VK_UP) || (i == VK_DOWN)) { /* Set old text to new */ - SetWindowText(hwnd, i == VK_UP ? HistoryGetPrev() : HistoryGetNext()); + SetWindowText(hwnd, (i == VK_UP) ? HistoryGetPrev() : HistoryGetNext()); /* Put cursor to end of line */ CallWindowProc(swProc, hwnd, uMsg, (WPARAM) VK_END, lParam); return 0; @@ -547,7 +580,8 @@ static LRESULT CALLBACK StringWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP /* Procedure for text window */ -static LRESULT CALLBACK TextWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +static LRESULT CALLBACK +TextWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { unsigned char c; UINT i; @@ -582,7 +616,8 @@ static LRESULT CALLBACK TextWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPAR } -static void Element_OnPaint(HWND hwnd) +static void +Element_OnPaint(HWND hwnd) { PAINTSTRUCT ps; RECT r; @@ -634,7 +669,8 @@ static void Element_OnPaint(HWND hwnd) /* Procedure for element window */ -static LRESULT CALLBACK ElementWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +static LRESULT CALLBACK +ElementWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { @@ -667,15 +703,16 @@ static LRESULT CALLBACK ElementWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, L -1 on failure */ -static int MakeArgcArgv(char *cmdline, int *argc, char ***argv) +static int +MakeArgcArgv(char *cmdline, int *argc, char ***argv) { char *pC1; /* a temporary character pointer */ char *pWorkString = NULL; /* a working copy of cmdline */ int i; /* a loop counter */ int quoteflag = 0; /* for the finite state machine parsing cmdline */ bool firstspace = TRUE; /* count only the first space */ - int numargs = 1; /* the number of command line arguments, later - copied to *argc */ + int numargs = 1; /* the number of command line arguments, + later copied to *argc */ char **tmpargv; /* the temporary argv, later copied to *argv */ int status = ERROR_SUCCESS; /* status */ char buffer[MAX_PATH + 1]; @@ -683,8 +720,7 @@ static int MakeArgcArgv(char *cmdline, int *argc, char ***argv) /* make sure we aren't dealing with any NULL pointers */ - if ((NULL == argc) - || (NULL == argv)) + if ((NULL == argc) || (NULL == argv)) { status = -1; goto outahere; @@ -726,14 +762,13 @@ static int MakeArgcArgv(char *cmdline, int *argc, char ***argv) and I couldn't tell what delimiter that I had bumped against */ for (i = 0; i < (signed)strlen(pWorkString); i++) - { switch (pWorkString[i]) { case SPACE: - if (!quoteflag) - { + if (!quoteflag) { pWorkString[i] = DELIMITER; /* change space to delimiter */ - if (firstspace) numargs++; /* count only the first space */ + if (firstspace) /* count only the first space */ + numargs++; firstspace = FALSE; } break; @@ -744,7 +779,6 @@ static int MakeArgcArgv(char *cmdline, int *argc, char ***argv) firstspace = TRUE; break; } - } /* Now, we should have ctrl-Zs everywhere that there used to be a space not protected by @@ -774,13 +808,14 @@ static int MakeArgcArgv(char *cmdline, int *argc, char ***argv) pC1 = NULL; /* Now actually strdup all the arguments out of the string and store them in the argv */ - for (i = 1; i < numargs; i++) - { + for (i = 1; i < numargs; i++) { if (NULL == pC1) pC1 = pWorkString; - if (i == 1) tmpargv[i] = copy(strtok(pC1, deli)); - else tmpargv[i] = copy(strtok(NULL, deli)); + if (i == 1) + tmpargv[i] = copy(strtok(pC1, deli)); + else + tmpargv[i] = copy(strtok(NULL, deli)); } /* copy the working values over to the arguments */ @@ -792,14 +827,14 @@ static int MakeArgcArgv(char *cmdline, int *argc, char ***argv) if (pWorkString) free(pWorkString); - /* return status */ return status; } /* Main entry point for our Windows application */ -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) +int WINAPI +WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) { int ix, iy; /* width and height of screen */ int iyt; /* height of screen divided by 3 */ @@ -834,10 +869,12 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi hwMainClass.lpszMenuName = NULL; hwMainClass.lpszClassName = hwClassName; - if (!RegisterClass(&hwMainClass)) goto THE_END; + if (!RegisterClass(&hwMainClass)) + goto THE_END; /* Define text window class */ - if (!GetClassInfo(NULL, "EDIT", &twTextClass)) goto THE_END; + if (!GetClassInfo(NULL, "EDIT", &twTextClass)) + goto THE_END; twProc = twTextClass.lpfnWndProc; twTextClass.lpfnWndProc = TextWindowProc; @@ -845,10 +882,12 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi twTextClass.lpszMenuName = NULL; twTextClass.lpszClassName = twClassName; - if (!RegisterClass(&twTextClass)) goto THE_END; + if (!RegisterClass(&twTextClass)) + goto THE_END; /* Define string window class */ - if (!GetClassInfo(NULL, "EDIT", &swStringClass)) goto THE_END; + if (!GetClassInfo(NULL, "EDIT", &swStringClass)) + goto THE_END; swProc = swStringClass.lpfnWndProc; swStringClass.lpfnWndProc = StringWindowProc; @@ -856,7 +895,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi swStringClass.lpszMenuName = NULL; swStringClass.lpszClassName = swClassName; - if (!RegisterClass(&swStringClass)) goto THE_END; + if (!RegisterClass(&swStringClass)) + goto THE_END; /* Define status element class */ hwElementClass.style = CS_HREDRAW | CS_VREDRAW; @@ -870,7 +910,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi hwElementClass.lpszMenuName = NULL; hwElementClass.lpszClassName = hwElementClassName; - if (!RegisterClass(&hwElementClass)) goto THE_END; + if (!RegisterClass(&hwElementClass)) + goto THE_END; /*Create main window */ SystemParametersInfo(SPI_GETWORKAREA, 0, &wsize, 0); @@ -882,13 +923,15 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi // ix = GetSystemMetrics(SM_CXSCREEN); hwMain = CreateWindow(hwClassName, hwWindowName, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, 0, iyt * 2, ix, iyt, NULL, NULL, hInst, NULL); - if (!hwMain) goto THE_END; + if (!hwMain) + goto THE_END; /* Create text window */ twText = CreateWindowEx(WS_EX_NOPARENTNOTIFY, twClassName, twWindowName, ES_LEFT | ES_MULTILINE | ES_READONLY | WS_CHILD | WS_BORDER | WS_VSCROLL, 20, 20, 300, 100, hwMain, NULL, hInst, NULL); - if (!twText) goto THE_END; + if (!twText) + goto THE_END; /* Ansii fixed font */ { @@ -910,8 +953,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi /* Create string window */ swString = CreateWindowEx(WS_EX_NOPARENTNOTIFY, swClassName, swWindowName, - ES_LEFT | WS_CHILD | WS_BORDER, 20,20,300,100, hwMain, NULL, hInst, NULL); - if (!swString) goto THE_END; + ES_LEFT | WS_CHILD | WS_BORDER, + 20, 20, 300, 100, hwMain, NULL, hInst, NULL); + if (!swString) + goto THE_END; { HDC stringDC; @@ -925,24 +970,26 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi } /* Create source window */ - hwSource = CreateWindowEx(WS_EX_NOPARENTNOTIFY, hwElementClassName, - hwSourceWindowName, WS_CHILD, 0,0, SourceLength, StatusElHeight, hwMain, - NULL, hInst, NULL); - if (!hwSource) goto THE_END; + hwSource = CreateWindowEx(WS_EX_NOPARENTNOTIFY, hwElementClassName, hwSourceWindowName, + WS_CHILD, + 0, 0, SourceLength, StatusElHeight, hwMain, NULL, hInst, NULL); + if (!hwSource) + goto THE_END; /* Create analysis window */ - hwAnalyse = CreateWindowEx(WS_EX_NOPARENTNOTIFY, hwElementClassName, - hwAnalyseWindowName, WS_CHILD, 0,0, AnalyseLength, StatusElHeight, hwMain, - NULL, hInst, NULL); - if (!hwAnalyse) goto THE_END; + hwAnalyse = CreateWindowEx(WS_EX_NOPARENTNOTIFY, hwElementClassName, hwAnalyseWindowName, + WS_CHILD, + 0, 0, AnalyseLength, StatusElHeight, hwMain, NULL, hInst, NULL); + if (!hwAnalyse) + goto THE_END; /* Create "Quit" button */ - hwQuitButton = CreateWindow("BUTTON", "Quit", WS_CHILD | - BS_PUSHBUTTON, 0, 0, QuitButtonLength, + hwQuitButton = CreateWindow("BUTTON", "Quit", WS_CHILD | BS_PUSHBUTTON, 0, 0, QuitButtonLength, StatusElHeight, hwMain, (HMENU)(UINT_PTR)QUIT_BUTTON_ID, hInst, NULL); - if (!hwQuitButton) goto THE_END; + if (!hwQuitButton) + goto THE_END; /* Make main window and subwindows visible. Size of windows allows display of 80 character line. @@ -986,7 +1033,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi Man schaue also nach, bevor man eine Funktion benutzt! */ -int win_x_fflush(FILE *stream) +int +win_x_fflush(FILE *stream) { if (((stream == stdout) && !flogp) || (stream == stderr)) return 0; @@ -995,20 +1043,22 @@ int win_x_fflush(FILE *stream) } -int win_x_fgetc(FILE *stream) +int +win_x_fgetc(FILE *stream) { if (stream == stdin) { int c; - do { + do c = w_getch(); - } while (c == CR); + while (c == CR); return c; } else return fgetc(stream); } -int win_x_fgetpos(FILE *stream, fpos_t *pos) +int +win_x_fgetpos(FILE *stream, fpos_t *pos) { int result; if ((stream == stdin) || ((stream == stdout) && !flogp) || (stream == stderr)) { @@ -1020,7 +1070,8 @@ int win_x_fgetpos(FILE *stream, fpos_t *pos) } -char *win_x_fgets(char *s, int n, FILE *stream) +char * +win_x_fgets(char *s, int n, FILE *stream) { if (stream == stdin) { int i = 0; @@ -1041,7 +1092,8 @@ char *win_x_fgets(char *s, int n, FILE *stream) } -int win_x_fputc(int c, FILE *stream) +int +win_x_fputc(int c, FILE *stream) { if (!flogp && ((stream == stdout) || (stream == stderr))) { if (c == LF) @@ -1055,13 +1107,15 @@ int win_x_fputc(int c, FILE *stream) } -int win_x_fputs(const char *s, FILE *stream) +int +win_x_fputs(const char *s, FILE *stream) { // if (((stream == stdout) && !flogp) || (stream == stderr)) { hvogt 14.6.2000 if ((stream == stdout) || (stream == stderr)) { int c = SE; - if (!s) return EOF; + if (!s) + return EOF; for (;;) { if (*s) { c = *s++; @@ -1074,7 +1128,8 @@ int win_x_fputs(const char *s, FILE *stream) } -int win_x_fprintf(FILE *stream, const char *format, ...) +int +win_x_fprintf(FILE *stream, const char *format, ...) { int result; char s[IOBufSize]; @@ -1096,7 +1151,8 @@ int win_x_fprintf(FILE *stream, const char *format, ...) } -int win_x_fclose(FILE *stream) +int +win_x_fclose(FILE *stream) { if ((stream == stdin) || ((stream == stdout) && !flogp) || (stream == stderr)) { assert(FALSE); @@ -1106,7 +1162,8 @@ int win_x_fclose(FILE *stream) } -size_t win_x_fread(void *ptr, size_t size, size_t n, FILE *stream) +size_t +win_x_fread(void *ptr, size_t size, size_t n, FILE *stream) { // if ((stream == stdin) || ((stream == stdout) && !flogp) || (stream == stderr)) { if (((stream == stdout) && !flogp) || (stream == stderr)) { @@ -1136,7 +1193,8 @@ size_t win_x_fread(void *ptr, size_t size, size_t n, FILE *stream) } -FILE *win_x_freopen(const char *path, const char *mode, FILE *stream) +FILE * +win_x_freopen(const char *path, const char *mode, FILE *stream) { if ((stream == stdin)/* || ((stream == stdout) && !flogp) || (stream == stderr)*/) { assert(FALSE); @@ -1146,7 +1204,8 @@ FILE *win_x_freopen(const char *path, const char *mode, FILE *stream) } -int win_x_fscanf(FILE *stream, const char *format, ...) +int +win_x_fscanf(FILE *stream, const char *format, ...) { int result; va_list args; @@ -1162,7 +1221,8 @@ int win_x_fscanf(FILE *stream, const char *format, ...) } -int win_x_fseek(FILE *stream, long offset, int whence) +int +win_x_fseek(FILE *stream, long offset, int whence) { if ((stream == stdin) || ((stream == stdout) && !flogp) || (stream == stderr)) { assert(FALSE); @@ -1172,7 +1232,8 @@ int win_x_fseek(FILE *stream, long offset, int whence) } -int win_x_fsetpos(FILE *stream, const fpos_t *pos) +int +win_x_fsetpos(FILE *stream, const fpos_t *pos) { if ((stream == stdin) || ((stream == stdout) && !flogp) || (stream == stderr)) { assert(FALSE); @@ -1182,7 +1243,8 @@ int win_x_fsetpos(FILE *stream, const fpos_t *pos) } -long win_x_ftell(FILE *stream) +long +win_x_ftell(FILE *stream) { if ((stream == stdin) || ((stream == stdout) && !flogp) || (stream == stderr)) { assert(FALSE); @@ -1192,7 +1254,8 @@ long win_x_ftell(FILE *stream) } -size_t win_x_fwrite(const void *ptr, size_t size, size_t n, FILE *stream) +size_t +win_x_fwrite(const void *ptr, size_t size, size_t n, FILE *stream) { // win_x_printf("entered fwrite, size %d, n %d \n", size, n); if (stream == stdin) { @@ -1208,7 +1271,8 @@ size_t win_x_fwrite(const void *ptr, size_t size, size_t n, FILE *stream) // win_x_printf("test1 %s\n", s); - if (!s) return 0 /* EOF */; + if (!s) + return 0 /* EOF */; for (i = 0; i < (size * n); i++) { if (*s) { @@ -1226,13 +1290,15 @@ size_t win_x_fwrite(const void *ptr, size_t size, size_t n, FILE *stream) } -char *win_x_gets(char *s) +char * +win_x_gets(char *s) { return win_x_fgets(s, 10000, stdin); } -void win_x_perror(const char *s) +void +win_x_perror(const char *s) { const char *cp; // char s[IOBufSize]; @@ -1244,7 +1310,8 @@ void win_x_perror(const char *s) } -int win_x_printf(const char *format, ...) +int +win_x_printf(const char *format, ...) { int result; char s[IOBufSize]; @@ -1260,13 +1327,15 @@ int win_x_printf(const char *format, ...) } -int win_x_puts(const char *s) +int +win_x_puts(const char *s) { return win_x_fputs(s, stdout); } -int win_x_scanf(const char *format, ...) +int +win_x_scanf(const char *format, ...) { NG_IGNORE(format); assert(FALSE); @@ -1274,7 +1343,8 @@ int win_x_scanf(const char *format, ...) } -int win_x_ungetc(int c, FILE *stream) +int +win_x_ungetc(int c, FILE *stream) { NG_IGNORE(c); NG_IGNORE(stream); @@ -1283,7 +1353,8 @@ int win_x_ungetc(int c, FILE *stream) } -int win_x_vfprintf(FILE *stream, const char *format, void *arglist) +int +win_x_vfprintf(FILE *stream, const char *format, void *arglist) { int result; char s[IOBufSize]; @@ -1300,7 +1371,9 @@ int win_x_vfprintf(FILE *stream, const char *format, void *arglist) } -/*int win_x_vfscanf(FILE *stream, const char *format, void *arglist) +#if 0 +int +win_x_vfscanf(FILE *stream, const char *format, void *arglist) { if (stream == stdin) { assert(FALSE); @@ -1308,10 +1381,11 @@ int win_x_vfprintf(FILE *stream, const char *format, void *arglist) } return vfscanf(stream, format, arglist); } -*/ +#endif -int win_x_vprintf(const char *format, void *arglist) +int +win_x_vprintf(const char *format, void *arglist) { int result; char s[IOBufSize]; @@ -1323,14 +1397,18 @@ int win_x_vprintf(const char *format, void *arglist) } -/*int win_x_vscanf(const char *format, void *arglist) +#if 0 +int +win_x_vscanf(const char *format, void *arglist) { assert(FALSE); return FALSE; -} */ +} +#endif -int win_x_read(int fd, char *buf, int n) +int +win_x_read(int fd, char *buf, int n) { if (fd == 0) { int i = 0; @@ -1347,7 +1425,7 @@ int win_x_read(int fd, char *buf, int n) } // s[i] = SE; buf = &s[0]; - return (i); + return i; } else { return _read(fd, buf, n); @@ -1355,31 +1433,36 @@ int win_x_read(int fd, char *buf, int n) } -int win_x_getc(FILE *fp) +int +win_x_getc(FILE *fp) { return win_x_fgetc(fp); } -int win_x_getchar(void) +int +win_x_getchar(void) { return win_x_fgetc(stdin); } -int win_x_putchar(const int c) +int +win_x_putchar(const int c) { return win_x_fputc(c, stdout); } -int win_x_putc(const int c, FILE *fp) +int +win_x_putc(const int c, FILE *fp) { return win_x_fputc(c, fp); } -int win_x_feof(FILE *fp) +int +win_x_feof(FILE *fp) { if ((fp == stdin) || (fp == stdout) || (fp == stderr)) { assert(FALSE); @@ -1389,7 +1472,8 @@ int win_x_feof(FILE *fp) } -int win_x_ferror(FILE *fp) +int +win_x_ferror(FILE *fp) { if ((fp == stdin) || (fp == stdout) || (fp == stderr)) { assert(FALSE); @@ -1399,7 +1483,8 @@ int win_x_ferror(FILE *fp) } -int win_x_fputchar(int c) +int +win_x_fputchar(int c) { return win_x_fputc(c, stdout); } @@ -1407,8 +1492,9 @@ int win_x_fputchar(int c) // ------------------------------------------------------ -/* -size_t _memavl(void) +#if 0 +size_t +_memavl(void) { MEMORYSTATUS ms; DWORD sum; @@ -1417,12 +1503,15 @@ size_t _memavl(void) sum = ms.dwAvailPhys + ms.dwAvailPageFile; return (size_t) sum; } +#endif // -------------------------------------------- +#if 0 #ifndef _MSC_VER -int system(const char *command) +int +system(const char *command) { // info-Bloecke STARTUPINFO si; @@ -1446,28 +1535,33 @@ int system(const char *command) NULL, // address of current directory name &si, // address of STARTUPINFO &pi // address of PROCESS_INFORMATION - )) return -1; + )) + return -1; // dieses Handle musz da sein - if (!pi.hProcess) return -1; + if (!pi.hProcess) + return -1; do { // Multitasking ermoeglichen WaitForIdle(); // hole mir den Exit-Code des Prozesses - if (!GetExitCodeProcess(pi.hProcess, &ExitStatus)) return -1; + if (!GetExitCodeProcess(pi.hProcess, &ExitStatus)) + return -1; // solange er existiert } while (ExitStatus == STILL_ACTIVE); // Handles freigeben - if (pi.hThread) CloseHandle(pi.hThread); - if (pi.hProcess) CloseHandle(pi.hProcess); + if (pi.hThread) + CloseHandle(pi.hThread); + if (pi.hProcess) + CloseHandle(pi.hProcess); // fertig return 0; } // system Windows95 #endif -*/ +#endif #ifdef __CYGWIN__ @@ -1499,7 +1593,8 @@ rlead(char *s) #endif -void winmessage(char *new_msg) +void +winmessage(char *new_msg) { /* open a message box only if message is not written into -o xxx.log */ if (!flogp)