Add a "Config *" argument to term_init(), and use that instead of the global
[u/mdw/putty] / window.c
index e97fc94..4bfec69 100644 (file)
--- a/window.c
+++ b/window.c
@@ -115,10 +115,16 @@ static time_t last_movement = 0;
 
 static int caret_x = -1, caret_y = -1;
 
+static int kbd_codepage;
+
 static void *ldisc;
 static Backend *back;
 static void *backhandle;
 
+static int session_closed;
+
+extern struct sesslist sesslist;       /* imported from windlg.c */
+
 #define FONT_NORMAL 0
 #define FONT_BOLD 1
 #define FONT_UNDERLINE 2
@@ -400,6 +406,8 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
                        cfg.host[sizeof(cfg.host) - 1] = '\0';
                        got_host = 1;
                    }
+               } else {
+                   cmdline_error("unknown option \"%s\"", p);
                }
            }
        }
@@ -498,7 +506,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
 
     hwnd = NULL;
 
-    term = term_init(NULL);
+    term = term_init(&cfg, NULL);
     logctx = log_init(NULL);
     term_provide_logctx(term, logctx);
 
@@ -683,10 +691,12 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
        AppendMenu(m, MF_ENABLED, IDM_NEWSESS, "Ne&w Session...");
        AppendMenu(m, MF_ENABLED, IDM_DUPSESS, "&Duplicate Session");
        s = CreateMenu();
-       get_sesslist(TRUE);
-       for (i = 1; i < ((nsessions < 256) ? nsessions : 256); i++)
+       get_sesslist(&sesslist, TRUE);
+       for (i = 1;
+            i < ((sesslist.nsessions < 256) ? sesslist.nsessions : 256);
+            i++)
            AppendMenu(s, MF_ENABLED, IDM_SAVED_MIN + (16 * i),
-                      sessions[i]);
+                      sesslist.sessions[i]);
        AppendMenu(m, MF_POPUP | MF_ENABLED, (UINT) s, "Sa&ved Sessions");
        AppendMenu(m, MF_ENABLED, IDM_RECONF, "Chan&ge Settings...");
        AppendMenu(m, MF_SEPARATOR, 0, 0);
@@ -1692,9 +1702,9 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
                    sprintf(c, "putty &%p", filemap);
                    cl = c;
                } else if (wParam == IDM_SAVEDSESS) {
-                   if ((lParam - IDM_SAVED_MIN) / 16 < nsessions) {
+                   if ((lParam - IDM_SAVED_MIN) / 16 < sesslist.nsessions) {
                        char *session =
-                           sessions[(lParam - IDM_SAVED_MIN) / 16];
+                           sesslist.sessions[(lParam - IDM_SAVED_MIN) / 16];
                        cl = smalloc(16 + strlen(session));
                                       /* 8, but play safe */
                        if (!cl)
@@ -2989,7 +2999,7 @@ void do_cursor(Context ctx, int x, int y, char *text, int len,
 
 /* This function gets the actual width of a character in the normal font.
  */
-int CharWidth(Context ctx, int uc) {
+int char_width(Context ctx, int uc) {
     HDC hdc = ctx;
     int ibuf = 0;