Skip to content

Instantly share code, notes, and snippets.

@southly
Created May 21, 2010 12:28
Show Gist options
  • Save southly/408773 to your computer and use it in GitHub Desktop.
Save southly/408773 to your computer and use it in GitHub Desktop.
#xyzzy multiframeパッチの追いかけ
From 7d9adc1ca6a0b47af576fcf2b4d1202a354abc51 Mon Sep 17 00:00:00 2001
From: NANRI <[email protected]>
Date: Fri, 21 May 2010 03:43:49 +0900
Subject: [PATCH] multiframe : import.
commit fa46e91f2eae2ed302a93f2720a891bea3b91623
Author: mumurik <devnull@localhost>
Date: Fri May 28 14:35:01 2010 +0900
remove most of active_app_frame at disp.cc.
commit 2f994f833a3e9ad87625496086ae27d68fa62c90
Author: mumurik <devnull@localhost>
Date: Thu May 27 15:15:44 2010 +0900
tmp check-in. this version is also unstable. give up this fix now.
commit be45adda107c971a1ad77f82e3224bd46891ba73
Author: mumurik <devnull@localhost>
Date: Sun May 23 20:34:54 2010 +0900
temporary comment out SetFocus.
commit 4d6b780b0ad1bd11888ffcc28b30bb3e995cfd89
Author: mumurik <devnull@localhost>
Date: Sat May 22 22:06:38 2010 +0900
argument of make-frame is optional and make-frame is interactive.
commit a87e9a71c5e853c246f77b6da95f88614f3e4772
Author: mumurik <devnull@localhost>
Date: Thu May 20 23:10:58 2010 +0900
fix: open-filer cause crash.
commit 8b74111f0429d84ffc95de18b2ad103128693f96
Author: mumurik <devnull@localhost>
Date: Wed May 19 17:37:09 2010 +0900
FIX: crash when frame kill some buffer that is also opened in another frame and activate that frame.
commit 15a5c6b6c0efbc5ebf1e68f685826b717f4d545a
Author: mumurik <devnull@localhost>
Date: Mon May 17 10:57:48 2010 +0900
FIX: switch-buffer history do not updated.
Avoid dlist_add_head call if appframe is not active at refresh_screen.
commit c36fea140aea152273938f6f4e05d4d79d043d23
Author: mumurik <devnull@localhost>
Date: Sun May 16 16:48:41 2010 +0900
modify refresh to support multiple app frame.
commit 403b13452328b1a618d11aaa869982634d45c0af
Author: mumurik <devnull@localhost>
Date: Fri May 7 20:25:07 2010 +0900
remove most of active_app_frame inside toplev.cc.
remove active_app_frame for WM_SETFOCUS and WM_ACTIVATE related codes.
commit 08c817fb7321409044eb95673209f2395f1936dd
Author: mumurik <devnull@localhost>
Date: Fri Apr 23 10:05:23 2010 +0900
FIX: changing focus of frame during async grep dialog cause crash (not yet fixed tottaly, though).
adjust_insertion should notify to all window, but only notify to active frame's window.
MOD: Window has owner frame reference and use it as far as possible.
buffer-bar should have app_frame (might be inside dock frame) too, but not yet modified.
commit 74da760858cb5d3e643740deb45dd5fd72e52fcc
Author: mumurik <devnull@localhost>
Date: Sat Apr 10 07:27:55 2010 +0900
FIX: forgot to mark background frame's windows.
FIX: g_frame should have been app_frame local.
MOD: move dump_image from app_frame to app.
IMP: call startup-frame when frame opened. hook is run muliple times...
commit 2ef1006f2e76a6d1c02a10e062bba8bb088d5994
Author: mumurik <devnull@localhost>
Date: Fri Apr 9 23:10:33 2010 +0900
Original version of builtin.l
commit ff4249c241853ac54fc4118b8151bb728c075b55
Author: mumurik <devnull@localhost>
Date: Fri Apr 9 23:09:21 2010 +0900
Original version of estartup.l
commit bc95de0b55ec6e2e30eff2e5a88ab1d48a2d5af6
Author: mumurik <devnull@localhost>
Date: Fri Apr 2 19:22:54 2010 +0900
Basic implementation of multiframe finished. Very unstable.
commit 8a836bf0e89d4b00010da207588bf6e3e6c8d8f1
Author: mumurik <devnull@localhost>
Date: Fri Apr 2 11:00:31 2010 +0900
temp check-in. before separate Application and ApplicationFrame.
Currently, Application should place to static, but place to heap.
So GC does not work collect. (should not new Application()).
---
lisp/builtin.l | 1 +
lisp/estartup.l | 32 ++
lisp/fstartup.l | 19 ++
src/Buffer.cc | 45 ++--
src/ChooseFont.cc | 4 +-
src/ColorDialog.cc | 16 +-
src/DnD.cc | 80 +++---
src/Makefile | 1 +
src/Window.cc | 462 ++++++++++++++++---------------
src/Window.h | 43 ++--
src/archiver.cc | 8 +-
src/binfo.cc | 2 +-
src/buffer-bar.cc | 12 +-
src/colors.cc | 2 +-
src/conf.cc | 20 +-
src/data.cc | 44 ++--
src/dataP.h | 1 +
src/dialogs.cc | 28 +-
src/disp.cc | 488 ++++++++++++++++----------------
src/dockbar.cc | 20 +-
src/dockbar.h | 2 +-
src/ed.h | 104 ++++++--
src/environ.cc | 2 +-
src/except.cc | 2 +-
src/fileio.cc | 7 +-
src/filer.cc | 34 ++--
src/fnkey.cc | 8 +-
src/fns.h | 13 +-
src/frame.cc | 196 +++++++++++++
src/gen-msg.cc | 2 +-
src/gen-syms.cc | 5 +
src/init.cc | 171 +++++++-----
src/insdel.cc | 37 ++--
src/kbd.cc | 135 +++++----
src/kbd.h | 1 +
src/ldialog.cc | 20 +-
src/lisp.h | 1 +
src/listen.cc | 6 +-
src/lprint.cc | 19 +-
src/lread.cc | 4 +-
src/mainframe.h | 4 +-
src/menu.cc | 8 +-
src/mouse.cc | 24 +-
src/move.cc | 6 +-
src/msgbox.cc | 4 +-
src/oledata.cc | 2 +-
src/pane.cc | 6 +-
src/popup.cc | 6 +-
src/popupl.cc | 16 +-
src/pred.cc | 3 +
src/preview.cc | 12 +-
src/print.cc | 14 +-
src/printdlg.cc | 8 +-
src/process.cc | 24 +-
src/resolver.cc | 4 +-
src/statarea.cc | 2 +-
src/stream.cc | 16 +-
src/string.cc | 10 +-
src/syntax.cc | 10 +-
src/thread.cc | 2 +-
src/toplev.cc | 796 ++++++++++++++++++++++++++++------------------------
src/usertab.cc | 12 +-
src/usertool.cc | 34 ++--
src/utils.cc | 2 +-
src/utimer.cc | 4 +-
src/vfs.cc | 2 +-
src/wheel.cc | 12 +-
src/winhelp.cc | 8 +-
68 files changed, 1819 insertions(+), 1329 deletions(-)
create mode 100644 lisp/fstartup.l
create mode 100644 src/frame.cc
diff --git a/lisp/builtin.l b/lisp/builtin.l
index cebd53f..d9e14b4 100644
--- a/lisp/builtin.l
+++ b/lisp/builtin.l
@@ -636,6 +636,7 @@
(si::defun-builtin buffer-size (&optional buffer))
(si::defun-builtin buffer-lines (&optional buffer))
(si::defun-builtin create-new-buffer (name))
+(si::defun-builtin make-frame (name))
(si::defun-builtin selected-buffer ())
(si::defun-builtin deleted-buffer-p (buffer))
(si::defun-builtin get-next-buffer (&optional buffer reverse tab-order internal))
diff --git a/lisp/estartup.l b/lisp/estartup.l
index 67d6029..fe39d8a 100644
--- a/lisp/estartup.l
+++ b/lisp/estartup.l
@@ -164,3 +164,35 @@
(funcall *initial-buffer-mode*)))))
(trap-errors (process-command-line))
(trap-errors (run-hooks '*post-startup-hook*))))
+
+(defun startup-frame ()
+; (trap-errors (init-misc-objects))
+ (trap-errors (init-pseudo-frame))
+ (trap-errors (run-hooks '*pre-startup-hook*))
+ (let (no-init-file
+ (cl (car si:*command-line-args*)))
+; (when (or (equal cl "-q")
+; (equal cl "-no-init-file"))
+; (setq no-init-file t)
+; (pop si:*command-line-args*))
+; (when *convert-registry-to-file-p*
+; (ignore-errors (load-history-file-compat)))
+; (unless no-init-file
+; (trap-errors
+; (let ((*loading-user-initial-file* t))
+; (load (namestring (if (file-system-supports-long-file-name-p "~/")
+; "~/.xyzzy" "~/_xyzzy"))
+; :if-does-not-exist nil :verbose nil :print nil)))
+; (unless *inhibit-history-load*
+; (ignore-errors (load-history-file))))
+; (ignore-errors (keep-compatibility))
+ (ignore-errors (init-app-menus))
+ (ignore-errors (init-misc-options))
+ (trap-errors
+ (let ((scratch (find-buffer "*scratch*")))
+ (when scratch
+ (save-excursion
+ (set-buffer scratch)
+ (funcall *initial-buffer-mode*)))))
+ (trap-errors (process-command-line))
+ (trap-errors (run-hooks '*post-startup-hook*))))
diff --git a/lisp/fstartup.l b/lisp/fstartup.l
new file mode 100644
index 0000000..1b39fc3
--- /dev/null
+++ b/lisp/fstartup.l
@@ -0,0 +1,19 @@
+;;; -*-Lisp-*-
+;;;
+;;; This file is part of xyzzy.
+;;;
+
+; (si:*load-library "loadup")
+
+(provide "startup-frame")
+
+(defun si:*startup-frame ()
+ (ed::startup-frame))
+
+;(unless (xyzzy-dumped-p)
+; (si:*show-window-foreground)
+; (ed::init-misc-objects)
+; (lisp::snarf-documentation)
+; (dump-xyzzy))
+
+(si:*startup-frame)
diff --git a/src/Buffer.cc b/src/Buffer.cc
index bcc4b8e..e7d75e3 100644
--- a/src/Buffer.cc
+++ b/src/Buffer.cc
@@ -114,7 +114,7 @@ Buffer::Buffer (lisp name, lisp filename, lisp dirname, int temporary)
b_prev = b_next = 0;
b_ldisp = 0;
- b_tab_columns = app.default_tab_columns;
+ b_tab_columns = active_app_frame().default_tab_columns;
b_local_tab_columns = 0;
lbp = temporary ? Qnil : make_buffer ();
@@ -334,7 +334,7 @@ Buffer::erase ()
if (xmarker_point (xcar (x)) != NO_MARK_SET)
xmarker_point (xcar (x)) = 0;
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = active_app_frame().active_frame.windows; wp; wp = wp->w_next)
if (wp->w_bufp == this)
{
wp->w_last_bufp = 0;
@@ -732,7 +732,7 @@ Buffer::quoted_buffer_name (char *b, char *be, int qc, int qe) const
void
Buffer::modify_mode_line () const
{
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = active_app_frame().active_frame.windows; wp; wp = wp->w_next)
if (wp->w_bufp == this)
wp->w_disp_flags |= Window::WDF_MODELINE;
}
@@ -910,13 +910,14 @@ Fdelete_buffer (lisp buffer)
return Qnil;
}
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
- if (wp->w_bufp == bp)
- {
- wp->w_last_bufp = 0;
- wp->w_bufp = 0;
- wp->set_buffer (newbp);
- }
+ for(ApplicationFrame *app = first_app_frame(); app; app = app->a_next)
+ for (Window *wp = app->active_frame.windows; wp; wp = wp->w_next)
+ if (wp->w_bufp == bp)
+ {
+ wp->w_last_bufp = 0;
+ wp->w_bufp = 0;
+ wp->set_buffer (newbp);
+ }
delete bp;
return Qt;
@@ -1206,7 +1207,7 @@ call_hooks (lisp hook)
int
Buffer::query_kill_xyzzy ()
{
- if (app.kbdq.disablep ())
+ if (active_app_frame().kbdq.disablep ())
return 0;
if (!call_hooks (Vbefore_delete_buffer_hook))
return 0;
@@ -1251,9 +1252,17 @@ Buffer::kill_xyzzy (int query)
return 1;
}
+extern bool is_last_app_frame();
+
lisp
Fkill_xyzzy ()
{
+ if(!is_last_app_frame())
+ {
+ PostMessage(active_app_frame().toplev, WM_CLOSE, 0, 0);
+ return Qnil;
+ }
+
if (Buffer::kill_xyzzy (1))
{
nonlocal_data *nld = nonlocal_jump::data ();
@@ -1283,7 +1292,7 @@ Buffer::refresh_title_bar () const
char buf[512 + 10];
buffer_info binfo (0, this, 0, 0);
*binfo.format (fmt, buf, buf + 512) = 0;
- SetWindowText (app.toplev, buf);
+ SetWindowText (active_app_frame().toplev, buf);
}
else
{
@@ -1302,7 +1311,7 @@ Buffer::refresh_title_bar () const
else
store_title (x, stpcpy (stpcpy (b, TitleBarString), " - "), b + l);
- SetWindowText (app.toplev, b);
+ SetWindowText (active_app_frame().toplev, b);
}
b_last_title_bar_buffer = 0; // 次回タイトルバーを強制的に再描画させる
}
@@ -1357,7 +1366,7 @@ Buffer::change_colors (const XCOLORREF *cc)
b_colors_enable = 0;
}
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = active_app_frame().active_frame.windows; wp; wp = wp->w_next)
if (wp->w_bufp == this)
wp->change_color ();
}
@@ -1413,7 +1422,7 @@ change_local_colors (const XCOLORREF *cc, int dir, int subdir)
void
Buffer::refresh_buffer () const
{
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = active_app_frame().active_frame.windows; wp; wp = wp->w_next)
if (wp->w_bufp == this)
wp->w_disp_flags |= Window::WDF_WINDOW;
}
@@ -1441,7 +1450,7 @@ Buffer::init_fold_width (int w)
if (w == FOLD_WINDOW)
{
w = -1;
- for (const Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (const Window *wp = active_app_frame().active_frame.windows; wp; wp = wp->w_next)
if (wp->w_bufp == this)
{
int cx = wp->w_ech.cx;
@@ -1883,7 +1892,7 @@ Buffer::change_ime_mode ()
{
b_last_selected_buffer = this;
if (xsymbol_value (Vsave_buffer_ime_mode) != Qnil)
- app.kbdq.toggle_ime (b_ime_mode);
+ active_app_frame().kbdq.toggle_ime (b_ime_mode);
}
}
@@ -1915,7 +1924,7 @@ Fset_buffer_ime_mode (lisp f, lisp buffer)
if (bp->b_ime_mode != omode
&& bp == selected_buffer ()
&& xsymbol_value (Vsave_buffer_ime_mode) != Qnil)
- app.kbdq.toggle_ime (bp->b_ime_mode);
+ active_app_frame().kbdq.toggle_ime (bp->b_ime_mode);
return Qt;
}
diff --git a/src/ChooseFont.cc b/src/ChooseFont.cc
index c357998..f1ad84f 100644
--- a/src/ChooseFont.cc
+++ b/src/ChooseFont.cc
@@ -3,7 +3,7 @@
ChooseFontP::ChooseFontP ()
{
- cf_hil = ImageList_LoadBitmap (app.hinst,
+ cf_hil = ImageList_LoadBitmap (g_app.hinst,
MAKEINTRESOURCE (IDB_TT),
18, 1, RGB (0, 0, 255));
}
@@ -21,7 +21,7 @@ ChooseFontP::add_lang (HWND hwnd)
{
char buf[128];
*buf = 0;
- LoadString (app.hinst, FontSet::lang_id (i), buf, sizeof buf);
+ LoadString (g_app.hinst, FontSet::lang_id (i), buf, sizeof buf);
int idx = SendDlgItemMessage (hwnd, IDC_LANG, CB_ADDSTRING, 0, LPARAM (buf));
SendDlgItemMessage (hwnd, IDC_LANG, CB_SETITEMDATA, idx, i);
}
diff --git a/src/ColorDialog.cc b/src/ColorDialog.cc
index 053e606..a3fb0a4 100644
--- a/src/ColorDialog.cc
+++ b/src/ColorDialog.cc
@@ -186,7 +186,7 @@ SelectColor::draw_combo (DRAWITEMSTRUCT *dis)
else
{
char b[256];
- if (!LoadString (app.hinst, dis->itemData, b, sizeof b))
+ if (!LoadString (g_app.hinst, dis->itemData, b, sizeof b))
*b = 0;
paint_color_list (dis, b, GetSysColor (dis->itemData - IDS_COLOR_SCROLLBAR));
}
@@ -343,7 +343,7 @@ SelectColor::select_color (HWND parent, XCOLORREF &c)
{
cc = c;
current_id = find_match (cc);
- if (DialogBoxParam (app.hinst, MAKEINTRESOURCE (IDD_SELECT_COLOR),
+ if (DialogBoxParam (g_app.hinst, MAKEINTRESOURCE (IDD_SELECT_COLOR),
parent, select_color_dlgproc, LPARAM (this)) == IDOK)
{
c = cc;
@@ -405,7 +405,7 @@ ChangeColorsPageP::init_page (UINT idd, PropSheet *sheet, int page_no,
psp->dwSize = sizeof *psp;
psp->dwFlags = ccp_hg ? PSP_DLGINDIRECT : 0;
- psp->hInstance = app.hinst;
+ psp->hInstance = g_app.hinst;
if (ccp_hg)
psp->pResource = (DLGTEMPLATE *)GlobalLock (ccp_hg);
else
@@ -683,12 +683,12 @@ ChooseFontPage::init_page (PropSheet *sheet, int page_no, PROPSHEETPAGE *psp)
ChangeColorsPageP::init_page (IDD_FONT, sheet, page_no, psp);
for (int i = 0; i < FONT_MAX; i++)
- GetObject (app.text_font.font (i), sizeof cfp_param.fs_logfont[i],
+ GetObject (active_app_frame().text_font.font (i), sizeof cfp_param.fs_logfont[i],
&cfp_param.fs_logfont[i]);
- cfp_param.fs_line_spacing = app.text_font.line_spacing ();
- cfp_param.fs_use_backsl = app.text_font.use_backsl_p ();
- cfp_param.fs_recommend_size = app.text_font.recommend_size_p ();
- cfp_param.fs_size_pixel = app.text_font.size_pixel_p ();
+ cfp_param.fs_line_spacing = active_app_frame().text_font.line_spacing ();
+ cfp_param.fs_use_backsl = active_app_frame().text_font.use_backsl_p ();
+ cfp_param.fs_recommend_size = active_app_frame().text_font.recommend_size_p ();
+ cfp_param.fs_size_pixel = active_app_frame().text_font.size_pixel_p ();
cfp_font.cf_param = cfp_param;
cfp_font.cf_fg = Window::default_xcolors[WCOLOR_TEXT];
cfp_font.cf_bg = Window::default_xcolors[WCOLOR_BACK];
diff --git a/src/DnD.cc b/src/DnD.cc
index b20032c..c2e50df 100644
--- a/src/DnD.cc
+++ b/src/DnD.cc
@@ -362,7 +362,7 @@ shell_context_menu (HWND hwnd, IShellFolder *sf,
return 0;
HWND hwnd_active = GetActiveWindow ();
- int enabled = IsWindowEnabled (app.toplev);
+ int enabled = IsWindowEnabled (active_app_frame().toplev);
CMINVOKECOMMANDINFO ci;
ci.cbSize = sizeof ci;
@@ -375,8 +375,8 @@ shell_context_menu (HWND hwnd, IShellFolder *sf,
ole_error (ctx_menu->InvokeCommand (&ci));
SetActiveWindow (hwnd_active);
- if (!enabled && IsWindowEnabled (app.toplev))
- EnableWindow (app.toplev, 0);
+ if (!enabled && IsWindowEnabled (active_app_frame().toplev))
+ EnableWindow (active_app_frame().toplev, 0);
return 1;
}
@@ -823,7 +823,7 @@ filer_drop_target::ask_user (DWORD *effect, DWORD req)
if (*effect == DROPEFFECT_NONE)
return;
- HMENU hmenu = LoadMenu (app.hinst, MAKEINTRESOURCE (IDM_DnD));
+ HMENU hmenu = LoadMenu (active_app_frame().hinst, MAKEINTRESOURCE (IDM_DnD));
HMENU hsub = GetSubMenu (hmenu, 0);
set_menu_state (hsub, *effect, req, IDC_MOVE, DROPEFFECT_MOVE);
set_menu_state (hsub, *effect, req, IDC_COPY, DROPEFFECT_COPY);
@@ -934,14 +934,14 @@ filer_drop_target::Drop (IDataObject *data_obj, DWORD key,
if (hr != S_OK)
*effect = DROPEFFECT_NONE;
- app.status_window.clear ();
+ active_app_frame().status_window.clear ();
return hr;
}
int
goto_pt (const POINTL &pt)
{
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = active_app_frame().active_frame.windows; wp; wp = wp->w_next)
if (wp->w_bufp)
{
RECT r;
@@ -956,14 +956,14 @@ goto_pt (const POINTL &pt)
break;
int x = p.x;
int y = p.y;
- if (x < r.left + app.text_font.cell ().cx / 2)
- x -= app.text_font.cell ().cx / 2;
- if (x >= r.right - app.text_font.cell ().cx / 2)
- x += app.text_font.cell ().cx / 2;
- if (y < r.top + app.text_font.cell ().cy / 2)
- y -= app.text_font.cell ().cy / 2;
- if (y >= r.bottom - app.text_font.cell ().cy / 2)
- y += app.text_font.cell ().cy / 2;
+ if (x < r.left + active_app_frame().text_font.cell ().cx / 2)
+ x -= active_app_frame().text_font.cell ().cx / 2;
+ if (x >= r.right - active_app_frame().text_font.cell ().cx / 2)
+ x += active_app_frame().text_font.cell ().cx / 2;
+ if (y < r.top + active_app_frame().text_font.cell ().cy / 2)
+ y -= active_app_frame().text_font.cell ().cy / 2;
+ if (y >= r.bottom - active_app_frame().text_font.cell ().cy / 2)
+ y += active_app_frame().text_font.cell ().cy / 2;
rowcol_from_point (wp, &x, &y);
if (wp->w_bufp->b_fold_columns == Buffer::FOLD_NONE)
{
@@ -976,12 +976,12 @@ goto_pt (const POINTL &pt)
wp->w_bufp->folded_goto_column (wp->w_point, x, 0);
}
wp->w_bufp->check_range (wp->w_point);
- app.drop_window = wp;
+ active_app_frame().drop_window = wp;
refresh_screen (0);
return 1;
}
}
- app.drop_window = 0;
+ active_app_frame().drop_window = 0;
refresh_screen (0);
return 0;
}
@@ -994,7 +994,7 @@ text_drop_target::query_drop (DWORD key, const POINTL &pt, DWORD *effect)
else
{
DWORD req = *effect;
- if (app.drag_window && app.drag_window->w_bufp != app.drag_buffer)
+ if (active_app_frame().drag_window && active_app_frame().drag_window->w_bufp != active_app_frame().drag_buffer)
*effect = DROPEFFECT_COPY;
else
*effect = key & MK_CONTROL ? DROPEFFECT_COPY : DROPEFFECT_MOVE;
@@ -1009,7 +1009,7 @@ STDMETHODIMP
text_drop_target::DragEnter (IDataObject *data_obj, DWORD key,
POINTL pt, DWORD *effect)
{
- app.f_in_drop = 1;
+ active_app_frame().f_in_drop = 1;
if (xsymbol_value (Venable_DnD_edit) == Qnil)
tdt_accept = 0;
@@ -1039,8 +1039,8 @@ text_drop_target::DragOver (DWORD key, POINTL pt, DWORD *effect)
STDMETHODIMP
text_drop_target::DragLeave ()
{
- app.drop_window = 0;
- app.f_in_drop = 0;
+ active_app_frame().drop_window = 0;
+ active_app_frame().f_in_drop = 0;
refresh_screen (0);
return S_OK;
}
@@ -1057,17 +1057,17 @@ STDMETHODIMP
text_drop_target::Drop (IDataObject *data_obj, DWORD key,
POINTL pt, DWORD *effect)
{
- app.f_in_drop = 0;
+ active_app_frame().f_in_drop = 0;
query_drop (key, pt, effect);
if (*effect == DROPEFFECT_NONE)
return S_OK;
if (*effect == DROPEFFECT_MOVE
- && app.drag_window
- && app.drag_window->w_bufp == app.drag_buffer
- && app.drop_window->w_bufp == app.drag_window->w_bufp
- && app.drop_window->w_point.p_point >= app.drag_region.p1
- && app.drop_window->w_point.p_point <= app.drag_region.p2)
+ && active_app_frame().drag_window
+ && active_app_frame().drag_window->w_bufp == active_app_frame().drag_buffer
+ && active_app_frame().drop_window->w_bufp == active_app_frame().drag_window->w_bufp
+ && active_app_frame().drop_window->w_point.p_point >= active_app_frame().drag_region.p1
+ && active_app_frame().drop_window->w_point.p_point <= active_app_frame().drag_region.p2)
{
*effect = DROPEFFECT_NONE;
return S_OK;
@@ -1103,7 +1103,7 @@ text_drop_target::Drop (IDataObject *data_obj, DWORD key,
{
try
{
- Window *wp = app.drop_window;
+ Window *wp = active_app_frame().drop_window;
Buffer *bp = wp->w_bufp;
bp->check_read_only ();
hr = E_OUTOFMEMORY;
@@ -1114,7 +1114,7 @@ text_drop_target::Drop (IDataObject *data_obj, DWORD key,
if (make_string_from_clipboard_text (x, ptr, etc.cfFormat,
ENCODING_LANG_NIL))
{
- bp->insert_chars (app.drop_window->w_point,
+ bp->insert_chars (active_app_frame().drop_window->w_point,
xstring_contents (x), xstring_length (x));
hr = S_OK;
}
@@ -1122,7 +1122,7 @@ text_drop_target::Drop (IDataObject *data_obj, DWORD key,
else
{
xyzzytext_header *x = (xyzzytext_header *)ptr;
- bp->insert_chars (app.drop_window->w_point, x->data, x->size);
+ bp->insert_chars (active_app_frame().drop_window->w_point, x->data, x->size);
hr = S_OK;
}
if (hr == S_OK)
@@ -1135,8 +1135,8 @@ text_drop_target::Drop (IDataObject *data_obj, DWORD key,
}
GlobalUnlock (medium.hGlobal);
}
- refresh_screen (!app.drag_window
- || app.drop_window->w_bufp != app.drag_window->w_bufp);
+ refresh_screen (!active_app_frame().drag_window
+ || active_app_frame().drop_window->w_bufp != active_app_frame().drag_window->w_bufp);
if (hr != S_OK)
*effect = DROPEFFECT_NONE;
@@ -1332,16 +1332,16 @@ Fdrag_region (lisp from, lisp to)
point_t p2 = bp->coerce_to_point (to);
if (p1 > p2)
swap (p1, p2);
- app.drop_window = 0;
+ active_app_frame().drop_window = 0;
text_data_object *data_obj = new text_data_object (bp, p1, p2);
HRESULT hr = 0;
DWORD effect = DROPEFFECT_COPY | DROPEFFECT_MOVE;
try
{
- app.drag_window = selected_window ();
- app.drag_buffer = selected_buffer ();
- app.drag_region.p1 = p1;
- app.drag_region.p2 = p2;
+ active_app_frame().drag_window = selected_window ();
+ active_app_frame().drag_buffer = selected_buffer ();
+ active_app_frame().drag_region.p1 = p1;
+ active_app_frame().drag_region.p2 = p2;
text_drop_source drop_src;
hr = DoDragDrop (data_obj, &drop_src, effect, &effect);
}
@@ -1349,8 +1349,8 @@ Fdrag_region (lisp from, lisp to)
{
}
- app.drag_window = 0;
- app.drag_buffer = 0;
+ active_app_frame().drag_window = 0;
+ active_app_frame().drag_buffer = 0;
data_obj->make_invalid ();
data_obj->Release ();
@@ -1375,8 +1375,8 @@ Fdrag_region (lisp from, lisp to)
}
multiple_value::count () = 2;
- multiple_value::value (1) = app.drop_window ? app.drop_window->lwp : Qnil;
- app.drop_window = 0;
+ multiple_value::value (1) = active_app_frame().drop_window ? active_app_frame().drop_window->lwp : Qnil;
+ active_app_frame().drop_window = 0;
return leffect;
}
diff --git a/src/Makefile b/src/Makefile
index e1d071e..f43a33d 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -49,6 +49,7 @@ fileio.cc \
filer.cc \
fnkey.cc \
font.cc \
+frame.cc \
gime.cc \
glob.cc \
guid.cc \
diff --git a/src/Window.cc b/src/Window.cc
index b22ece6..4ae0573 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -434,7 +434,7 @@ Window::init (int minibufp, int temporary)
Application::ClientClassName, "",
(WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE
| WS_VSCROLL | WS_HSCROLL),
- 0, 0, 0, 0, app.active_frame.hwnd, 0, app.hinst, this))
+ 0, 0, 0, 0, w_owner->active_frame.hwnd, 0, w_owner->hinst, this))
FEstorage_error ();
if (minibufp)
@@ -442,7 +442,7 @@ Window::init (int minibufp, int temporary)
else if (!CreateWindow (Application::ModelineClassName, "",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE,
0, 0, 0, 0,
- app.active_frame.hwnd, 0, app.hinst, this))
+ w_owner->active_frame.hwnd, 0, w_owner->hinst, this))
{
DestroyWindow (w_hwnd);
FEstorage_error ();
@@ -468,6 +468,7 @@ Window::Window (const Window &src)
lwp = Qnil;
w_next = w_prev = 0;
#define CP(x) (x = src.x)
+ CP (w_owner);
CP (w_bufp);
CP (w_flags_mask);
CP (w_flags);
@@ -499,8 +500,9 @@ Window::Window (const Window &src)
てきとーに対処。*/
#pragma optimize("g", off)
-Window::Window (int minibufp, int temporary)
+Window::Window (ApplicationFrame *owner, int minibufp, int temporary)
{
+ w_owner = owner;
lwp = Qnil;
w_bufp = 0;
w_next = w_prev = 0;
@@ -633,7 +635,7 @@ Window::set_window ()
{
assert (this);
assert (xwindow_wp (lwp) == this);
- app.active_frame.selected = this;
+ w_owner->active_frame.selected = this;
w_bufp->check_range (w_point);
}
@@ -703,19 +705,20 @@ Window::invalidate_glyphs ()
w_cursor_line.ypixel = -1;
}
+// static!
void
Window::change_parameters (const FontSetParam &param,
const XCOLORREF *colors, const XCOLORREF *mlcolors,
const XCOLORREF *fg, const XCOLORREF *bg)
{
- int ocell = app.text_font.cell ().cy;
+ int ocell = active_app_frame().text_font.cell ().cy;
- app.text_font.create (param);
+ active_app_frame().text_font.create (param);
init_colors (colors, mlcolors, fg, bg);
- compute_geometry (app.active_frame.size, ocell);
+ compute_geometry (&active_app_frame(), active_app_frame().active_frame.size, ocell);
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = active_app_frame().active_frame.windows; wp; wp = wp->w_next)
wp->invalidate_glyphs ();
}
@@ -732,9 +735,9 @@ set_bgmode ()
}
void
-Window::create_default_windows ()
+Window::create_default_windows (ApplicationFrame *owner)
{
- app.text_font.init ();
+ owner->text_font.init ();
XCOLORREF cc[USER_DEFINABLE_COLORS];
for (int i = 0; i < USER_DEFINABLE_COLORS; i++)
@@ -787,8 +790,8 @@ Window::create_default_windows ()
init_colors (cc, mlcc, fg, bg);
set_bgmode ();
- Window *wp = new Window ();
- Window *mwp = new Window (1);
+ Window *wp = new Window (owner);
+ Window *mwp = new Window (owner, 1);
wp->w_order.left = 0;
wp->w_order.top = 0;
@@ -796,31 +799,31 @@ Window::create_default_windows ()
wp->w_order.bottom = 1;
mwp->w_rect.top = 0;
- mwp->w_rect.bottom = app.text_font.size ().cy + sysdep.edge.cy;
+ mwp->w_rect.bottom = owner->text_font.size ().cy + sysdep.edge.cy;
wp->w_prev = 0;
wp->w_next = mwp;
mwp->w_prev = wp;
mwp->w_next = 0;
- app.active_frame.windows = wp;
- app.active_frame.selected = wp;
+ owner->active_frame.windows = wp;
+ owner->active_frame.selected = wp;
SIZE osize = {0, 0};
- if (!IsIconic (app.toplev))
+ if (!IsIconic (owner->toplev))
{
RECT r;
- GetClientRect (app.active_frame.hwnd, &r);
- app.active_frame.size.cx = r.right;
- app.active_frame.size.cy = r.bottom;
+ GetClientRect (owner->active_frame.hwnd, &r);
+ owner->active_frame.size.cx = r.right;
+ owner->active_frame.size.cy = r.bottom;
}
else
{
- app.active_frame.size.cx = 10;
- app.active_frame.size.cy = 10;
+ owner->active_frame.size.cx = 10;
+ owner->active_frame.size.cy = 10;
}
- Window::compute_geometry (osize);
- Window::move_all_windows (0);
+ Window::compute_geometry (owner, osize);
+ Window::move_all_windows (owner, 0);
}
int
@@ -840,12 +843,12 @@ Window::calc_client_size (int width, int height)
{
w_client.cx = max (0, width);
w_client.cy = max (0, height);
- w_ech.cx = max (0L, ((w_client.cx - app.text_font.cell ().cx / 2)
- / app.text_font.cell ().cx));
- w_ech.cy = w_client.cy / app.text_font.cell ().cy;
- w_ch_max.cx = (w_client.cx + app.text_font.cell ().cx
- + app.text_font.cell ().cx / 2 - 1) / app.text_font.cell ().cx;
- w_ch_max.cy = (w_client.cy + app.text_font.cell ().cy - 1) / app.text_font.cell ().cy;
+ w_ech.cx = max (0L, ((w_client.cx - w_owner->text_font.cell ().cx / 2)
+ / w_owner->text_font.cell ().cx));
+ w_ech.cy = w_client.cy / w_owner->text_font.cell ().cy;
+ w_ch_max.cx = (w_client.cx + w_owner->text_font.cell ().cx
+ + w_owner->text_font.cell ().cx / 2 - 1) / w_owner->text_font.cell ().cx;
+ w_ch_max.cy = (w_client.cy + w_owner->text_font.cell ().cy - 1) / w_owner->text_font.cell ().cy;
if (!w_ech.cx && w_ch_max.cx)
w_ech.cx = 1;
if (!w_ech.cy && w_ch_max.cy)
@@ -911,21 +914,21 @@ compute_size (int *o, int n, int old_size, int new_size)
}
void
-Window::compute_geometry (const SIZE &old_size, int lcell)
+Window::compute_geometry (ApplicationFrame *owner, const SIZE &old_size, int lcell)
{
- if (!app.active_frame.windows)
+ if (!owner->active_frame.windows)
return;
- const SIZE &new_size = app.active_frame.size;
+ const SIZE &new_size = owner->active_frame.size;
- for (Window *wp = app.active_frame.windows; wp->w_next; wp = wp->w_next)
+ for (Window *wp = owner->active_frame.windows; wp->w_next; wp = wp->w_next)
;
wp->w_rect.left = 0;
wp->w_rect.right = new_size.cx;
int h = max (int ((wp->w_rect.bottom - wp->w_rect.top)
- * app.text_font.cell ().cy / lcell),
+ * owner->text_font.cell ().cy / lcell),
lcell);
- h = max (h, int (app.text_font.cell ().cy + 4));
+ h = max (h, int (owner->text_font.cell ().cy + 4));
wp->w_rect.bottom = new_size.cy;
wp->w_rect.top = new_size.cy - h;
@@ -934,7 +937,7 @@ Window::compute_geometry (const SIZE &old_size, int lcell)
long nx = 0, ny = 0;
long ow = 0, oh = 0;
- for (wp = app.active_frame.windows; wp->w_next; wp = wp->w_next)
+ for (wp = owner->active_frame.windows; wp->w_next; wp = wp->w_next)
{
nx = max (nx, wp->w_order.right);
ny = max (ny, wp->w_order.bottom);
@@ -944,7 +947,7 @@ Window::compute_geometry (const SIZE &old_size, int lcell)
int *const ox = (int *)alloca (sizeof *ox * (nx + 1));
int *const oy = (int *)alloca (sizeof *oy * (ny + 1));
- for (wp = app.active_frame.windows; wp->w_next; wp = wp->w_next)
+ for (wp = owner->active_frame.windows; wp->w_next; wp = wp->w_next)
{
ox[wp->w_order.left] = wp->w_rect.left;
oy[wp->w_order.top] = wp->w_rect.top;
@@ -955,7 +958,7 @@ Window::compute_geometry (const SIZE &old_size, int lcell)
compute_size (ox, nx, ow, new_size.cx);
compute_size (oy, ny, oh, new_size.cy - h);
- for (wp = app.active_frame.windows; wp->w_next; wp = wp->w_next)
+ for (wp = owner->active_frame.windows; wp->w_next; wp = wp->w_next)
{
wp->w_rect.left = ox[wp->w_order.left];
wp->w_rect.top = oy[wp->w_order.top];
@@ -968,33 +971,33 @@ Window::compute_geometry (const SIZE &old_size, int lcell)
cx -= sysdep.vscroll;
if (wp->flags () & WF_HSCROLL_BAR)
cy -= sysdep.hscroll;
- if (wp->w_rect.right != app.active_frame.size.cx)
+ if (wp->w_rect.right != owner->active_frame.size.cx)
cx -= FRAME_WIDTH;
cx -= RIGHT_PADDING;
if (wp->w_hwnd_ml)
- cy -= app.modeline_param.m_height + 4 + FRAME_WIDTH;
+ cy -= owner->modeline_param.m_height + 4 + FRAME_WIDTH;
if (!wp->minibuffer_window_p () && wp->flags () & WF_RULER)
cy -= RULER_HEIGHT;
wp->calc_client_size (cx, cy);
}
- app.active_frame.windows_moved = 1;
+ owner->active_frame.windows_moved = 1;
}
void
-Window::move_all_windows (int update)
+Window::move_all_windows (ApplicationFrame *owner, int update)
{
int mod = 0;
- app.active_frame.windows_moved = 0;
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ owner->active_frame.windows_moved = 0;
+ for (Window *wp = owner->active_frame.windows; wp; wp = wp->w_next)
{
int cx, cy;
int mlh;
if (wp->w_hwnd_ml)
{
- mlh = wp->flags () & WF_MODE_LINE ? app.modeline_param.m_height + 4 : 0;
- cx = wp->w_rect.right == app.active_frame.size.cx ? 0 : FRAME_WIDTH;
+ mlh = wp->flags () & WF_MODE_LINE ? owner->modeline_param.m_height + 4 : 0;
+ cx = wp->w_rect.right == owner->active_frame.size.cx ? 0 : FRAME_WIDTH;
cy = FRAME_WIDTH;
}
else
@@ -1041,7 +1044,7 @@ Window::move_all_windows (int update)
}
}
- for (wp = app.active_frame.reserved; wp; wp = wp->w_next)
+ for (wp = owner->active_frame.reserved; wp; wp = wp->w_next)
{
MoveWindow (wp->w_hwnd, 0, 0, 0, 0, 1);
if (wp->w_hwnd_ml)
@@ -1050,24 +1053,24 @@ Window::move_all_windows (int update)
if (mod)
{
- for (wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (wp = owner->active_frame.windows; wp; wp = wp->w_next)
if (wp->w_bufp)
wp->w_bufp->window_size_changed ();
- InvalidateRect (app.active_frame.hwnd, 0, 1);
- InvalidateRect (app.toplev, 0, 1);
+ InvalidateRect (owner->active_frame.hwnd, 0, 1);
+ InvalidateRect (owner->toplev, 0, 1);
if (update)
{
- UpdateWindow (app.active_frame.hwnd);
- UpdateWindow (app.toplev);
+ UpdateWindow (owner->active_frame.hwnd);
+ UpdateWindow (owner->toplev);
}
}
}
void
-Window::repaint_all_windows ()
+Window::repaint_all_windows (ApplicationFrame *owner)
{
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = owner->active_frame.windows; wp; wp = wp->w_next)
if (!GetUpdateRect (wp->w_hwnd, 0, 0))
wp->update_window ();
}
@@ -1076,12 +1079,15 @@ void
Window::destroy_windows ()
{
Window *wp, *next;
- for (wp = app.active_frame.deleted; wp; wp = next)
+ for (ApplicationFrame *app1 = first_app_frame(); app1; app1 = app1->a_next)
{
- next = wp->w_next;
- delete wp;
+ for (wp = app1->active_frame.deleted; wp; wp = next)
+ {
+ next = wp->w_next;
+ delete wp;
+ }
+ app1->active_frame.deleted = 0;
}
- app.active_frame.deleted = 0;
}
void
@@ -1328,9 +1334,9 @@ Window::coerce_to_window (lisp object)
}
Window *
-Window::minibuffer_window ()
+Window::minibuffer_window (ApplicationFrame *owner)
{
- for (Window *wp = app.active_frame.windows; wp->w_next; wp = wp->w_next)
+ for (Window *wp = owner->active_frame.windows; wp->w_next; wp = wp->w_next)
;
return wp;
}
@@ -1339,17 +1345,11 @@ int
Window::count_windows ()
{
int n = 0;
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next, n++)
+ for (Window *wp = active_app_frame().active_frame.windows; wp; wp = wp->w_next, n++)
;
return n;
}
-void
-Window::modify_all_mode_line ()
-{
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
- wp->w_disp_flags |= WDF_MODELINE;
-}
void
Window::split (int nlines, int verticalp)
@@ -1372,7 +1372,7 @@ Window::split (int nlines, int verticalp)
}
else
{
- int ml = app.modeline_param.m_height + 4;
+ int ml = w_owner->modeline_param.m_height + 4;
if (nlines > 0)
{
h0 = nlines;
@@ -1385,9 +1385,9 @@ Window::split (int nlines, int verticalp)
h0 = w_ech.cy - h1 - 1;
current = 1;
}
- pxl = (h0 * app.text_font.cell ().cy + ml
+ pxl = (h0 * w_owner->text_font.cell ().cy + ml
+ (w_rect.bottom - w_rect.top - ml
- - (h0 + h1) * app.text_font.cell ().cy) / 2);
+ - (h0 + h1) * w_owner->text_font.cell ().cy) / 2);
}
if (h0 < 1 || h1 < 1)
@@ -1416,9 +1416,9 @@ Window::split (int nlines, int verticalp)
h0 = w_ech.cx - h1 - 1;
current = 1;
}
- pxl = (h0 * app.text_font.cell ().cx
+ pxl = (h0 * w_owner->text_font.cell ().cx
+ (w_rect.right - w_rect.left
- - (h0 + h1) * app.text_font.cell ().cx) / 2);
+ - (h0 + h1) * w_owner->text_font.cell ().cx) / 2);
}
#define WINDOW_WIDTH_MIN 10
if (h0 < WINDOW_WIDTH_MIN || h1 < WINDOW_WIDTH_MIN)
@@ -1440,7 +1440,7 @@ Window::split (int nlines, int verticalp)
w_rect.bottom = w_rect.top + pxl;
wp->w_rect.top = w_rect.bottom;
- for (Window *w = app.active_frame.windows; w->w_next; w = w->w_next)
+ for (Window *w = w_owner->active_frame.windows; w->w_next; w = w->w_next)
if (w != wp && w->w_rect.top == wp->w_rect.top)
{
w_order.bottom = w->w_order.top;
@@ -1451,7 +1451,7 @@ Window::split (int nlines, int verticalp)
if (!w->w_next)
{
int y, o;
- for (w = app.active_frame.windows, y = o = 0; w->w_next; w = w->w_next)
+ for (w = w_owner->active_frame.windows, y = o = 0; w->w_next; w = w->w_next)
if (w->w_rect.top < wp->w_rect.top && w->w_rect.top > y)
{
y = w->w_rect.top;
@@ -1459,7 +1459,7 @@ Window::split (int nlines, int verticalp)
}
w_order.bottom = o + 1;
wp->w_order.top = o + 1;
- for (w = app.active_frame.windows; w->w_next; w = w->w_next)
+ for (w = w_owner->active_frame.windows; w->w_next; w = w->w_next)
{
if (w != wp && w->w_order.top > o)
w->w_order.top++;
@@ -1476,7 +1476,7 @@ Window::split (int nlines, int verticalp)
w_rect.right = w_rect.left + pxl;
wp->w_rect.left = w_rect.right;
- for (Window *w = app.active_frame.windows; w->w_next; w = w->w_next)
+ for (Window *w = w_owner->active_frame.windows; w->w_next; w = w->w_next)
if (w != wp && w->w_rect.left == wp->w_rect.left)
{
w_order.right = w->w_order.left;
@@ -1487,7 +1487,7 @@ Window::split (int nlines, int verticalp)
if (!w->w_next)
{
int x, o;
- for (w = app.active_frame.windows, x = o = 0; w->w_next; w = w->w_next)
+ for (w = w_owner->active_frame.windows, x = o = 0; w->w_next; w = w->w_next)
if (w->w_rect.left < wp->w_rect.left && w->w_rect.left > x)
{
x = w->w_rect.left;
@@ -1495,7 +1495,7 @@ Window::split (int nlines, int verticalp)
}
w_order.right = o + 1;
wp->w_order.left = o + 1;
- for (w = app.active_frame.windows; w->w_next; w = w->w_next)
+ for (w = w_owner->active_frame.windows; w->w_next; w = w->w_next)
{
if (w != wp && w->w_order.left > o)
w->w_order.left++;
@@ -1508,7 +1508,7 @@ Window::split (int nlines, int verticalp)
if (current)
wp->set_window ();
- compute_geometry ();
+ compute_geometry (w_owner);
wp->change_color ();
Buffer::maybe_modify_buffer_bar ();
}
@@ -1530,13 +1530,13 @@ Window::close ()
for (WindowConfiguration::Data *d = wc->wc_data, *de = d + wc->wc_nwindows; d < de; d++)
if (d->wp == this)
{
- w_next = app.active_frame.reserved;
- app.active_frame.reserved = this;
+ w_next = w_owner->active_frame.reserved;
+ w_owner->active_frame.reserved = this;
return;
}
- w_next = app.active_frame.deleted;
- app.active_frame.deleted = this;
+ w_next = w_owner->active_frame.deleted;
+ w_owner->active_frame.deleted = this;
}
void
@@ -1548,7 +1548,7 @@ Window::delete_other_windows ()
Window *mini = minibuffer_window ();
int f = 0;
- for (Window *wp = app.active_frame.windows, *next; wp; wp = next)
+ for (Window *wp = w_owner->active_frame.windows, *next; wp; wp = next)
{
next = wp->w_next;
if (wp != this && wp != mini)
@@ -1561,7 +1561,7 @@ Window::delete_other_windows ()
if (!f)
return;
- app.active_frame.windows = this;
+ w_owner->active_frame.windows = this;
set_window ();
w_prev = 0;
w_next = mini;
@@ -1573,7 +1573,7 @@ Window::delete_other_windows ()
w_order.top = 0;
w_order.bottom = 1;
- compute_geometry ();
+ compute_geometry (w_owner);
Buffer::maybe_modify_buffer_bar ();
}
@@ -1589,7 +1589,7 @@ Window::find_resizeable_edge (LONG RECT::*edge1, LONG RECT::*edge2,
LONG RECT::*match1, LONG RECT::*match2) const
{
int n = 0;
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = w_owner->active_frame.windows; wp; wp = wp->w_next)
if (!wp->minibuffer_window_p () && wp->w_order.*edge1 == w_order.*edge2)
{
if (wp->w_order.*match1 == w_order.*match1)
@@ -1619,7 +1619,7 @@ void
Window::resize_edge (LONG RECT::*edge1, LONG RECT::*edge2,
LONG RECT::*match1, LONG RECT::*match2) const
{
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = w_owner->active_frame.windows; wp; wp = wp->w_next)
if (!wp->minibuffer_window_p ()
&& wp->w_order.*edge1 == w_order.*edge2
&& wp->w_order.*match1 >= w_order.*match1
@@ -1629,11 +1629,11 @@ Window::resize_edge (LONG RECT::*edge1, LONG RECT::*edge2,
wp->w_rect.*edge1 = w_rect.*edge1;
}
- for (wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (wp = w_owner->active_frame.windows; wp; wp = wp->w_next)
if (!wp->minibuffer_window_p () && wp->w_order.*edge2 == w_order.*edge2)
return;
- for (wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (wp = w_owner->active_frame.windows; wp; wp = wp->w_next)
if (!wp->minibuffer_window_p ())
{
if (wp->w_order.*edge2 > w_order.*edge2)
@@ -1657,18 +1657,18 @@ Window::resize_edge (int f) const
}
Window *
-Window::find_point_window (POINT &p)
+Window::find_point_window (ApplicationFrame *owner, POINT &p)
{
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = owner->active_frame.windows; wp; wp = wp->w_next)
if (PtInRect (&wp->w_rect, p))
break;
return wp;
}
Window *
-Window::find_scr_point_window (const POINT &pt, int ml, int *in_ml)
+Window::find_scr_point_window (ApplicationFrame *owner, const POINT &pt, int ml, int *in_ml)
{
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = owner->active_frame.windows; wp; wp = wp->w_next)
{
RECT r;
GetWindowRect (wp->w_hwnd, &r);
@@ -1710,7 +1710,7 @@ Window::delete_window ()
if (!f)
return 0;
can->w_prev = 0;
- app.active_frame.windows = can;
+ w_owner->active_frame.windows = can;
}
else
{
@@ -1730,11 +1730,11 @@ Window::delete_window ()
resize_edge (f);
save_buffer_params ();
close ();
- Window *wp = find_point_window (op);
+ Window *wp = find_point_window (w_owner, op);
if (!wp || !wp->w_bufp)
wp = can;
wp->set_window ();
- compute_geometry ();
+ compute_geometry (w_owner);
Buffer::maybe_modify_buffer_bar ();
return 1;
}
@@ -1777,6 +1777,7 @@ lisp
Fnext_window (lisp window, lisp minibufp)
{
Window *wp = Window::coerce_to_window (window);
+ ApplicationFrame *owner = wp->w_owner;
if (!minibufp)
minibufp = Qnil;
Window *next = wp->w_next;
@@ -1784,7 +1785,7 @@ Fnext_window (lisp window, lisp minibufp)
|| (!next->w_bufp && minibufp != Qt)
|| (next->minibuffer_window_p ()
&& minibufp != Qnil && minibufp != Qt))
- next = app.active_frame.windows;
+ next = owner->active_frame.windows;
return next->lwp;
}
@@ -1810,8 +1811,9 @@ Fget_buffer_window (lisp buffer, lisp curwin)
Buffer *bp = Buffer::coerce_to_buffer (buffer);
Window *cwp = ((curwin && curwin != Qnil)
? Window::coerce_to_window (curwin) : 0);
+ ApplicationFrame *owner = cwp != 0 ? cwp->w_owner : &active_app_frame();
int f = 0;
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = owner->active_frame.windows; wp; wp = wp->w_next)
if (wp->w_bufp == bp)
{
if (wp != cwp)
@@ -1836,20 +1838,20 @@ Fset_window (lisp window)
lisp
Fscreen_width ()
{
- return make_fixnum (app.active_frame.size.cx / app.text_font.cell ().cx);
+ return make_fixnum (active_app_frame().active_frame.size.cx / active_app_frame().text_font.cell ().cx);
}
lisp
Fscreen_height ()
{
- return make_fixnum (app.active_frame.size.cy / app.text_font.cell ().cy);
+ return make_fixnum (active_app_frame().active_frame.size.cy / active_app_frame().text_font.cell ().cy);
}
lisp
Fwindow_height (lisp window)
{
int h = (Window::coerce_to_window (window)->w_clsize.cy
- / app.text_font.cell ().cy);
+ / Window::coerce_to_window (window)->w_owner->text_font.cell ().cy);
return make_fixnum (max (h, 1));
}
@@ -1857,8 +1859,8 @@ lisp
Fwindow_width (lisp window)
{
int w = ((Window::coerce_to_window (window)->w_clsize.cx
- - app.text_font.cell ().cx / 2)
- / app.text_font.cell ().cx);
+ - Window::coerce_to_window (window)->w_owner->text_font.cell ().cx / 2)
+ / Window::coerce_to_window (window)->w_owner->text_font.cell ().cx);
return make_fixnum (max (w, 1));
}
@@ -1866,7 +1868,7 @@ lisp
Fwindow_lines (lisp window)
{
int h = (Window::coerce_to_window (window)->w_clsize.cy
- / app.text_font.cell ().cy);
+ / Window::coerce_to_window (window)->w_owner->text_font.cell ().cy);
return make_fixnum (max (h, 1));
}
@@ -1874,8 +1876,8 @@ lisp
Fwindow_columns (lisp window)
{
Window *wp = Window::coerce_to_window (window);
- int w = ((wp->w_clsize.cx - app.text_font.cell ().cx / 2)
- / app.text_font.cell ().cx);
+ int w = ((wp->w_clsize.cx - wp->w_owner->text_font.cell ().cx / 2)
+ / wp->w_owner->text_font.cell ().cx);
if (wp->flags () & Window::WF_LINE_NUMBER)
w -= Window::LINENUM_COLUMNS + 1;
if (wp->flags () & Window::WF_FOLD_MARK
@@ -1913,15 +1915,15 @@ lisp
Fget_window_handle (lisp window)
{
if (!window || window == Qnil)
- return make_fixnum (long (app.toplev));
+ return make_fixnum (long (active_app_frame().toplev));
return make_fixnum (long (Window::coerce_to_window (window)->w_hwnd));
}
int
-Window::find_horiz_order (int y)
+Window::find_horiz_order (ApplicationFrame *owner, int y)
{
int y0 = y;
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = owner->active_frame.windows; wp; wp = wp->w_next)
{
if (wp->w_rect.top > y && (y0 == y || wp->w_rect.top < y0))
y0 = wp->w_rect.top;
@@ -1938,7 +1940,7 @@ Window::change_horiz_size (int bottom, int xmin, int xmax)
if (obottom == bottom)
return;
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = w_owner->active_frame.windows; wp; wp = wp->w_next)
if (wp->w_rect.left < xmax && wp->w_rect.right > xmin)
{
if (wp->w_rect.top == obottom)
@@ -1947,9 +1949,9 @@ Window::change_horiz_size (int bottom, int xmin, int xmax)
wp->w_rect.bottom = bottom;
}
- for (int y = find_horiz_order (-1), order = 0;
- y >= 0; y = find_horiz_order (y), order++)
- for (wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (int y = find_horiz_order (w_owner, -1), order = 0;
+ y >= 0; y = find_horiz_order (w_owner, y), order++)
+ for (wp = w_owner->active_frame.windows; wp; wp = wp->w_next)
{
if (wp->w_rect.top == y)
wp->w_order.top = order;
@@ -1957,14 +1959,14 @@ Window::change_horiz_size (int bottom, int xmin, int xmax)
wp->w_order.bottom = order;
}
- compute_geometry ();
+ compute_geometry (w_owner);
}
int
-Window::find_vert_order (int x)
+Window::find_vert_order (ApplicationFrame *owner, int x)
{
int x0 = x;
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = owner->active_frame.windows; wp; wp = wp->w_next)
{
if (wp->w_rect.left > x && (x0 == x || wp->w_rect.left < x0))
x0 = wp->w_rect.left;
@@ -1981,7 +1983,7 @@ Window::change_vert_size (int right, int ymin, int ymax)
if (oright == right)
return;
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = w_owner->active_frame.windows; wp; wp = wp->w_next)
if (wp->w_rect.top < ymax && wp->w_rect.bottom > ymin)
{
if (wp->w_rect.left == oright)
@@ -1990,9 +1992,9 @@ Window::change_vert_size (int right, int ymin, int ymax)
wp->w_rect.right = right;
}
- for (int x = find_vert_order (-1), order = 0;
- x >= 0; x = find_vert_order (x), order++)
- for (wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (int x = find_vert_order (w_owner, -1), order = 0;
+ x >= 0; x = find_vert_order (w_owner, x), order++)
+ for (wp = w_owner->active_frame.windows; wp; wp = wp->w_next)
{
if (wp->w_rect.left == x)
wp->w_order.left = order;
@@ -2000,7 +2002,7 @@ Window::change_vert_size (int right, int ymin, int ymax)
wp->w_order.right = order;
}
- compute_geometry ();
+ compute_geometry (w_owner);
}
int
@@ -2010,7 +2012,7 @@ Window::enlarge_window_horiz (int n)
Window *wp2 = find_horiz_window (&RECT::right);
if (!wp1 || !wp2)
return 0;
- int goal = w_rect.bottom + n * app.text_font.cell ().cy;
+ int goal = w_rect.bottom + n * w_owner->text_font.cell ().cy;
if (goal < get_horiz_min (wp1->w_rect.left, wp2->w_rect.right)
|| goal > get_horiz_max (wp1->w_rect.left, wp2->w_rect.right))
return 0;
@@ -2025,7 +2027,7 @@ Window::enlarge_window_vert (int n)
Window *wp2 = find_vert_window (&RECT::bottom);
if (!wp1 || !wp2)
return 0;
- int goal = w_rect.right + n * app.text_font.cell ().cx;
+ int goal = w_rect.right + n * w_owner->text_font.cell ().cx;
if (goal < get_vert_min (wp1->w_rect.top, wp2->w_rect.bottom)
|| goal > get_vert_max (wp1->w_rect.top, wp2->w_rect.bottom))
return 0;
@@ -2040,12 +2042,12 @@ Window::enlarge_window (int n, int side)
return 1;
if (!side)
{
- for (Window *wp1 = app.active_frame.windows; wp1; wp1 = wp1->w_next)
+ for (Window *wp1 = w_owner->active_frame.windows; wp1; wp1 = wp1->w_next)
if (wp1->w_rect.bottom == w_rect.top
&& wp1->w_rect.left < w_rect.right
&& wp1->w_rect.right > w_rect.left)
break;
- for (Window *wp2 = app.active_frame.windows; wp2; wp2 = wp2->w_next)
+ for (Window *wp2 = w_owner->active_frame.windows; wp2; wp2 = wp2->w_next)
if (wp2->w_rect.top == w_rect.bottom
&& wp2->w_rect.left < w_rect.right
&& wp2->w_rect.right > w_rect.left)
@@ -2059,7 +2061,7 @@ Window::enlarge_window (int n, int side)
{
if (enlarge_window_vert (n))
return 1;
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = w_owner->active_frame.windows; wp; wp = wp->w_next)
if (wp->w_rect.right == w_rect.left
&& wp->w_rect.top < w_rect.bottom
&& wp->w_rect.bottom > w_rect.top)
@@ -2079,10 +2081,10 @@ Fenlarge_window (lisp nlines, lisp side)
}
Window *
-Window::find_point_window (const POINT &point, int &vert)
+Window::find_point_window (ApplicationFrame *owner, const POINT &point, int &vert)
{
- if (app.active_frame.windows)
- for (Window *wp = app.active_frame.windows; wp->w_next; wp = wp->w_next)
+ if (owner->active_frame.windows)
+ for (Window *wp = owner->active_frame.windows; wp->w_next; wp = wp->w_next)
if (PtInRect (&wp->w_rect, point))
{
if (point.x >= wp->w_rect.right - (FRAME_WIDTH + 1))
@@ -2097,7 +2099,7 @@ Window::find_point_window (const POINT &point, int &vert)
}
int
-Window::frame_window_setcursor (HWND hwnd, WPARAM, LPARAM lparam)
+Window::frame_window_setcursor (ApplicationFrame *owner, HWND hwnd, WPARAM, LPARAM lparam)
{
if (LOWORD (lparam) == HTCLIENT)
{
@@ -2105,7 +2107,7 @@ Window::frame_window_setcursor (HWND hwnd, WPARAM, LPARAM lparam)
GetCursorPos (&point);
ScreenToClient (hwnd, &point);
int vert;
- if (find_point_window (point, vert))
+ if (find_point_window (owner, point, vert))
{
SetCursor (vert ? sysdep.hcur_sizewe : sysdep.hcur_sizens);
return 1;
@@ -2119,7 +2121,7 @@ Window::find_resizeable_window (LONG RECT::*target,
LONG RECT::*emin, LONG RECT::*emax,
LONG RECT::*edge1, LONG RECT::*edge2) const
{
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = w_owner->active_frame.windows; wp; wp = wp->w_next)
if (wp != this && wp->w_rect.*edge1 == w_rect.*edge2)
{
if (wp->w_rect.*target == w_rect.*target)
@@ -2148,11 +2150,11 @@ int
Window::get_horiz_min (int xmin, int xmax) const
{
int y = w_rect.top;
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = w_owner->active_frame.windows; wp; wp = wp->w_next)
if (wp->w_rect.bottom == w_rect.bottom
&& wp->w_rect.left < xmax && wp->w_rect.right > xmin)
y = max (y, int (wp->w_rect.top));
- y += (app.modeline_param.m_height + 4 + app.text_font.cell ().cy
+ y += (w_owner->modeline_param.m_height + 4 + w_owner->text_font.cell ().cy
+ sysdep.edge.cy + FRAME_WIDTH);
if (!minibuffer_window_p () && flags () & WF_RULER)
y += RULER_HEIGHT;
@@ -2164,15 +2166,15 @@ Window::get_horiz_max (int xmin, int xmax) const
{
Window *mini = minibuffer_window ();
int y = mini->w_rect.bottom;
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = w_owner->active_frame.windows; wp; wp = wp->w_next)
if (wp->w_rect.top == w_rect.bottom
&& wp->w_rect.left < xmax && wp->w_rect.right > xmin)
y = min (y, int (wp->w_rect.bottom));
if (y == mini->w_rect.bottom)
- y -= app.text_font.cell ().cy + sysdep.edge.cy;
+ y -= w_owner->text_font.cell ().cy + sysdep.edge.cy;
else
{
- y -= (app.modeline_param.m_height + 4 + app.text_font.cell ().cy
+ y -= (w_owner->modeline_param.m_height + 4 + w_owner->text_font.cell ().cy
+ sysdep.edge.cy + FRAME_WIDTH);
if (flags () & WF_RULER)
y -= RULER_HEIGHT;
@@ -2184,44 +2186,44 @@ int
Window::get_vert_min (int ymin, int ymax) const
{
int x = w_rect.left;
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = w_owner->active_frame.windows; wp; wp = wp->w_next)
if (wp->w_rect.right == w_rect.right
&& wp->w_rect.top < ymax && wp->w_rect.bottom > ymin)
x = max (x, int (wp->w_rect.left));
- x += app.text_font.cell ().cx * WINDOW_WIDTH_MIN;
+ x += w_owner->text_font.cell ().cx * WINDOW_WIDTH_MIN;
return min (x, int (w_rect.right));
}
int
Window::get_vert_max (int ymin, int ymax) const
{
- int x = app.active_frame.size.cx;
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ int x = w_owner->active_frame.size.cx;
+ for (Window *wp = w_owner->active_frame.windows; wp; wp = wp->w_next)
if (wp->w_rect.left == w_rect.right
&& wp->w_rect.top < ymax && wp->w_rect.bottom > ymin)
x = min (x, int (wp->w_rect.right));
- x -= app.text_font.cell ().cx * WINDOW_WIDTH_MIN;
+ x -= w_owner->text_font.cell ().cx * WINDOW_WIDTH_MIN;
return x;
}
static void
-paint_resize_line (HWND hwnd, const RECT &cr, int vert)
+paint_resize_line (ApplicationFrame *owner, HWND hwnd, const RECT &cr, int vert)
{
RECT r = cr;
if (vert)
r.left -= FRAME_WIDTH;
else
r.top -= FRAME_WIDTH;
- MapWindowPoints (hwnd, app.toplev, (POINT *)&r, 2);
- HDC hdc = GetDC (app.toplev);
- HBITMAP hbm = LoadBitmap (app.hinst, MAKEINTRESOURCE (IDB_CHECK));
+ MapWindowPoints (hwnd, owner->toplev, (POINT *)&r, 2);
+ HDC hdc = GetDC (owner->toplev);
+ HBITMAP hbm = LoadBitmap (owner->hinst, MAKEINTRESOURCE (IDB_CHECK));
HBRUSH hbr = CreatePatternBrush (hbm);
DeleteObject (hbm);
HGDIOBJ obr = SelectObject (hdc, hbr);
PatBlt (hdc, r.left, r.top, r.right - r.left, r.bottom - r.top, PATINVERT);
SelectObject (hdc, obr);
DeleteObject (hbr);
- ReleaseDC (app.toplev, hdc);
+ ReleaseDC (owner->toplev, hdc);
}
int
@@ -2260,7 +2262,7 @@ Window::frame_window_resize (HWND hwnd, const POINT &point, int vert)
r.top = r.bottom = w_rect.bottom;
d = w_rect.bottom - point.y;
}
- paint_resize_line (hwnd, r, vert);
+ paint_resize_line (w_owner, hwnd, r, vert);
SetCapture (hwnd);
MSG msg;
@@ -2276,7 +2278,7 @@ Window::frame_window_resize (HWND hwnd, const POINT &point, int vert)
switch (msg.message)
{
case WM_MOUSEMOVE:
- paint_resize_line (hwnd, r, vert);
+ paint_resize_line (w_owner, hwnd, r, vert);
if (vert)
r.left = r.right = min (max (nmin,
short (LOWORD (msg.lParam)) + d),
@@ -2285,12 +2287,12 @@ Window::frame_window_resize (HWND hwnd, const POINT &point, int vert)
r.top = r.bottom = min (max (nmin,
short (HIWORD (msg.lParam)) + d),
nmax);
- paint_resize_line (hwnd, r, vert);
+ paint_resize_line (w_owner, hwnd, r, vert);
break;
case WM_LBUTTONUP:
ReleaseCapture ();
- paint_resize_line (hwnd, r, vert);
+ paint_resize_line (w_owner, hwnd, r, vert);
if (vert)
change_vert_size (min (max (nmin, short (LOWORD (msg.lParam)) + d), nmax),
r.top, r.bottom);
@@ -2313,18 +2315,18 @@ Window::frame_window_resize (HWND hwnd, const POINT &point, int vert)
}
}
done:
- paint_resize_line (hwnd, r, vert);
+ paint_resize_line (w_owner, hwnd, r, vert);
return 1;
}
int
-Window::frame_window_resize (HWND hwnd, LPARAM lparam, const POINT *real)
+Window::frame_window_resize (ApplicationFrame *owner, HWND hwnd, LPARAM lparam, const POINT *real)
{
POINT point;
point.x = short (LOWORD (lparam));
point.y = short (HIWORD (lparam));
int vert;
- Window *wp = Window::find_point_window (point, vert);
+ Window *wp = Window::find_point_window (owner, point, vert);
if (!wp)
return 0;
return wp->frame_window_resize (hwnd, real ? *real : point, vert);
@@ -2336,12 +2338,12 @@ WindowConfiguration::WindowConfiguration ()
wc_data = new Data[wc_nwindows];
wc_selected = selected_window ();
- wc_size = app.active_frame.size;
+ wc_size = active_app_frame().active_frame.size;
wc_prev = wc_chain;
wc_chain = this;
Data *d = wc_data;
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next, d++)
+ for (Window *wp = active_app_frame().active_frame.windows; wp; wp = wp->w_next, d++)
{
d->wp = wp;
d->bufp = wp->w_bufp;
@@ -2365,9 +2367,9 @@ WindowConfiguration::~WindowConfiguration ()
{
wc_chain = wc_prev;
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = active_app_frame().active_frame.windows; wp; wp = wp->w_next)
wp->w_disp_flags &= ~(Window::WDF_WINDOW | Window::WDF_MODELINE);
- for (wp = app.active_frame.reserved; wp; wp = wp->w_next)
+ for (wp = active_app_frame().active_frame.reserved; wp; wp = wp->w_next)
wp->w_disp_flags &= ~(Window::WDF_WINDOW | Window::WDF_MODELINE);
for (int i = 0; i < wc_nwindows; i++)
@@ -2376,7 +2378,7 @@ WindowConfiguration::~WindowConfiguration ()
Buffer *bp = Buffer::dlist_find ();
Window *reserved = 0, *next;
- for (wp = app.active_frame.windows; wp; wp = next)
+ for (wp = active_app_frame().active_frame.windows; wp; wp = next)
{
next = wp->w_next;
if (!(wp->w_disp_flags & Window::WDF_WINDOW))
@@ -2385,7 +2387,7 @@ WindowConfiguration::~WindowConfiguration ()
reserved = wp;
}
}
- for (wp = app.active_frame.reserved; wp; wp = next)
+ for (wp = active_app_frame().active_frame.reserved; wp; wp = next)
{
next = wp->w_next;
if (!(wp->w_disp_flags & Window::WDF_WINDOW))
@@ -2395,8 +2397,8 @@ WindowConfiguration::~WindowConfiguration ()
}
}
- app.active_frame.selected = wc_selected;
- app.active_frame.windows = wc_data[0].wp;
+ active_app_frame().active_frame.selected = wc_selected;
+ active_app_frame().active_frame.windows = wc_data[0].wp;
for (i = 0; i < wc_nwindows; i++)
{
wp = wc_data[i].wp;
@@ -2434,9 +2436,9 @@ WindowConfiguration::~WindowConfiguration ()
assert (xwindow_wp (selected_window ()->lwp));
assert (xwindow_wp (selected_window ()->lwp) == selected_window ());
- Window::compute_geometry (wc_size);
+ Window::compute_geometry (&active_app_frame(), wc_size);
- app.active_frame.reserved = 0;
+ active_app_frame().active_frame.reserved = 0;
for (wp = reserved; wp; wp = next)
{
next = wp->w_next;
@@ -2499,30 +2501,35 @@ check_modified_flags (Window *wp, int df)
return recompute;
}
+extern ApplicationFrame *first_app_frame();
lisp
Fset_window_flags (lisp flags)
{
int f = fixnum_value (flags);
int recompute = 0;
int dflags = Window::w_default_flags;
- for (Window *w = app.active_frame.windows; w; w = w->w_next)
- {
- Window::w_default_flags = dflags;
- int of = w->flags ();
- Window::w_default_flags = f;
- int df = of ^ w->flags ();
- if (check_modified_flags (w, df))
- recompute = 1;
- w->w_disp_flags |= Window::WDF_WINDOW;
- if (df & (Window::WF_BGCOLOR_MODE | Window::WF_LINE_NUMBER))
- w->invalidate_glyphs ();
- }
+ for (ApplicationFrame *app1 = first_app_frame(); app1; app1 = app1->a_next)
+ for (Window *w = active_app_frame().active_frame.windows; w; w = w->w_next)
+ {
+ Window::w_default_flags = dflags;
+ int of = w->flags ();
+ Window::w_default_flags = f;
+ int df = of ^ w->flags ();
+ if (check_modified_flags (w, df))
+ recompute = 1;
+ w->w_disp_flags |= Window::WDF_WINDOW;
+ if (df & (Window::WF_BGCOLOR_MODE | Window::WF_LINE_NUMBER))
+ w->invalidate_glyphs ();
+ }
Window::w_default_flags = f;
set_bgmode ();
- if ((f ^ dflags) & Window::WF_FUNCTION_BAR)
- recalc_toplevel ();
- else if (recompute)
- Window::compute_geometry ();
+ for(ApplicationFrame *app1 = first_app_frame(); app1; app1 = app1->a_next)
+ {
+ if ((f ^ dflags) & Window::WF_FUNCTION_BAR)
+ recalc_toplevel (app1);
+ else if (recompute)
+ Window::compute_geometry (app1);
+ }
return Qt;
}
@@ -2585,7 +2592,7 @@ Fset_local_window_flags (lisp lobj, lisp lflags, lisp lon)
new_flags &= ~(Window::WF_MODE_LINE | Window::WF_RULER);
new_flags_mask &= ~(Window::WF_MODE_LINE | Window::WF_RULER);
}
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = active_app_frame().active_frame.windows; wp; wp = wp->w_next)
if (wp->w_bufp == bp)
{
bp->b_wflags = old_flags;
@@ -2617,7 +2624,7 @@ Fset_local_window_flags (lisp lobj, lisp lflags, lisp lon)
recompute = 1;
}
if (recompute)
- Window::compute_geometry ();
+ Window::compute_geometry (&active_app_frame());
return Qt;
}
@@ -2647,7 +2654,7 @@ next_xyzzy_window (int next)
int i = xyzzy_instance::instnum ();
if (i < 0)
i = -1;
- xyzzy_hwnd xh (app.toplev);
+ xyzzy_hwnd xh (active_app_frame().toplev);
HWND hwnd = next ? xh.next (i) : xh.prev (i);
if (!hwnd)
return Qnil;
@@ -2670,14 +2677,14 @@ Fprevious_xyzzy_window ()
lisp
Fcount_xyzzy_instance ()
{
- xyzzy_hwnd xh (app.toplev);
+ xyzzy_hwnd xh (active_app_frame().toplev);
return make_fixnum (xh.count ());
}
lisp
Flist_xyzzy_windows ()
{
- xyzzy_hwnd xh (app.toplev);
+ xyzzy_hwnd xh (active_app_frame().toplev);
int i = -1;
lisp p = Qnil;
while (1)
@@ -2698,7 +2705,7 @@ Factivate_xyzzy_window (lisp x)
{
int i = fixnum_value (x);
int o = i--;
- xyzzy_hwnd xh (app.toplev);
+ xyzzy_hwnd xh (active_app_frame().toplev);
HWND hwnd = xh.next (i);
if (!hwnd || i != o)
return Qnil;
@@ -2731,7 +2738,7 @@ lisp
Fcurrent_window_configuration ()
{
lisp ldefs = Qnil;
- for (Window *wp = app.active_frame.windows; wp->w_next; wp = wp->w_next)
+ for (Window *wp = active_app_frame().active_frame.windows; wp->w_next; wp = wp->w_next)
{
Buffer *bp = wp->w_bufp;
ldefs = xcons (make_list (wp->lwp,
@@ -2766,8 +2773,8 @@ Fcurrent_window_configuration ()
return make_list (Qwindow_configuration,
Fselected_window (),
Fnreverse (ldefs),
- make_list (make_fixnum (app.active_frame.size.cx),
- make_fixnum (app.active_frame.size.cy),
+ make_list (make_fixnum (active_app_frame().active_frame.size.cx),
+ make_fixnum (active_app_frame().active_frame.size.cy),
0),
0);
}
@@ -2891,19 +2898,19 @@ wc_range (Buffer *bp, point_t point)
}
static void
-wc_restore (winconf *conf, int nwindows, const SIZE &size,
+wc_restore (ApplicationFrame *owner, winconf *conf, int nwindows, const SIZE &size,
lisp lselected_window, int curw)
{
Buffer *const bp = selected_buffer ();
Window *cur_wp = 0;
- Window *odeleted = app.active_frame.deleted;
+ Window *odeleted = active_app_frame().active_frame.deleted;
for (int i = 0; i < nwindows; i++)
{
if (!conf[i].wp)
{
- Window *wp = new Window ();
- wp->w_next = app.active_frame.deleted;
- app.active_frame.deleted = wp;
+ Window *wp = new Window (owner);
+ wp->w_next = owner->active_frame.deleted;
+ owner->active_frame.deleted = wp;
conf[i].wp = wp;
}
if (conf[i].lwp == Qnil)
@@ -2917,12 +2924,12 @@ wc_restore (winconf *conf, int nwindows, const SIZE &size,
if (curw >= 0 && curw < nwindows)
cur_wp = conf[curw].wp;
- app.active_frame.deleted = odeleted;
+ owner->active_frame.deleted = odeleted;
- for (Window *wp = app.active_frame.windows; wp->w_next; wp = wp->w_next)
+ for (Window *wp = owner->active_frame.windows; wp->w_next; wp = wp->w_next)
wp->w_disp_flags &= ~(Window::WDF_WINDOW | Window::WDF_MODELINE);
Window *const mini_wp = wp;
- for (wp = app.active_frame.reserved; wp; wp = wp->w_next)
+ for (wp = owner->active_frame.reserved; wp; wp = wp->w_next)
wp->w_disp_flags &= ~(Window::WDF_WINDOW | Window::WDF_MODELINE);
for (i = 0; i < nwindows; i++)
@@ -2934,7 +2941,7 @@ wc_restore (winconf *conf, int nwindows, const SIZE &size,
| Window::WDF_GOAL_COLUMN);
Window *reserved = 0, *next;
- for (wp = app.active_frame.windows; wp->w_next; wp = next)
+ for (wp = owner->active_frame.windows; wp->w_next; wp = next)
{
next = wp->w_next;
if (!(wp->w_disp_flags & Window::WDF_WINDOW))
@@ -2943,7 +2950,7 @@ wc_restore (winconf *conf, int nwindows, const SIZE &size,
reserved = wp;
}
}
- for (wp = app.active_frame.reserved; wp; wp = next)
+ for (wp = owner->active_frame.reserved; wp; wp = next)
{
next = wp->w_next;
if (!(wp->w_disp_flags & Window::WDF_WINDOW))
@@ -2954,8 +2961,8 @@ wc_restore (winconf *conf, int nwindows, const SIZE &size,
}
long ymax = -1;
- app.active_frame.selected = cur_wp ? cur_wp : conf[0].wp;
- app.active_frame.windows = conf[0].wp;
+ owner->active_frame.selected = cur_wp ? cur_wp : conf[0].wp;
+ owner->active_frame.windows = conf[0].wp;
for (i = 0; i < nwindows; i++)
{
wp = conf[i].wp;
@@ -3057,9 +3064,9 @@ wc_restore (winconf *conf, int nwindows, const SIZE &size,
assert (xwindow_wp (selected_window ()->lwp));
assert (xwindow_wp (selected_window ()->lwp) == selected_window ());
- Window::compute_geometry (size);
+ Window::compute_geometry (owner, size);
- app.active_frame.reserved = 0;
+ owner->active_frame.reserved = 0;
for (wp = reserved; wp; wp = next)
{
next = wp->w_next;
@@ -3084,6 +3091,7 @@ Fset_window_configuration (lisp lconf)
check_window (lselected_window);
}
+ ApplicationFrame *app_frame = xwindow_wp(lselected_window)->w_owner;
x = xcdr (x);
lisp ldefs = xcar (x);
if (!consp (ldefs))
@@ -3122,7 +3130,7 @@ Fset_window_configuration (lisp lconf)
conf[i].wp = xwindow_wp (conf[i].lwp);
if (!conf[i].wp)
{
- for (Window *wp = app.active_frame.reserved; wp; wp = wp->w_next)
+ for (Window *wp = app_frame->active_frame.reserved; wp; wp = wp->w_next)
if (wp->lwp == conf[i].lwp)
{
conf[i].wp = wp;
@@ -3179,7 +3187,7 @@ Fset_window_configuration (lisp lconf)
FEprogram_error (Einvalid_window_configuration);
wc_check_order (conf, nwindows, size);
- wc_restore (conf, nwindows, size, lselected_window, curw);
+ wc_restore (app_frame, conf, nwindows, size, lselected_window, curw);
return Qnil;
}
@@ -3230,7 +3238,7 @@ Fbegin_auto_scroll ()
{
POINT p;
GetCursorPos (&p);
- Window *wp = Window::find_scr_point_window (p, 0, 0);
+ Window *wp = Window::find_scr_point_window (&active_app_frame(), p, 0, 0);
if (!wp)
return Qnil;
Buffer *bp = wp->w_bufp;
@@ -3247,10 +3255,10 @@ void
Window::calc_ruler_rect (RECT &r) const
{
POINT p = {0, 0};
- MapWindowPoints (w_hwnd, app.active_frame.hwnd, &p, 1);
- r.left = p.x + app.text_font.cell ().cx / 2;
+ MapWindowPoints (w_hwnd, active_app_frame().active_frame.hwnd, &p, 1);
+ r.left = p.x + active_app_frame().text_font.cell ().cx / 2;
if (flags () & WF_LINE_NUMBER)
- r.left += (LINENUM_COLUMNS + 1) * app.text_font.cell ().cx;
+ r.left += (LINENUM_COLUMNS + 1) * active_app_frame().text_font.cell ().cx;
r.top = p.y - RULER_HEIGHT;
r.right = p.x + w_clsize.cx + RIGHT_PADDING - 1;
r.bottom = p.y - 3;
@@ -3259,8 +3267,8 @@ Window::calc_ruler_rect (RECT &r) const
inline void
Window::calc_ruler_box (const RECT &r, RECT &br) const
{
- br.left = r.left + (w_ruler_column - w_ruler_top_column) * app.text_font.cell ().cx;
- br.right = br.left + app.text_font.cell ().cx;
+ br.left = r.left + (w_ruler_column - w_ruler_top_column) * active_app_frame().text_font.cell ().cx;
+ br.right = br.left + active_app_frame().text_font.cell ().cx;
br.top = r.top;
br.bottom = r.bottom;
}
@@ -3315,7 +3323,7 @@ Window::paint_ruler (HDC hdc) const
RECT r;
GetWindowRect (w_hwnd, &r);
- MapWindowPoints (HWND_DESKTOP, app.active_frame.hwnd, (POINT *)&r, 2);
+ MapWindowPoints (HWND_DESKTOP, active_app_frame().active_frame.hwnd, (POINT *)&r, 2);
r.bottom = r.top;
r.top -= RULER_HEIGHT;
draw_hline (hdc, r.left, r.right - 1, r.top, sysdep.btn_highlight);
@@ -3332,7 +3340,7 @@ Window::paint_ruler (HDC hdc) const
else
{
int x = r.left + ((w_ruler_fold_column - w_ruler_top_column)
- * app.text_font.cell ().cx);
+ * active_app_frame().text_font.cell ().cx);
if (x < r.right)
{
fill_rect (hdc, r.left, r.top, x - r.left, r.bottom - r.top, sysdep.window);
@@ -3347,8 +3355,8 @@ Window::paint_ruler (HDC hdc) const
int bkmode = SetBkMode (hdc, TRANSPARENT);
int y = (r.top + r.bottom) / 2;
- for (int x = r.left + app.text_font.cell ().cx / 2, column = w_ruler_top_column + 1;
- x < r.right; x += app.text_font.cell ().cx, column++)
+ for (int x = r.left + active_app_frame().text_font.cell ().cx / 2, column = w_ruler_top_column + 1;
+ x < r.right; x += active_app_frame().text_font.cell ().cx, column++)
paint_ruler (hdc, r, x, y, column);
SetTextColor (hdc, ofg);
@@ -3376,8 +3384,8 @@ Window::erase_ruler (HDC hdc, const RECT &r) const
int bkmode = SetBkMode (hdc, TRANSPARENT);
int y = (r.top + r.bottom) / 2;
- int x = (r.left + app.text_font.cell ().cx / 2
- + (w_ruler_column - w_ruler_top_column) * app.text_font.cell ().cx);
+ int x = (r.left + active_app_frame().text_font.cell ().cx / 2
+ + (w_ruler_column - w_ruler_top_column) * active_app_frame().text_font.cell ().cx);
int column = w_ruler_column + 1;
paint_ruler (hdc, br, x, y, column);
@@ -3385,11 +3393,11 @@ Window::erase_ruler (HDC hdc, const RECT &r) const
if (rem)
{
column -= rem;
- x -= rem * app.text_font.cell ().cx;
+ x -= rem * active_app_frame().text_font.cell ().cx;
if (column && x >= r.left)
paint_ruler (hdc, br, x, y, column);
column += 10;
- x += 10 * app.text_font.cell ().cx;
+ x += 10 * active_app_frame().text_font.cell ().cx;
if (x < r.right)
paint_ruler (hdc, br, x, y, column);
}
@@ -3409,20 +3417,20 @@ Window::update_ruler ()
w_ruler_top_column = w_top_column;
w_ruler_column = w_column;
w_ruler_fold_column = w_bufp->b_fold_columns;
- HDC hdc = GetDC (app.active_frame.hwnd);
+ HDC hdc = GetDC (active_app_frame().active_frame.hwnd);
paint_ruler (hdc);
- ReleaseDC (app.active_frame.hwnd, hdc);
+ ReleaseDC (active_app_frame().active_frame.hwnd, hdc);
}
else if (w_ruler_column != w_column)
{
- HDC hdc = GetDC (app.active_frame.hwnd);
+ HDC hdc = GetDC (active_app_frame().active_frame.hwnd);
RECT r;
calc_ruler_rect (r);
if (w_ruler_column >= 0)
erase_ruler (hdc, r);
w_ruler_column = w_column;
paint_ruler_box (hdc, r);
- ReleaseDC (app.active_frame.hwnd, hdc);
+ ReleaseDC (active_app_frame().active_frame.hwnd, hdc);
}
}
@@ -3447,10 +3455,10 @@ Window::point2window_pos (point_t point, POINT &p) const
if (w_last_flags & Window::WF_LINE_NUMBER)
p.x += Window::LINENUM_COLUMNS + 1;
p.x = min (max (0L, p.x), w_ch_max.cx);
- p.x *= app.text_font.cell ().cx;
- p.x += app.text_font.cell ().cx / 2;
+ p.x *= active_app_frame().text_font.cell ().cx;
+ p.x += active_app_frame().text_font.cell ().cx / 2;
p.y = linenum - w_last_top_linenum;
p.y = min (max (0L, p.y), w_ch_max.cy);
- p.y *= app.text_font.cell ().cy;
+ p.y *= active_app_frame().text_font.cell ().cy;
}
diff --git a/src/Window.h b/src/Window.h
index 8ad40d1..bdaa831 100644
--- a/src/Window.h
+++ b/src/Window.h
@@ -262,6 +262,7 @@ public:
};
struct wheel_info;
+class ApplicationFrame;
struct Window
{
@@ -360,6 +361,8 @@ struct Window
long w_selection_column;
Region w_selection_region;
+ ApplicationFrame *w_owner;
+
Buffer::selection_type w_reverse_temp;
Region w_reverse_region;
@@ -417,11 +420,11 @@ struct Window
void process_hscroll (int);
void wheel_scroll (const wheel_info &);
- Window (int = 0, int = 0);
+ Window (ApplicationFrame *owner, int = 0, int = 0);
Window (const Window &);
void init (int, int);
~Window ();
- static void create_default_windows ();
+ static void create_default_windows (ApplicationFrame *owner);
void save_buffer_params ();
void set_buffer_params (Buffer *);
@@ -473,28 +476,28 @@ struct Window
int caret_line () const
{return w_linenum - w_last_top_linenum;}
static int caret_xpixel (int column)
- {return (column * app.text_font.cell ().cx
- + app.text_font.cell ().cx / 2);}
+ {return (column * active_app_frame().text_font.cell ().cx
+ + active_app_frame().text_font.cell ().cx / 2);}
static int caret_ypixel (int line)
- {return line * app.text_font.cell ().cy;}
+ {return line * active_app_frame().text_font.cell ().cy;}
int caret_x () const
{return caret_xpixel (caret_column ());}
int caret_y () const
{return caret_ypixel (caret_line ());}
void hide_caret () const;
void update_caret () const;
- static void update_last_caret ();
- static void update_caret (HWND, int, int, int, int, COLORREF);
- static void delete_caret ();
- static void compute_geometry (const SIZE & = app.active_frame.size,
- int = app.text_font.cell ().cy);
- static void move_all_windows (int = 1);
- static void repaint_all_windows ();
+ static void update_last_caret (ApplicationFrame *owner);
+ static void update_caret (ApplicationFrame *, HWND, int, int, int, int, COLORREF);
+ static void delete_caret (ApplicationFrame *owner);
+ static void compute_geometry (ApplicationFrame *owner, const SIZE & = active_app_frame().active_frame.size,
+ int = active_app_frame().text_font.cell ().cy);
+ static void move_all_windows (ApplicationFrame *owner, int = 1);
+ static void repaint_all_windows (ApplicationFrame *owner);
static void destroy_windows ();
void split (int, int);
int minibuffer_window_p () const;
- static Window *minibuffer_window ();
+ static Window *minibuffer_window (ApplicationFrame *owner = &active_app_frame());
void delete_other_windows ();
void close ();
static int count_windows ();
@@ -507,8 +510,8 @@ struct Window
};
int find_resizeable_edge (LONG RECT::*, LONG RECT::*, LONG RECT::*, LONG RECT::*) const;
int find_resizeable_edges () const;
- static Window *find_point_window (POINT &p);
- static Window *find_scr_point_window (const POINT &, int, int *);
+ static Window *find_point_window (ApplicationFrame *owner, POINT &p);
+ static Window *find_scr_point_window (ApplicationFrame *owner, const POINT &, int, int *);
void resize_edge (LONG RECT::*, LONG RECT::*, LONG RECT::*, LONG RECT::*) const;
void resize_edge (int) const;
int delete_window ();
@@ -516,7 +519,7 @@ struct Window
void set_window ();
static Window *coerce_to_window (lisp);
- static Window *find_point_window (const POINT &, int &);
+ static Window *find_point_window (ApplicationFrame *owner, const POINT &, int &);
Window *find_resizeable_window (LONG RECT::*, LONG RECT::*, LONG RECT::*, LONG RECT::*, LONG RECT::*) const;
Window *find_horiz_window (LONG RECT::*) const;
Window *find_vert_window (LONG RECT::*) const;
@@ -526,14 +529,14 @@ struct Window
int get_vert_max (int, int) const;
void change_vert_size (int, int, int);
void change_horiz_size (int, int, int);
- static int find_vert_order (int);
- static int find_horiz_order (int);
+ static int find_vert_order (ApplicationFrame*, int);
+ static int find_horiz_order (ApplicationFrame*, int);
int enlarge_window_horiz (int);
int enlarge_window_vert (int);
int enlarge_window (int, int);
- static int frame_window_setcursor (HWND, WPARAM, LPARAM);
- static int frame_window_resize (HWND, LPARAM, const POINT * = 0);
+ static int frame_window_setcursor (ApplicationFrame *owner, HWND, WPARAM, LPARAM);
+ static int frame_window_resize (ApplicationFrame *owner, HWND, LPARAM, const POINT * = 0);
int frame_window_resize (HWND, const POINT &, int);
int redraw_mode_line ();
diff --git a/src/archiver.cc b/src/archiver.cc
index 6211af2..eae19f1 100644
--- a/src/archiver.cc
+++ b/src/archiver.cc
@@ -146,18 +146,18 @@ NotifyWndProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
if (*i->szDestFileName)
{
if (!wparam)
- app.status_window.puts (i->szDestFileName, 1);
+ active_app_frame().status_window.puts (i->szDestFileName, 1);
else if (wparam == 1)
{
sprintf (buf, "%s(%u/%u)...",
i->szDestFileName, i->dwWriteSize, i->dwFileSize);
- app.status_window.puts (buf, 1);
+ active_app_frame().status_window.puts (buf, 1);
}
}
else if (wparam == 4)
{
sprintf (buf, "Updating %s...", i->szSourceFileName);
- app.status_window.puts (buf, 1);
+ active_app_frame().status_window.puts (buf, 1);
}
if (QUITP)
return 1;
@@ -235,7 +235,7 @@ ArchiverP::doit (HWND hwnd, const char *data) const
EnableWindow (hwnd, 1);
#ifdef __XYZZY__
- app.status_window.puts ("done", 1);
+ active_app_frame().status_window.puts ("done", 1);
#endif
#ifdef NEED_EXTRACTINGINFO
diff --git a/src/binfo.cc b/src/binfo.cc
index e8c2ce1..899cead 100644
--- a/src/binfo.cc
+++ b/src/binfo.cc
@@ -147,7 +147,7 @@ buffer_info::ime_mode (char *b, char *be) const
if (!b_ime)
return b;
*b_ime = 1;
- return stpncpy (b, (app.ime_open_mode == kbd_queue::IME_MODE_ON
+ return stpncpy (b, (active_app_frame().ime_open_mode == kbd_queue::IME_MODE_ON
? "あ" : "--"),
be - b);
}
diff --git a/src/buffer-bar.cc b/src/buffer-bar.cc
index d9ed22a..e2737f0 100644
--- a/src/buffer-bar.cc
+++ b/src/buffer-bar.cc
@@ -65,7 +65,7 @@ buffer_bar::notify (NMHDR *nm, LRESULT &result)
case TCN_SELCHANGE:
case TCN_SELCHANGING:
- if (!app.kbdq.idlep ()
+ if (!active_app_frame().kbdq.idlep ()
|| selected_window ()->minibuffer_window_p ())
{
result = 1; // prevent the selection
@@ -127,7 +127,7 @@ buffer_bar::tab_color (const Buffer *bp, COLORREF &fg, COLORREF &bg)
}
else
{
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = active_app_frame().active_frame.windows; wp; wp = wp->w_next)
if (wp->w_bufp == bp)
{
fg = get_misc_color (MC_BUFTAB_DISP_FG);
@@ -197,11 +197,11 @@ buffer_bar::make_instance ()
{
if (!b_bar)
{
- b_bar = new buffer_bar (g_frame);
- if (!b_bar->create (app.toplev))
+ b_bar = new buffer_bar (active_main_frame());
+ if (!b_bar->create (active_app_frame().toplev))
return 0;
b_bar->insert_buffers ();
- g_frame.add (b_bar);
+ active_main_frame().add (b_bar);
}
return 1;
}
@@ -402,7 +402,7 @@ buffer_bar::wndproc (UINT msg, WPARAM wparam, LPARAM lparam)
KillTimer (b_hwnd, DROP_TIMER_ID);
b_drop_index = -1;
if (index >= 0
- && (app.drag_window || app.kbdq.idlep ())
+ && (active_app_frame().drag_window || active_app_frame().kbdq.idlep ())
&& !selected_window ()->minibuffer_window_p ())
{
Buffer *bp = nth (index);
diff --git a/src/colors.cc b/src/colors.cc
index ef4d129..455e057 100644
--- a/src/colors.cc
+++ b/src/colors.cc
@@ -80,5 +80,5 @@ modify_misc_colors (const XCOLORREF *colors, int save)
}
Filer::modify_colors ();
- g_frame.color_changed ();
+ active_main_frame().color_changed ();
}
diff --git a/src/conf.cc b/src/conf.cc
index 88006a7..dea2500 100644
--- a/src/conf.cc
+++ b/src/conf.cc
@@ -8,7 +8,7 @@
void
write_conf (const char *section, const char *name, const char *str)
{
- WritePrivateProfileString (section, name, str, app.ini_file_path);
+ WritePrivateProfileString (section, name, str, g_app.ini_file_path);
}
void
@@ -16,7 +16,7 @@ write_conf (const char *section, const char *name, long value, int hex)
{
char buf[32];
sprintf (buf, hex ? "#%lx" : "%ld", value);
- WritePrivateProfileString (section, name, buf, app.ini_file_path);
+ WritePrivateProfileString (section, name, buf, g_app.ini_file_path);
}
void
@@ -25,7 +25,7 @@ write_conf (const char *section, const char *name, const int *value, int n, int
char *buf = (char *)alloca (16 * n), *b = buf;
for (int i = 0; i < n; i++)
b += sprintf (b, hex ? ",#%x" : ",%d", *value++);
- WritePrivateProfileString (section, name, buf + 1, app.ini_file_path);
+ WritePrivateProfileString (section, name, buf + 1, g_app.ini_file_path);
}
void
@@ -33,7 +33,7 @@ write_conf (const char *section, const char *name, const RECT &r)
{
char buf[128];
sprintf (buf, "(%d,%d)-(%d,%d)", r.left, r.top, r.right, r.bottom);
- WritePrivateProfileString (section, name, buf, app.ini_file_path);
+ WritePrivateProfileString (section, name, buf, g_app.ini_file_path);
}
void
@@ -41,7 +41,7 @@ write_conf (const char *section, const char *name, const LOGFONT &lf)
{
char buf[128];
sprintf (buf, "%d,\"%s\",%d", lf.lfHeight, lf.lfFaceName, lf.lfCharSet);
- WritePrivateProfileString (section, name, buf, app.ini_file_path);
+ WritePrivateProfileString (section, name, buf, g_app.ini_file_path);
}
void
@@ -49,7 +49,7 @@ write_conf (const char *section, const char *name, const PRLOGFONT &lf)
{
char buf[128];
sprintf (buf, "%d,\"%s\",%d,%d,%d", lf.point, lf.face, lf.charset, lf.bold, lf.italic);
- WritePrivateProfileString (section, name, buf, app.ini_file_path);
+ WritePrivateProfileString (section, name, buf, g_app.ini_file_path);
}
void
@@ -62,25 +62,25 @@ write_conf (const char *section, const char *name, const WINDOWPLACEMENT &w)
w.rcNormalPosition.right,
w.rcNormalPosition.bottom,
w.showCmd);
- WritePrivateProfileString (section, name, buf, app.ini_file_path);
+ WritePrivateProfileString (section, name, buf, g_app.ini_file_path);
}
void
flush_conf ()
{
- WritePrivateProfileString (0, 0, 0, app.ini_file_path);
+ WritePrivateProfileString (0, 0, 0, g_app.ini_file_path);
}
int
read_conf (const char *section, const char *name, char *buf, int size)
{
- return GetPrivateProfileString (section, name, "", buf, size, app.ini_file_path);
+ return GetPrivateProfileString (section, name, "", buf, size, g_app.ini_file_path);
}
void
delete_conf (const char *section)
{
- WritePrivateProfileString (section, 0, 0, app.ini_file_path);
+ WritePrivateProfileString (section, 0, 0, g_app.ini_file_path);
}
static int
diff --git a/src/data.cc b/src/data.cc
index 0b6d778..6311579 100644
--- a/src/data.cc
+++ b/src/data.cc
@@ -584,6 +584,7 @@ gc_mark_object (lisp object)
case Trandom_state:
case Twindow:
+ case Tappframe:
case Tbuffer:
case Tsyntax_table:
case Tmarker:
@@ -776,7 +777,7 @@ gc_mark_in_stack ()
setjmp (regs);
int tem = 0;
- lisp *beg = (lisp *)&tem, *end = (lisp *)app.initial_stack;
+ lisp *beg = (lisp *)&tem, *end = (lisp *)g_app.initial_stack;
for (; beg < end; beg++)
{
lisp p = *beg;
@@ -797,6 +798,8 @@ gc_mark_in_stack ()
}
}
+extern void app_frame_gc_mark(void (*f)(lisp));
+
void
gc_mark_object ()
{
@@ -849,13 +852,6 @@ gc_mark_object ()
gc_mark_object (lp->lex_frame);
}
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
- gc_mark_object (wp->lwp);
- for (wp = app.active_frame.reserved; wp; wp = wp->w_next)
- gc_mark_object (wp->lwp);
- for (wp = app.active_frame.deleted; wp; wp = wp->w_next)
- gc_mark_object (wp->lwp);
-
for (Buffer *bp = Buffer::b_blist; bp; bp = bp->b_next)
{
for (lisp *x = &bp->Buffer_gc_start; x <= &bp->Buffer_gc_end; x++)
@@ -866,8 +862,7 @@ gc_mark_object ()
toplev_gc_mark (gc_mark_object);
process_gc_mark (gc_mark_object);
- g_frame.gc_mark (gc_mark_object);
- app.user_timer.gc_mark (gc_mark_object);
+ app_frame_gc_mark(gc_mark_object);
gc_mark_in_stack ();
@@ -884,14 +879,14 @@ gc (int nomsg)
if (suppress_gc::gc_suppressed_p ())
return;
- app.in_gc = 1;
+ g_app.in_gc = 1;
if (nomsg < 0)
nomsg = xsymbol_value (Vgarbage_collection_messages) == Qnil;
int msglen = 0;
if (!nomsg)
- msglen = app.status_window.text (get_message_string (Mgarbage_collecting));
+ msglen = active_app_frame().status_window.text (get_message_string (Mgarbage_collecting));
ldataP::ld_nwasted = 0;
gc_mark_object ();
@@ -911,13 +906,13 @@ gc (int nomsg)
if (!nomsg)
{
if (msglen)
- app.status_window.restore ();
+ active_app_frame().status_window.restore ();
else
- app.status_window.text (get_message_string (Mgarbage_collecting_done));
+ active_app_frame().status_window.text (get_message_string (Mgarbage_collecting_done));
}
_heapmin ();
- app.in_gc = 0;
+ g_app.in_gc = 0;
}
lisp
@@ -2102,6 +2097,21 @@ rdump_object (FILE *fp, lwindow *d, int n,
}
static inline void
+dump_object (FILE *, const lappframe *, int,
+ const u_long [LDATA_MAX_OBJECTS_PER_LONG])
+{
+}
+
+static void
+rdump_object (FILE *fp, lappframe *d, int n,
+ const u_long used[LDATA_MAX_OBJECTS_PER_LONG])
+{
+ for (lappframe *de = d + n; d < de; d++)
+ if (bitisset (used, bit_index (d)))
+ d->fp = 0;
+}
+
+static inline void
dump_object (FILE *, const lbuffer *, int,
const u_long [LDATA_MAX_OBJECTS_PER_LONG])
{
@@ -2670,7 +2680,7 @@ Fdump_xyzzy (lisp filename)
if (!filename || filename == Qnil)
{
filename = xsymbol_value (Qdump_image_path);
- path = app.dump_image;
+ path = g_app.dump_image;
}
else
{
@@ -2786,7 +2796,7 @@ static int dump_flag;
int
rdump_xyzzy ()
{
- FILE *fp = _fsopen (app.dump_image, "rb", _SH_DENYWR);
+ FILE *fp = _fsopen (g_app.dump_image, "rb", _SH_DENYWR);
if (!fp)
return 0;
diff --git a/src/dataP.h b/src/dataP.h
index 686ac17..576492c 100644
--- a/src/dataP.h
+++ b/src/dataP.h
@@ -31,6 +31,7 @@ DECLARE_LDATA (lstruct_def, Tstruct_def)
DECLARE_LDATA (lstruct_data, Tstruct_data)
DECLARE_LDATA (lreadtable, Treadtable)
DECLARE_LDATA (lwindow, Twindow)
+DECLARE_LDATA (lappframe, Tappframe)
DECLARE_LDATA (lbuffer, Tbuffer)
DECLARE_LDATA (lsyntax_table, Tsyntax_table)
DECLARE_LDATA (lmarker, Tmarker)
diff --git a/src/dialogs.cc b/src/dialogs.cc
index f7c3f9b..d2126cb 100644
--- a/src/dialogs.cc
+++ b/src/dialogs.cc
@@ -11,7 +11,7 @@ void
set_window_icon (HWND hwnd)
{
SendMessage (hwnd, WM_SETICON, 1,
- LPARAM (LoadIcon (app.hinst, MAKEINTRESOURCE (IDI_XYZZY))));
+ LPARAM (LoadIcon (active_app_frame().hinst, MAKEINTRESOURCE (IDI_XYZZY))));
}
void
@@ -21,7 +21,7 @@ center_window (HWND hwnd)
if (!owner)
owner = GetParent (hwnd);
if (!owner)
- owner = app.toplev;
+ owner = active_app_frame().toplev;
RECT dr, or;
GetWindowRect (hwnd, &dr);
@@ -57,7 +57,7 @@ init_list_column (HWND list, int ncolumns, const int *width, const int *fmts,
{
char buf[64];
lvc.cx = width[i];
- LoadString (app.hinst, id_start + i, buf, sizeof buf);
+ LoadString (active_app_frame().hinst, id_start + i, buf, sizeof buf);
lvc.pszText = buf;
lvc.iSubItem = i;
lvc.fmt = fmts[i];
@@ -108,7 +108,7 @@ buffer_list_init_column (HWND list)
init_list_column (list, 4, width, fmts, IDS_SELECT_BUFFER1,
cfgBufferSelector, cfgColumn);
- HIMAGELIST hil = ImageList_LoadBitmap (app.hinst,
+ HIMAGELIST hil = ImageList_LoadBitmap (active_app_frame().hinst,
MAKEINTRESOURCE (IDB_BUFSEL),
17, 1, RGB (255, 255, 255));
ListView_SetImageList (list, hil, LVSIL_SMALL);
@@ -395,7 +395,7 @@ select_buffer_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
return 1;
case WM_ACTIVATEAPP:
- PostThreadMessage (app.quit_thread_id, WM_PRIVATE_ACTIVATEAPP,
+ PostThreadMessage (active_app_frame().quit_thread_id, WM_PRIVATE_ACTIVATEAPP,
wparam, lparam);
return 0;
@@ -429,7 +429,7 @@ lisp
Fbuffer_selector ()
{
Buffer *bp = 0;
- int r = DialogBoxParam (app.hinst, MAKEINTRESOURCE (IDD_SELECT_BUFFER),
+ int r = DialogBoxParam (active_app_frame().hinst, MAKEINTRESOURCE (IDD_SELECT_BUFFER),
get_active_window (), select_buffer_proc, LPARAM (&bp));
Fdo_events ();
if (r != IDOK)
@@ -512,7 +512,7 @@ OFN::init_eol_list ()
if (!ofn_save || eol_list[i].id != IDS_EOL_AUTO)
{
char b[64];
- LoadString (app.hinst, eol_list[i].id, b, sizeof b);
+ LoadString (active_app_frame().hinst, eol_list[i].id, b, sizeof b);
int j = SendDlgItemMessage (ofn_hwnd, IDC_EOL_CODE, CB_ADDSTRING, 0, LPARAM (b));
if (j != CB_ERR)
{
@@ -776,7 +776,7 @@ Ffile_name_dialog (lisp keys)
? OPENFILENAME_SIZE_VERSION_500
: OPENFILENAME_SIZE_VERSION_400);
ofn.hwndOwner = get_active_window ();
- ofn.hInstance = app.hinst;
+ ofn.hInstance = active_app_frame().hinst;
ofn.lCustData = DWORD (&ofn);
char buf[1024 * 32];
@@ -887,7 +887,7 @@ Ffile_name_dialog (lisp keys)
if (!ofn.lpstrTitle && save)
{
title = (char *)alloca (256);
- LoadString (app.hinst, IDS_SAVE_AS, title, 256);
+ LoadString (active_app_frame().hinst, IDS_SAVE_AS, title, 256);
ofn.lpstrTitle = title;
}
}
@@ -1091,7 +1091,7 @@ Fdirectory_name_dialog (lisp keys)
odn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
odn.hwndOwner = get_active_window ();
- odn.hInstance = app.hinst;
+ odn.hInstance = active_app_frame().hinst;
char buf[PATH_MAX];
strcpy (buf, "FOO");
@@ -1214,7 +1214,7 @@ IdleDialog::DoModal (HWND owner, UINT id)
enable_owner = 1;
}
- id_hwnd = CreateDialogParam (app.hinst, MAKEINTRESOURCE (id), owner,
+ id_hwnd = CreateDialogParam (active_app_frame().hinst, MAKEINTRESOURCE (id), owner,
WndProc, LPARAM (this));
if (id_hwnd)
{
@@ -1239,7 +1239,7 @@ int
IdleDialog::Create (HWND owner, UINT id)
{
id_modeless = 1;
- id_hwnd = CreateDialogParam (app.hinst, MAKEINTRESOURCE (id), owner,
+ id_hwnd = CreateDialogParam (active_app_frame().hinst, MAKEINTRESOURCE (id), owner,
WndProc, LPARAM (this));
if (!id_hwnd)
return 0;
@@ -1348,7 +1348,7 @@ DriveDialog::setup_list (HWND hwnd)
ListView_InsertColumn (hwnd, i, &lvc);
}
- HIMAGELIST hil = ImageList_LoadBitmap (app.hinst,
+ HIMAGELIST hil = ImageList_LoadBitmap (active_app_frame().hinst,
MAKEINTRESOURCE (IDB_FILESEL),
16, 1, RGB (0, 0, 255));
ListView_SetImageList (hwnd, hil, LVSIL_SMALL);
@@ -1543,7 +1543,7 @@ DriveDialog::WndProc (UINT msg, WPARAM wparam, LPARAM lparam)
return 1;
case WM_ACTIVATEAPP:
- PostThreadMessage (app.quit_thread_id, WM_PRIVATE_ACTIVATEAPP,
+ PostThreadMessage (active_app_frame().quit_thread_id, WM_PRIVATE_ACTIVATEAPP,
wparam, lparam);
return 0;
diff --git a/src/disp.cc b/src/disp.cc
index 3df4090..4db46e8 100644
--- a/src/disp.cc
+++ b/src/disp.cc
@@ -133,7 +133,7 @@ calc_caret_shape (SIZE &size, int ovwrt, int dbcp, int selection)
if (selection)
{
size.cx = 2 * sysdep.border.cx;
- size.cy = app.text_font.size ().cy;
+ size.cy = active_app_frame().text_font.size ().cy;
}
else
{
@@ -149,16 +149,16 @@ calc_caret_shape (SIZE &size, int ovwrt, int dbcp, int selection)
{
case CARET_SHAPE_THIN:
size.cx = 2 * sysdep.border.cx;
- size.cy = app.text_font.size ().cy;
+ size.cy = active_app_frame().text_font.size ().cy;
break;
default:
case CARET_SHAPE_BLOCK:
- size.cy = app.text_font.size ().cy;
+ size.cy = active_app_frame().text_font.size ().cy;
goto width;
case CARET_SHAPE_HALF:
- size.cy = app.text_font.size ().cy / 2;
+ size.cy = active_app_frame().text_font.size ().cy / 2;
goto width;
case CARET_SHAPE_UNDERLINE:
@@ -166,7 +166,7 @@ calc_caret_shape (SIZE &size, int ovwrt, int dbcp, int selection)
goto width;
width:
- size.cx = app.text_font.cell ().cx;
+ size.cx = active_app_frame().text_font.cell ().cx;
if (dbcp)
size.cx *= 2;
break;
@@ -189,86 +189,86 @@ Window::caret_size (SIZE &size) const
&& w_point.p_point < w_selection_marker)
: (w_point.p_point >= w_selection_marker
&& w_point.p_point < w_selection_point))))
- || app.f_in_drop));
+ || w_owner->f_in_drop));
}
void
Window::hide_caret () const
{
- if (app.active_frame.has_caret == w_hwnd && app.active_frame.caret_on)
+ if (w_owner->active_frame.has_caret == w_hwnd && w_owner->active_frame.caret_on)
{
HideCaret (w_hwnd);
- app.active_frame.caret_on = 0;
+ w_owner->active_frame.caret_on = 0;
}
}
void
-Window::delete_caret ()
+Window::delete_caret (ApplicationFrame *app1)
{
- if (app.active_frame.has_caret)
+ if (app1->active_frame.has_caret)
{
xcaret.destroy ();
- app.active_frame.caret_on = 0;
- app.active_frame.has_caret = 0;
+ app1->active_frame.caret_on = 0;
+ app1->active_frame.has_caret = 0;
}
}
void
-Window::update_last_caret ()
+Window::update_last_caret (ApplicationFrame *owner)
{
- if (app.active_frame.windows)
+ if (owner->active_frame.windows)
{
- if (selected_window ())
- selected_window ()->update_caret ();
- Window *mini = Window::minibuffer_window ();
- if (mini && mini != selected_window ())
+ if (selected_window (owner))
+ selected_window (owner)->update_caret ();
+ Window *mini = Window::minibuffer_window (owner);
+ if (mini && mini != selected_window (owner))
mini->update_caret ();
}
}
void
-Window::update_caret (HWND hwnd, int x, int y, int w, int h, COLORREF cc)
+Window::update_caret (ApplicationFrame *app1, HWND hwnd, int x, int y, int w, int h, COLORREF cc)
{
- int gray_caret = app.f_in_drop;
- if (!app.ime_composition
- && app.last_blink_caret != (xsymbol_value (Vblink_caret) != Qnil))
+ int gray_caret = app1->f_in_drop;
+ if (!app1->ime_composition
+ && app1->last_blink_caret != (xsymbol_value (Vblink_caret) != Qnil))
{
- app.last_blink_caret = xsymbol_value (Vblink_caret) != Qnil;
- if (app.last_blink_caret)
- restore_caret_blink_time ();
+ app1->last_blink_caret = xsymbol_value (Vblink_caret) != Qnil;
+ if (app1->last_blink_caret)
+ restore_caret_blink_time (app1);
else
- set_caret_blink_time ();
+ set_caret_blink_time (app1);
}
- if (!app.active_frame.has_caret)
+ if (!app1->active_frame.has_caret)
{
- app.active_frame.has_caret = hwnd;
+ app1->active_frame.has_caret = hwnd;
xcaret.create (hwnd, gray_caret ? HBITMAP (1) : 0, w, h, cc);
ShowCaret (hwnd);
}
- else if (app.active_frame.has_caret != hwnd
- || w != app.active_frame.caret_size.cx
- || h != app.active_frame.caret_size.cy
- || cc != app.active_frame.last_caret_color
- || app.active_frame.gray_caret != gray_caret)
+ else if (app1->active_frame.has_caret != hwnd
+ || w != app1->active_frame.caret_size.cx
+ || h != app1->active_frame.caret_size.cy
+ || cc != app1->active_frame.last_caret_color
+ || app1->active_frame.gray_caret != gray_caret)
{
- app.active_frame.has_caret = hwnd;
+ app1->active_frame.has_caret = hwnd;
xcaret.destroy ();
xcaret.create (hwnd, gray_caret ? HBITMAP (1) : 0, w, h, cc);
ShowCaret (hwnd);
}
- else if (!app.active_frame.caret_on)
+ else if (!app1->active_frame.caret_on)
ShowCaret (hwnd);
- app.active_frame.has_caret_last = hwnd;
- app.active_frame.last_caret_color = cc;
- app.active_frame.caret_on = 1;
- app.active_frame.caret_size.cx = w;
- app.active_frame.caret_size.cy = h;
- app.active_frame.caret_pos.x = x;
- app.active_frame.caret_pos.y = y;
- app.active_frame.gray_caret = gray_caret;
- SetCaretPos (app.active_frame.caret_pos.x,
- app.active_frame.caret_pos.y + app.text_font.size ().cy - h);
- set_ime_caret ();
+ app1->active_frame.has_caret_last = hwnd;
+ app1->active_frame.last_caret_color = cc;
+ app1->active_frame.caret_on = 1;
+ app1->active_frame.caret_size.cx = w;
+ app1->active_frame.caret_size.cy = h;
+ app1->active_frame.caret_pos.x = x;
+ app1->active_frame.caret_pos.y = y;
+ app1->active_frame.gray_caret = gray_caret;
+ SetCaretPos (app1->active_frame.caret_pos.x,
+ app1->active_frame.caret_pos.y + app1->text_font.size ().cy - h);
+ set_ime_caret (app1);
}
void
@@ -276,28 +276,28 @@ Window::update_caret () const
{
int show, prompt = 0;
- if (app.f_in_drop)
- show = w_bufp && app.drop_window == this;
- else if (!app.active_frame.has_focus)
+ if (w_owner->f_in_drop)
+ show = w_bufp && w_owner->drop_window == this;
+ else if (!w_owner->active_frame.has_focus)
show = 0;
else if (stringp (xsymbol_value (Vminibuffer_message))
&& xsymbol_value (Vminibuffer_prompt) != Qnil
- && app.minibuffer_prompt_column >= 0)
+ && w_owner->minibuffer_prompt_column >= 0)
{
show = minibuffer_window_p ();
prompt = 1;
}
else
- show = w_bufp && selected_window () == this;
+ show = w_bufp && selected_window (w_owner) == this;
if (!show)
{
- if (app.active_frame.has_caret == w_hwnd)
- delete_caret ();
+ if (w_owner->active_frame.has_caret == w_hwnd)
+ delete_caret (w_owner);
}
else
{
- COLORREF cc = (app.ime_open_mode == kbd_queue::IME_MODE_ON
+ COLORREF cc = (w_owner->ime_open_mode == kbd_queue::IME_MODE_ON
? w_colors[WCOLOR_IMECARET]
: w_colors[WCOLOR_CARET]);
COLORREF bg = w_colors[WCOLOR_BACK];
@@ -306,7 +306,7 @@ Window::update_caret () const
if (prompt)
{
calc_caret_shape (sz, 0, 0, 0);
- x = app.minibuffer_prompt_column - 1;
+ x = w_owner->minibuffer_prompt_column - 1;
y = 0;
}
else
@@ -340,7 +340,7 @@ Window::update_caret () const
cc = GetNearestColor (hdc, cc);
ReleaseDC (w_hwnd, hdc);
- update_caret (w_hwnd, caret_xpixel (x), caret_ypixel (y),
+ update_caret (w_owner, w_hwnd, caret_xpixel (x), caret_ypixel (y),
sz.cx, sz.cy, cc);
}
}
@@ -353,7 +353,7 @@ class paint_chars_ctx
const int p_cellw;
public:
paint_chars_ctx (int x, int y, const RECT &r, int w)
- : p_x (x), p_y (y), p_cellw (w * app.text_font.cell ().cx)
+ : p_x (x), p_y (y), p_cellw (w * active_app_frame().text_font.cell ().cx)
{
p_r.left = r.left;
p_r.top = r.top;
@@ -373,9 +373,9 @@ public:
void
paint_chars_ctx::paint_lucida (HDC hdc, ucs2_t wc, int flags)
{
- const FontObject &f = app.text_font.font (FONT_ASCII);
+ const FontObject &f = active_app_frame().text_font.font (FONT_ASCII);
int o = (LUCIDA_OFFSET (wc - UNICODE_SMLCDM_MIN) * f.size ().cy / LUCIDA_BASE_HEIGHT
- + app.text_font.cell ().cx / 2);
+ + active_app_frame().text_font.cell ().cx / 2);
p_r.right = min (int (p_r.left + p_cellw), p_right);
ExtTextOutW (hdc, p_x + o, p_y, flags, &p_r, &wc, 1, 0);
p_r.left = p_r.right;
@@ -386,7 +386,7 @@ static inline void
paint_ascii_chars (HDC hdc, int x, int y, int flags, const RECT &r,
const char *string, int len, const INT *padding)
{
- const FontObject &f = app.text_font.font (FONT_ASCII);
+ const FontObject &f = active_app_frame().text_font.font (FONT_ASCII);
ExtTextOut (hdc, x + f.offset ().x, y + f.offset ().y, flags,
&r, string, len, f.need_pad_p () ? padding : 0);
}
@@ -395,7 +395,7 @@ static inline void
paint_jp_chars (HDC hdc, int x, int y, int flags, const RECT &r,
const char *string, int len, const INT *padding)
{
- const FontObject &f = app.text_font.font (FONT_JP);
+ const FontObject &f = active_app_frame().text_font.font (FONT_JP);
HGDIOBJ of = SelectObject (hdc, f);
ExtTextOut (hdc, x + f.offset ().x, y + f.offset ().y, flags,
&r, string, len, f.need_pad_p () ? padding : 0);
@@ -429,7 +429,7 @@ static inline void
paint_jisx0212_half_width_chars (HDC hdc, int x, int y, int flags, const RECT &r,
const char *string, int len, const INT *padding)
{
- const FontObject &f = app.text_font.font (FONT_JP);
+ const FontObject &f = active_app_frame().text_font.font (FONT_JP);
HGDIOBJ of = SelectObject (hdc, f);
paint_chars_ctx ctx (x + f.offset ().x, y + f.offset ().y, r, 1);
for (const u_char *s = (const u_char *)string, *const se = s + len; s < se; s++)
@@ -442,7 +442,7 @@ paint_chars_lucida (HDC hdc, int x, int y, int flags, const RECT &r,
const char *string, int len, const INT *padding, int c)
{
static LOGFONT lf = {0,0,0,0,0,0,0,0,0,0,0,0,0,LUCIDA_FACE_NAME};
- lf.lfHeight = app.text_font.font (FONT_ASCII).size ().cy;
+ lf.lfHeight = active_app_frame().text_font.font (FONT_ASCII).size ().cy;
HGDIOBJ of = SelectObject (hdc, CreateFontIndirect (&lf));
paint_chars_ctx ctx (x, y, r, 1);
for (const u_char *s = (const u_char *)string, *const se = s + len; s < se; s++)
@@ -455,10 +455,10 @@ paint_chars (HDC hdc, int x, int y, int flags, const RECT &r,
glyph_t charset, const char *string, int len, const INT *padding)
{
#define PAINT_FULL_WIDTH_CHARS(FONT) \
- paint_full_width_chars (hdc, x, y, flags, r, string, len, app.text_font.font (FONT))
+ paint_full_width_chars (hdc, x, y, flags, r, string, len, active_app_frame().text_font.font (FONT))
#define PAINT_HALF_WIDTH_CHARS(OFFSET, FONT) \
paint_half_width_chars (hdc, x, y, flags, r, string, len, padding, \
- OFFSET, app.text_font.font (FONT))
+ OFFSET, active_app_frame().text_font.font (FONT))
#define PAINT_JISX0212_HALF_WIDTH_CHARS() \
paint_jisx0212_half_width_chars (hdc, x, y, flags, r, string, len, padding)
#define PAINT_CHARS_LUCIDA(OFFSET) \
@@ -568,7 +568,7 @@ Window::paint_glyphs (HDC hdc, HDC hdcmem, const glyph_t *gstart, const glyph_t
{
RECT r;
r.top = y + yoffset;
- r.bottom = y + app.text_font.cell ().cy;
+ r.bottom = y + w_owner->text_font.cell ().cy;
r.right = x;
glyph_t gsum = 0;
const glyph_t *gfrom = g;
@@ -588,7 +588,7 @@ Window::paint_glyphs (HDC hdc, HDC hdcmem, const glyph_t *gstart, const glyph_t
}
r.left = r.right;
- r.right += (be - buf) * app.text_font.cell ().cx;
+ r.right += (be - buf) * w_owner->text_font.cell ().cx;
if (r.right > w_clsize.cx)
{
r.right = w_clsize.cx;
@@ -614,20 +614,20 @@ Window::paint_glyphs (HDC hdc, HDC hdcmem, const glyph_t *gstart, const glyph_t
if (c & GLYPH_BITMAP_BIT)
{
- int x = r.left + (b - buf) * app.text_font.cell ().cx;
- for (; b < be; b++, x += app.text_font.cell ().cx)
+ int x = r.left + (b - buf) * w_owner->text_font.cell ().cx;
+ for (; b < be; b++, x += w_owner->text_font.cell ().cx)
{
int w = w_clsize.cx - x;
if (w <= 0)
break;
- if (w > app.text_font.cell ().cx)
- w = app.text_font.cell ().cx;
- BitBlt (hdc, x, r.top, w, app.text_font.cell ().cy,
- hdcmem, app.text_font.cell ().cx * (*b & 0xff), yoffset, SRCCOPY);
+ if (w > w_owner->text_font.cell ().cx)
+ w = w_owner->text_font.cell ().cx;
+ BitBlt (hdc, x, r.top, w, w_owner->text_font.cell ().cy,
+ hdcmem, w_owner->text_font.cell ().cx * (*b & 0xff), yoffset, SRCCOPY);
}
}
else
- paint_chars (hdc, r.left + (b - buf) * app.text_font.cell ().cx, y,
+ paint_chars (hdc, r.left + (b - buf) * w_owner->text_font.cell ().cx, y,
ETO_OPAQUE | ETO_CLIPPED, r, GLYPH_CHARSET (c), b, be - b, padding);
SetTextColor (hdc, ofg);
@@ -663,8 +663,8 @@ Window::paint_glyphs (HDC hdc, HDC hdcmem, const glyph_t *gstart, const glyph_t
COLORREF ofg = SetTextColor (hdc, glyph_forecolor (c0));
- r.left = x + (g0 - gfrom) * app.text_font.cell ().cx + 1;
- r.right = x + (g - gfrom) * app.text_font.cell ().cx + 1;
+ r.left = x + (g0 - gfrom) * w_owner->text_font.cell ().cx + 1;
+ r.right = x + (g - gfrom) * w_owner->text_font.cell ().cx + 1;
if (r.right > w_clsize.cx)
{
r.right = w_clsize.cx;
@@ -676,16 +676,16 @@ Window::paint_glyphs (HDC hdc, HDC hdcmem, const glyph_t *gstart, const glyph_t
{
COLORREF obg = SetBkColor (hdc, glyph_backcolor (c0));
char *b = buf;
- for (int x = r.left; b < be; b++, x += app.text_font.cell ().cx)
+ for (int x = r.left; b < be; b++, x += w_owner->text_font.cell ().cx)
if ((*b & 0xff) == FontSet::backsl)
{
int w = w_clsize.cx - x;
if (w <= 0)
break;
- if (w > app.text_font.cell ().cx)
- w = app.text_font.cell ().cx;
- BitBlt (hdc, x, r.top, w, app.text_font.cell ().cy,
- hdcmem, app.text_font.cell ().cx * FontSet::bold_backsl, yoffset, SRCCOPY);
+ if (w > w_owner->text_font.cell ().cx)
+ w = w_owner->text_font.cell ().cx;
+ BitBlt (hdc, x, r.top, w, w_owner->text_font.cell ().cy,
+ hdcmem, w_owner->text_font.cell ().cx * FontSet::bold_backsl, yoffset, SRCCOPY);
}
SetBkColor (hdc, obg);
}
@@ -713,8 +713,8 @@ Window::paint_glyphs (HDC hdc, HDC hdcmem, const glyph_t *gstart, const glyph_t
;
COLORREF obg = SetBkColor (hdc, glyph_forecolor (c));
- r.left = x + (g0 - gfrom) * app.text_font.cell ().cx;
- r.right = x + (g - gfrom) * app.text_font.cell ().cx;
+ r.left = x + (g0 - gfrom) * w_owner->text_font.cell ().cx;
+ r.right = x + (g - gfrom) * w_owner->text_font.cell ().cx;
if (r.right > w_clsize.cx)
{
r.right = w_clsize.cx;
@@ -724,14 +724,14 @@ Window::paint_glyphs (HDC hdc, HDC hdcmem, const glyph_t *gstart, const glyph_t
if (c & GLYPH_UNDERLINE)
{
- r.bottom = y + app.text_font.size ().cy;
- r.top = r.bottom - app.text_font.line_width ();
+ r.bottom = y + w_owner->text_font.size ().cy;
+ r.top = r.bottom - w_owner->text_font.line_width ();
ExtTextOut (hdc, r.left, r.top, ETO_OPAQUE, &r, "", 0, 0);
}
if (!yoffset && c & GLYPH_STRIKEOUT)
{
- r.top = y + app.text_font.size ().cy / 2;
- r.bottom = r.top + app.text_font.line_width ();
+ r.top = y + w_owner->text_font.size ().cy / 2;
+ r.bottom = r.top + w_owner->text_font.line_width ();
ExtTextOut (hdc, r.left, r.top, ETO_OPAQUE, &r, "", 0, 0);
}
@@ -776,8 +776,8 @@ Window::paint_line (HDC hdc, HDC hdcmem, glyph_data *ogd, const glyph_data *ngd,
n++, o++;
}
else
- PatBlt (hdc, ((ogd->gd_len - 1) * app.text_font.cell ().cx + app.text_font.cell ().cx / 2), y,
- app.text_font.cell ().cx, app.text_font.cell ().cy, PATCOPY);
+ PatBlt (hdc, ((ogd->gd_len - 1) * w_owner->text_font.cell ().cx + w_owner->text_font.cell ().cx / 2), y,
+ w_owner->text_font.cell ().cx, w_owner->text_font.cell ().cy, PATCOPY);
}
const glyph_t *nls = n;
@@ -788,8 +788,8 @@ Window::paint_line (HDC hdc, HDC hdcmem, glyph_data *ogd, const glyph_data *ngd,
if (!dl)
{
paint_glyphs (hdc, hdcmem, ngd->gd_cc, nfd, nls, buf, padding,
- ((nfd - ngd->gd_cc - 1) * app.text_font.cell ().cx
- + app.text_font.cell ().cx / 2),
+ ((nfd - ngd->gd_cc - 1) * w_owner->text_font.cell ().cx
+ + w_owner->text_font.cell ().cx / 2),
y, 0);
for (o = ofd, n = nfd; n < nls;)
*o++ = *n++;
@@ -799,28 +799,28 @@ Window::paint_line (HDC hdc, HDC hdcmem, glyph_data *ogd, const glyph_data *ngd,
if (ogd->gd_len - (ols - ogd->gd_cc) <= 3)
{
paint_glyphs (hdc, hdcmem, ngd->gd_cc, nfd, ne, buf, padding,
- ((nfd - ngd->gd_cc - 1) * app.text_font.cell ().cx
- + app.text_font.cell ().cx / 2),
+ ((nfd - ngd->gd_cc - 1) * w_owner->text_font.cell ().cx
+ + w_owner->text_font.cell ().cx / 2),
y, 0);
if (dl < 0 && ogd->gd_len > ngd->gd_len)
PatBlt (hdc,
- ((ngd->gd_len - 1) * app.text_font.cell ().cx
- + app.text_font.cell ().cx / 2),
+ ((ngd->gd_len - 1) * w_owner->text_font.cell ().cx
+ + w_owner->text_font.cell ().cx / 2),
y,
- (ogd->gd_len - ngd->gd_len) * app.text_font.cell ().cx,
- app.text_font.cell ().cy,
+ (ogd->gd_len - ngd->gd_len) * w_owner->text_font.cell ().cx,
+ w_owner->text_font.cell ().cy,
PATCOPY);
}
else
{
RECT r;
r.top = y;
- r.bottom = y + app.text_font.cell ().cy;
- r.left = ((ols - ogd->gd_cc - 1) * app.text_font.cell ().cx
- + app.text_font.cell ().cx / 2);
- r.right = ((ogd->gd_len - 1) * app.text_font.cell ().cx
- + app.text_font.cell ().cx / 2);
- int dx = dl * app.text_font.cell ().cx;
+ r.bottom = y + w_owner->text_font.cell ().cy;
+ r.left = ((ols - ogd->gd_cc - 1) * w_owner->text_font.cell ().cx
+ + w_owner->text_font.cell ().cx / 2);
+ r.right = ((ogd->gd_len - 1) * w_owner->text_font.cell ().cx
+ + w_owner->text_font.cell ().cx / 2);
+ int dx = dl * w_owner->text_font.cell ().cx;
if (r.right + dx > w_clsize.cx)
{
r.right = w_clsize.cx - dx;
@@ -831,8 +831,8 @@ Window::paint_line (HDC hdc, HDC hdcmem, glyph_data *ogd, const glyph_data *ngd,
{
if (r.right > w_clsize.cx)
{
- int x = ((w_clsize.cx + app.text_font.cell ().cx / 2)
- / app.text_font.cell ().cx + dl);
+ int x = ((w_clsize.cx + w_owner->text_font.cell ().cx / 2)
+ / w_owner->text_font.cell ().cx + dl);
if (x >= 0 && x < ngd->gd_len)
{
const glyph_t *g = ngd->gd_cc + x;
@@ -846,26 +846,26 @@ Window::paint_line (HDC hdc, HDC hdcmem, glyph_data *ogd, const glyph_data *ngd,
else if (glyph_lead_p (*g))
l = 2;
paint_glyphs (hdc, hdcmem, ngd->gd_cc, g, g + l, buf, padding,
- (x - 1) * app.text_font.cell ().cx + app.text_font.cell ().cx / 2,
+ (x - 1) * w_owner->text_font.cell ().cx + w_owner->text_font.cell ().cx / 2,
y, 0);
}
}
- r.left = ((ngd->gd_len - 1) * app.text_font.cell ().cx
- + app.text_font.cell ().cx / 2);
+ r.left = ((ngd->gd_len - 1) * w_owner->text_font.cell ().cx
+ + w_owner->text_font.cell ().cx / 2);
ValidateRect (w_hwnd, &r);
PatBlt (hdc, r.left, r.top,
- r.right - r.left, app.text_font.cell ().cy,
+ r.right - r.left, w_owner->text_font.cell ().cy,
PATCOPY);
}
else
{
- r.right = ((nls - ngd->gd_cc - 1) * app.text_font.cell ().cx
- + app.text_font.cell ().cx / 2);
+ r.right = ((nls - ngd->gd_cc - 1) * w_owner->text_font.cell ().cx
+ + w_owner->text_font.cell ().cx / 2);
ValidateRect (w_hwnd, &r);
}
paint_glyphs (hdc, hdcmem, ngd->gd_cc, nfd, nls, buf, padding,
- ((nfd - ngd->gd_cc - 1) * app.text_font.cell ().cx
- + app.text_font.cell ().cx / 2),
+ ((nfd - ngd->gd_cc - 1) * w_owner->text_font.cell ().cx
+ + w_owner->text_font.cell ().cx / 2),
y, 0);
}
for (o = ofd, n = nfd; n < ne;)
@@ -881,7 +881,7 @@ Window::erase_cursor_line (HDC hdc) const
if (w_cursor_line.ypixel < 0 || !w_glyphs.g_rep)
return;
- int y = w_cursor_line.ypixel / app.text_font.cell ().cy;
+ int y = w_cursor_line.ypixel / w_owner->text_font.cell ().cy;
if (y >= 0 && y < w_ch_max.cy)
{
HDC xhdc = hdc;
@@ -891,45 +891,45 @@ Window::erase_cursor_line (HDC hdc) const
hdc = GetDC (w_hwnd);
}
- int x1 = (w_cursor_line.x1 - app.text_font.cell ().cx / 2) / app.text_font.cell ().cx + 1;
+ int x1 = (w_cursor_line.x1 - w_owner->text_font.cell ().cx / 2) / w_owner->text_font.cell ().cx + 1;
int x2pixel = w_cursor_line.x2;
if (w_bufp->b_fold_columns != Buffer::FOLD_NONE)
{
int w = w_cursor_line.x1 + ((w_bufp->b_fold_columns - w_last_top_column)
- * app.text_font.cell ().cx);
+ * w_owner->text_font.cell ().cx);
if (x2pixel < w)
x2pixel = w;
}
- int x2 = (x2pixel - app.text_font.cell ().cx / 2
- + app.text_font.cell ().cx - 1) / app.text_font.cell ().cx + 1;
+ int x2 = (x2pixel - w_owner->text_font.cell ().cx / 2
+ + w_owner->text_font.cell ().cx - 1) / w_owner->text_font.cell ().cx + 1;
const glyph_data *gd = w_glyphs.g_rep->gr_oglyph[y];
const glyph_t *g = gd->gd_cc + x1, *ge = gd->gd_cc + min (int (gd->gd_len), x2);
int x = w_cursor_line.x1;
- HGDIOBJ of = SelectObject (hdc, app.text_font.font (FONT_ASCII));
+ HGDIOBJ of = SelectObject (hdc, w_owner->text_font.font (FONT_ASCII));
HDC hdcmem = CreateCompatibleDC (hdc);
- HGDIOBJ obm = SelectObject (hdcmem, app.text_font.hbm ());
+ HGDIOBJ obm = SelectObject (hdcmem, w_owner->text_font.hbm ());
HGDIOBJ obr = SelectObject (hdc, CreateSolidBrush (w_colors[WCOLOR_BACK]));
INT *padding;
- if (!app.text_font.need_pad_p ())
+ if (!w_owner->text_font.need_pad_p ())
padding = 0;
else
{
padding = (INT *)alloca (sizeof *padding * w_ch_max.cx);
for (int i = 0; i < w_ch_max.cx; i++)
- padding[i] = app.text_font.cell ().cx;
+ padding[i] = w_owner->text_font.cell ().cx;
}
char *buf = (char *)alloca (w_ch_max.cx + 3);
paint_glyphs (hdc, hdcmem, gd->gd_cc, g, ge, buf, padding, x,
- (w_cursor_line.ypixel - app.text_font.cell ().cy + 1),
- app.text_font.cell ().cy - 1);
+ (w_cursor_line.ypixel - w_owner->text_font.cell ().cy + 1),
+ w_owner->text_font.cell ().cy - 1);
SelectObject (hdcmem, obm);
DeleteDC (hdcmem);
SelectObject (hdc, of);
DeleteObject (SelectObject (hdc, obr));
- x += (ge - g) * app.text_font.cell ().cx;
+ x += (ge - g) * w_owner->text_font.cell ().cx;
if (x < w_cursor_line.x2)
draw_hline (hdc, x, w_cursor_line.x2,
w_cursor_line.ypixel, w_colors[WCOLOR_BACK]);
@@ -952,19 +952,19 @@ Window::paint_cursor_line (HDC hdc, int f) const
if (paint)
{
x1 = ((w_last_flags & WF_LINE_NUMBER ? LINENUM_COLUMNS + 1 : 0)
- * app.text_font.cell ().cx + app.text_font.cell ().cx / 2);
- x2 = w_ch_max.cx * app.text_font.cell ().cx;
+ * w_owner->text_font.cell ().cx + w_owner->text_font.cell ().cx / 2);
+ x2 = w_ch_max.cx * w_owner->text_font.cell ().cx;
if (w_bufp->b_fold_columns != Buffer::FOLD_NONE)
{
int w = x1 + ((w_bufp->b_fold_columns - w_last_top_column)
- * app.text_font.cell ().cx);
+ * w_owner->text_font.cell ().cx);
if (w < x2)
x2 = w;
}
if (x2 > w_clsize.cx)
x2 = w_clsize.cx;
- y = (w_linenum - w_last_top_linenum + 1) * app.text_font.cell ().cy - 1;
+ y = (w_linenum - w_last_top_linenum + 1) * w_owner->text_font.cell ().cy - 1;
if (y != w_cursor_line.ypixel
|| x1 != w_cursor_line.x1
@@ -1370,7 +1370,7 @@ glyph_dbchar (glyph_t *g, Char cc, int f, int flags)
}
static inline glyph_t *
-glyph_sbchar (glyph_t *g, Char cc, int f, int flags)
+glyph_sbchar (ApplicationFrame *app1, glyph_t *g, Char cc, int f, int flags)
{
int ccs = code_charset (cc);
switch (ccs)
@@ -1446,7 +1446,7 @@ glyph_sbchar (glyph_t *g, Char cc, int f, int flags)
break;
case ccs_usascii:
- if (app.text_font.use_backsl_p () && cc == '\\')
+ if (app1->text_font.use_backsl_p () && cc == '\\')
*g++ = f | GLYPH_BM_BACKSL;
else if (flags & Window::WF_HALFSPC && cc == ' ')
*g++ = (f & ~GLYPH_TEXT_MASK) | GLYPH_CTRL | GLYPH_BM_HALFSPC;
@@ -1480,7 +1480,7 @@ glyph_sbchar (glyph_t *g, Char cc, int f, int flags)
}
static inline glyph_t *
-glyph_bmchar (glyph_t *g, Char bm, lisp ch, int f, int n)
+glyph_bmchar (ApplicationFrame *app1, glyph_t *g, Char bm, lisp ch, int f, int n)
{
ch = xsymbol_value (ch);
if (ch == Qnil)
@@ -1488,7 +1488,7 @@ glyph_bmchar (glyph_t *g, Char bm, lisp ch, int f, int n)
*g++ = f | ' ';
else if (charp (ch) && char_width (xchar_code (ch)) == 1)
for (int i = 0; i < n; i++)
- g = glyph_sbchar (g, xchar_code (ch), f, 0);
+ g = glyph_sbchar (app1, g, xchar_code (ch), f, 0);
else
for (int i = 0; i < n; i++)
*g++ = f | bm;
@@ -1928,7 +1928,7 @@ Window::redraw_line (glyph_data *gd, Point &point, long vlinenum, long plinenum,
g = glyph_dbchar (g, cc, 0, 0);
}
else
- g = glyph_sbchar (g, cc, 0, 0);
+ g = glyph_sbchar (w_owner, g, cc, 0, 0);
}
}
while (g < ge2)
@@ -2258,7 +2258,7 @@ Window::redraw_line (glyph_data *gd, Point &point, long vlinenum, long plinenum,
if (seltype == Buffer::SELECTION_RECTANGLE)
f &= ~GLYPH_SELECTED;
if (wflags & WF_NEWLINE)
- g = glyph_bmchar (g, GLYPH_BM_NEWLINE, Vdisplay_newline_char,
+ g = glyph_bmchar (w_owner, g, GLYPH_BM_NEWLINE, Vdisplay_newline_char,
(f & ~GLYPH_TEXT_MASK) | GLYPH_CTRL, 1);
else
*g++ = (f & ~GLYPH_TEXT_MASK) | ' ';
@@ -2273,10 +2273,10 @@ Window::redraw_line (glyph_data *gd, Point &point, long vlinenum, long plinenum,
int n = min (goal - col, ge - g);
if (wflags & WF_HTAB)
{
- g = glyph_bmchar (g, GLYPH_BM_HTAB, Vdisplay_first_tab_char,
+ g = glyph_bmchar (w_owner, g, GLYPH_BM_HTAB, Vdisplay_first_tab_char,
(f & ~GLYPH_TEXT_MASK) | GLYPH_CTRL, 1);
if (--n > 0)
- g = glyph_bmchar (g, '.', Vdisplay_rest_tab_char,
+ g = glyph_bmchar (w_owner, g, '.', Vdisplay_rest_tab_char,
(f & ~GLYPH_TEXT_MASK) | GLYPH_CTRL, n);
}
else
@@ -2314,7 +2314,7 @@ Window::redraw_line (glyph_data *gd, Point &point, long vlinenum, long plinenum,
g = glyph_dbchar (g, cc, f, wflags);
}
else
- g = glyph_sbchar (g, cc, f, wflags);
+ g = glyph_sbchar (w_owner, g, cc, f, wflags);
if (f & GLYPH_SELECTED
&& seltype == Buffer::SELECTION_RECTANGLE
@@ -2457,13 +2457,13 @@ Window::scroll_down_region (int y1, int y2, int dy, int offset) const
}
RECT r;
- r.left = (offset - 1) * app.text_font.cell ().cx + app.text_font.cell ().cx / 2;
- r.right = min (w_client.cx, LONG ((maxl - 1) * app.text_font.cell ().cx
- + app.text_font.cell ().cx / 2));
- r.top = y1 * app.text_font.cell ().cy;
- r.bottom = (y2 + 1) * app.text_font.cell ().cy;
- ScrollWindow (w_hwnd, 0, dy * app.text_font.cell ().cy, 0, &r);
- r.bottom = r.top + dy * app.text_font.cell ().cy;
+ r.left = (offset - 1) * w_owner->text_font.cell ().cx + w_owner->text_font.cell ().cx / 2;
+ r.right = min (w_client.cx, LONG ((maxl - 1) * w_owner->text_font.cell ().cx
+ + w_owner->text_font.cell ().cx / 2));
+ r.top = y1 * w_owner->text_font.cell ().cy;
+ r.bottom = (y2 + 1) * w_owner->text_font.cell ().cy;
+ ScrollWindow (w_hwnd, 0, dy * w_owner->text_font.cell ().cy, 0, &r);
+ r.bottom = r.top + dy * w_owner->text_font.cell ().cy;
ValidateRect (w_hwnd, &r);
}
@@ -2493,13 +2493,13 @@ Window::scroll_up_region (int y1, int y2, int dy, int offset) const
}
RECT r;
- r.left = (offset - 1) * app.text_font.cell ().cx + app.text_font.cell ().cx / 2;
- r.right = min (w_client.cx, LONG ((maxl - 1) * app.text_font.cell ().cx
- + app.text_font.cell ().cx / 2));
- r.top = y1 * app.text_font.cell ().cy;
- r.bottom = (y2 + 1) * app.text_font.cell ().cy;
- ScrollWindow (w_hwnd, 0, -dy * app.text_font.cell ().cy, 0, &r);
- r.top = r.bottom - dy * app.text_font.cell ().cy;
+ r.left = (offset - 1) * w_owner->text_font.cell ().cx + w_owner->text_font.cell ().cx / 2;
+ r.right = min (w_client.cx, LONG ((maxl - 1) * w_owner->text_font.cell ().cx
+ + w_owner->text_font.cell ().cx / 2));
+ r.top = y1 * w_owner->text_font.cell ().cy;
+ r.bottom = (y2 + 1) * w_owner->text_font.cell ().cy;
+ ScrollWindow (w_hwnd, 0, -dy * w_owner->text_font.cell ().cy, 0, &r);
+ r.top = r.bottom - dy * w_owner->text_font.cell ().cy;
ValidateRect (w_hwnd, &r);
}
@@ -2619,25 +2619,25 @@ Window::find_motion () const
void
Window::paint_region (HDC hdc, int from, int to) const
{
- HGDIOBJ of = SelectObject (hdc, app.text_font.font (FONT_ASCII));
+ HGDIOBJ of = SelectObject (hdc, w_owner->text_font.font (FONT_ASCII));
HDC hdcmem = CreateCompatibleDC (hdc);
- HGDIOBJ obm = SelectObject (hdcmem, app.text_font.hbm ());
+ HGDIOBJ obm = SelectObject (hdcmem, w_owner->text_font.hbm ());
HGDIOBJ obr = SelectObject (hdc, CreateSolidBrush (w_colors[WCOLOR_BACK]));
INT *padding;
- if (!app.text_font.need_pad_p ())
+ if (!w_owner->text_font.need_pad_p ())
padding = 0;
else
{
padding = (INT *)alloca (sizeof *padding * w_ch_max.cx);
for (int i = 0; i < w_ch_max.cx; i++)
- padding[i] = app.text_font.cell ().cx;
+ padding[i] = w_owner->text_font.cell ().cx;
}
char *buf = (char *)alloca (w_ch_max.cx + 3);
glyph_data **g = w_glyphs.g_rep->gr_nglyph + from;
glyph_data **og = w_glyphs.g_rep->gr_oglyph + from;
- for (int y = from * app.text_font.cell ().cy, ye = to * app.text_font.cell ().cy;
- y < ye; y += app.text_font.cell ().cy, g++, og++)
+ for (int y = from * w_owner->text_font.cell ().cy, ye = to * w_owner->text_font.cell ().cy;
+ y < ye; y += w_owner->text_font.cell ().cy, g++, og++)
if ((*g)->gd_mod)
{
paint_line (hdc, hdcmem, *og, *g, buf, y, padding);
@@ -2723,24 +2723,24 @@ Window::scroll_lines (int dy)
RECT r;
r.left = 0;
- r.right = min (w_client.cx, LONG ((maxl - 1) * app.text_font.cell ().cx
- + app.text_font.cell ().cx / 2));
+ r.right = min (w_client.cx, LONG ((maxl - 1) * w_owner->text_font.cell ().cx
+ + w_owner->text_font.cell ().cx / 2));
r.top = 0;
if (dy < 0)
- r.bottom = w_ech.cy * app.text_font.cell ().cy;
+ r.bottom = w_ech.cy * w_owner->text_font.cell ().cy;
else
r.bottom = w_client.cy;
- ScrollWindow (w_hwnd, 0, dy * app.text_font.cell ().cy, 0, &r);
+ ScrollWindow (w_hwnd, 0, dy * w_owner->text_font.cell ().cy, 0, &r);
if (dy < 0)
{
r.bottom = w_client.cy;
- r.top = ((r.bottom + dy * app.text_font.cell ().cy)
- / app.text_font.cell ().cy * app.text_font.cell ().cy);
+ r.top = ((r.bottom + dy * w_owner->text_font.cell ().cy)
+ / w_owner->text_font.cell ().cy * w_owner->text_font.cell ().cy);
}
else
{
r.top = 0;
- r.bottom = dy * app.text_font.cell ().cy;
+ r.bottom = dy * w_owner->text_font.cell ().cy;
}
ValidateRect (w_hwnd, &r);
@@ -3117,7 +3117,7 @@ Window::reframe ()
paint:
HDC hdc = GetDC (w_hwnd);
if (w_cursor_line.ypixel >= 0
- && w_cursor_line.x1 == app.text_font.cell ().cx / 2
+ && w_cursor_line.x1 == w_owner->text_font.cell ().cx / 2
&& flags () & WF_LINE_NUMBER)
erase_cursor_line (hdc);
paint_window (hdc);
@@ -3168,10 +3168,10 @@ Window::paint_minibuffer_message (lisp string)
g = glyph_dbchar (g, cc, 0, 0);
}
else
- g = glyph_sbchar (g, cc, 0, 0);
+ g = glyph_sbchar (w_owner, g, cc, 0, 0);
}
- app.minibuffer_prompt_column = g - (*gr)->gd_cc;
+ w_owner->minibuffer_prompt_column = g - (*gr)->gd_cc;
for (; g > (*gr)->gd_cc && g[-1] == ' '; g--)
;
@@ -3266,10 +3266,10 @@ Window::paint_mode_line_point (HDC hdc)
point_from_end (nb, b, e);
w_last_ml_point_width = e - b;
- int x0 = (w_point_pixel + app.modeline_param.m_exts[1]
- - app.modeline_param.m_exts[b - nb]);
- int right = (x0 + app.modeline_param.m_exts[e - nb]
- + app.modeline_param.m_exts[1]);
+ int x0 = (w_point_pixel + w_owner->modeline_param.m_exts[1]
+ - w_owner->modeline_param.m_exts[b - nb]);
+ int right = (x0 + w_owner->modeline_param.m_exts[e - nb]
+ + w_owner->modeline_param.m_exts[1]);
if (w_last_ml_linenum < 0)
{
@@ -3285,8 +3285,8 @@ Window::paint_mode_line_point (HDC hdc)
;
for (; ie > ib && ob[ie - 1] == nb[ie - 1]; ie--)
;
- r.left = x0 + app.modeline_param.m_exts[ib];
- r.right = min (x0 + app.modeline_param.m_exts[ie], int (w_ml_size.cx - 1));
+ r.left = x0 + w_owner->modeline_param.m_exts[ib];
+ r.right = min (x0 + w_owner->modeline_param.m_exts[ie], int (w_ml_size.cx - 1));
b = nb + ib;
e = nb + ie;
}
@@ -3297,8 +3297,8 @@ Window::paint_mode_line_point (HDC hdc)
;
ExtTextOut (hdc,
- x0 + app.modeline_param.m_exts[b - nb],
- 1 + app.modeline_param.m_exlead,
+ x0 + w_owner->modeline_param.m_exts[b - nb],
+ 1 + w_owner->modeline_param.m_exlead,
ETO_OPAQUE | ETO_CLIPPED, &r, b, e - b, 0);
w_last_ml_column = w_column;
w_last_ml_linenum = w_plinenum;
@@ -3344,7 +3344,7 @@ Window::paint_mode_line (HDC hdc)
ofg = SetTextColor (hdc, w_colors[WCOLOR_MODELINE_FG]);
obg = SetBkColor (hdc, w_colors[WCOLOR_MODELINE_BG]);
}
- HGDIOBJ of = SelectObject (hdc, app.modeline_param.m_hfont);
+ HGDIOBJ of = SelectObject (hdc, w_owner->modeline_param.m_hfont);
RECT r;
r.left = 1;
@@ -3355,7 +3355,7 @@ Window::paint_mode_line (HDC hdc)
if (!posp)
{
w_point_pixel = -1;
- ExtTextOut (hdc, 1, 1 + app.modeline_param.m_exlead,
+ ExtTextOut (hdc, 1, 1 + w_owner->modeline_param.m_exlead,
ETO_OPAQUE | ETO_CLIPPED, &r, b0, b - b0, 0);
}
else
@@ -3364,12 +3364,12 @@ Window::paint_mode_line (HDC hdc)
GetTextExtentPoint32 (hdc, b0, posp - b0, &size);
w_point_pixel = 1 + size.cx;
r.right = min (w_point_pixel, int (r.right));
- ExtTextOut (hdc, 1, 1 + app.modeline_param.m_exlead,
+ ExtTextOut (hdc, 1, 1 + w_owner->modeline_param.m_exlead,
ETO_OPAQUE | ETO_CLIPPED, &r, b0, posp - b0, 0);
w_last_ml_column = w_last_ml_linenum = -1;
r.left = paint_mode_line_point (hdc);
r.right = w_ml_size.cx - 1;
- ExtTextOut (hdc, r.left, 1 + app.modeline_param.m_exlead,
+ ExtTextOut (hdc, r.left, 1 + w_owner->modeline_param.m_exlead,
ETO_OPAQUE | ETO_CLIPPED, &r, posp, b - posp, 0);
}
@@ -3443,7 +3443,7 @@ Window::redraw_mode_line ()
w_inverse_mode_line = 0;
}
}
- else if (w_inverse_mode_line != (selected_window () == this))
+ else if (w_inverse_mode_line != (selected_window (w_owner) == this))
{
w_disp_flags |= WDF_MODELINE;
w_inverse_mode_line ^= 1;
@@ -3475,7 +3475,7 @@ Window::redraw_mode_line ()
ofg = SetTextColor (hdc, w_colors[WCOLOR_MODELINE_FG]);
obg = SetBkColor (hdc, w_colors[WCOLOR_MODELINE_BG]);
}
- HGDIOBJ of = SelectObject (hdc, app.modeline_param.m_hfont);
+ HGDIOBJ of = SelectObject (hdc, w_owner->modeline_param.m_hfont);
paint_mode_line_point (hdc);
SelectObject (hdc, of);
SetTextColor (hdc, ofg);
@@ -3627,71 +3627,79 @@ void
refresh_screen (int f)
{
Window::destroy_windows ();
- if (app.active_frame.windows_moved)
- Window::move_all_windows ();
+ for(ApplicationFrame *app1 = first_app_frame(); app1; app1= app1->a_next)
+ {
+ if (app1->active_frame.windows_moved)
+ Window::move_all_windows (app1);
- if (g_frame.modified ())
- recalc_toplevel ();
+ if (app1->mframe->modified ())
+ recalc_toplevel (app1);
- lisp lmenu = (win32_menu_p (selected_buffer ()->lmenu)
- ? selected_buffer ()->lmenu
- : (win32_menu_p (xsymbol_value (Vdefault_menu))
- ? xsymbol_value (Vdefault_menu)
- : Qnil));
- if (lmenu != xsymbol_value (Vlast_active_menu))
- {
- if (SetMenu (app.toplev, lmenu == Qnil ? 0 : xwin32_menu_handle (lmenu)))
+ lisp lmenu = (win32_menu_p (selected_buffer (app1)->lmenu)
+ ? selected_buffer (app1)->lmenu
+ : (win32_menu_p (xsymbol_value (Vdefault_menu))
+ ? xsymbol_value (Vdefault_menu)
+ : Qnil));
+ if (lmenu != xsymbol_value (Vlast_active_menu))
{
- DrawMenuBar (app.toplev);
-#ifndef WINDOWBLINDS_FIXED // WindowBlinds対策
- if (lmenu == Qnil || xsymbol_value (Vlast_active_menu) == Qnil)
+ if (SetMenu (app1->toplev, lmenu == Qnil ? 0 : xwin32_menu_handle (lmenu)))
{
- RECT r;
- GetWindowRect (app.toplev, &r);
- int w = r.right - r.left;
- int h = r.bottom - r.top;
- MoveWindow (app.toplev, r.left, r.top, w - 1, h - 1, 1);
- MoveWindow (app.toplev, r.left, r.top, w, h, 1);
- }
+ DrawMenuBar (app1->toplev);
+#ifndef WINDOWBLINDS_FIXED // WindowBlinds対策
+ if (lmenu == Qnil || xsymbol_value (Vlast_active_menu) == Qnil)
+ {
+ RECT r;
+ GetWindowRect (app1->toplev, &r);
+ int w = r.right - r.left;
+ int h = r.bottom - r.top;
+ MoveWindow (app1->toplev, r.left, r.top, w - 1, h - 1, 1);
+ MoveWindow (app1->toplev, r.left, r.top, w, h, 1);
+ }
#endif /* WINDOWBLINDS_FIXED */
- xsymbol_value (Vlast_active_menu) = lmenu;
+ xsymbol_value (Vlast_active_menu) = lmenu;
+ }
}
- }
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
- UpdateWindow (wp->w_hwnd);
+ for (Window *wp = app1->active_frame.windows; wp; wp = wp->w_next)
+ UpdateWindow (wp->w_hwnd);
- int update_title_bar = 0;
- for (wp = app.active_frame.windows; wp; wp = wp->w_next)
- if (wp->refresh (f) && wp == selected_window ())
- update_title_bar = 1;
+ int update_title_bar = 0;
+ for (wp = app1->active_frame.windows; wp; wp = wp->w_next)
+ if (wp->refresh (f) && wp == selected_window (app1))
+ update_title_bar = 1;
- app.stat_area.update ();
+ app1->stat_area.update ();
- for (Buffer *bp = Buffer::b_blist; bp; bp = bp->b_next)
- {
- bp->b_modified_region.p1 = -1;
- bp->b_last_narrow_depth = bp->b_narrow_depth;
- }
+ // TODO: this section should run only once, but I just call as many times as AppFrame num
+ for (Buffer *bp = Buffer::b_blist; bp; bp = bp->b_next)
+ {
+ bp->b_modified_region.p1 = -1;
+ bp->b_last_narrow_depth = bp->b_narrow_depth;
+ }
- if (f)
- {
- bp = selected_buffer ();
- g_frame.update_ui ();
- bp->change_ime_mode ();
- bp->set_frame_title (update_title_bar);
- bp->dlist_add_head ();
- Fundo_boundary ();
+ if (f)
+ {
+ bp = selected_buffer (app1);
+ app1->mframe->update_ui ();
+ bp->change_ime_mode ();
+ bp->set_frame_title (update_title_bar);
+ if(app1 == &active_app_frame())
+ bp->dlist_add_head ();
+ Fundo_boundary ();
+ }
}
}
void
pending_refresh_screen ()
{
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
- wp->pending_refresh ();
+ for( ApplicationFrame *app1 = first_app_frame(); app1; app1 = app1->a_next)
+ {
+ for (Window *wp = app1->active_frame.windows; wp; wp = wp->w_next)
+ wp->pending_refresh ();
- selected_buffer ()->dlist_add_head ();
+ selected_buffer (app1)->dlist_add_head ();
+ }
}
void
@@ -3733,17 +3741,17 @@ Window::winsize_changed (int w, int h)
void
Window::discard_invalid_region (const PAINTSTRUCT &ps, RECT &r)
{
- r.left = max (0L, ((ps.rcPaint.left - app.text_font.cell ().cx / 2)
- / app.text_font.cell ().cx));
+ r.left = max (0L, ((ps.rcPaint.left - w_owner->text_font.cell ().cx / 2)
+ / w_owner->text_font.cell ().cx));
r.right = min (w_ch_max.cx,
- ((ps.rcPaint.right + app.text_font.cell ().cx
- + app.text_font.cell ().cx / 2 - 1)
- / app.text_font.cell ().cx));
+ ((ps.rcPaint.right + w_owner->text_font.cell ().cx
+ + w_owner->text_font.cell ().cx / 2 - 1)
+ / w_owner->text_font.cell ().cx));
r.right = max (r.left, r.right);
- r.top = max (0L, ps.rcPaint.top / app.text_font.cell ().cy);
+ r.top = max (0L, ps.rcPaint.top / w_owner->text_font.cell ().cy);
r.bottom = min (w_ch_max.cy,
- ((ps.rcPaint.bottom + app.text_font.cell ().cy - 1)
- / app.text_font.cell ().cy));
+ ((ps.rcPaint.bottom + w_owner->text_font.cell ().cy - 1)
+ / w_owner->text_font.cell ().cy));
r.bottom = max (r.top, r.bottom);
glyph_data **og = w_glyphs.g_rep->gr_oglyph;
@@ -3794,8 +3802,8 @@ Window::update_window ()
paint_cursor_line (0, 1);
}
if (this == selected_window ()
- && !app.ime_composition
- && GetFocus () == app.toplev)
+ && !w_owner->ime_composition
+ && GetFocus () == w_owner->toplev)
update_caret ();
}
@@ -3807,7 +3815,7 @@ Frefresh_screen (lisp f)
else if (f != Qt)
refresh_screen (1);
else
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = active_app_frame().active_frame.windows; wp; wp = wp->w_next)
wp->w_disp_flags |= Window::WDF_WINDOW;
return Qt;
}
diff --git a/src/dockbar.cc b/src/dockbar.cc
index 240353e..da5a6ce 100644
--- a/src/dockbar.cc
+++ b/src/dockbar.cc
@@ -213,7 +213,7 @@ dock_bar::wndproc (UINT msg, WPARAM wparam, LPARAM lparam)
return HTCLIENT;
case WM_LBUTTONDOWN:
- if (!app.kbdq.idlep ())
+ if (!active_app_frame().kbdq.idlep ())
return 0;
if (lbtn_down (short (LOWORD (lparam)), short (HIWORD (lparam))))
return 0;
@@ -232,12 +232,12 @@ dock_bar::wndproc (UINT msg, WPARAM wparam, LPARAM lparam)
case WM_XBUTTONDBLCLK:
case WM_MOUSEMOVE:
case WM_MOUSEWHEEL:
- if (!app.kbdq.idlep ())
+ if (!active_app_frame().kbdq.idlep ())
return 0;
break;
case WM_KEYDOWN:
- if (!app.kbdq.idlep ())
+ if (!active_app_frame().kbdq.idlep ())
return 0;
switch (wparam)
{
@@ -259,7 +259,7 @@ dock_bar::wndproc (UINT msg, WPARAM wparam, LPARAM lparam)
break;
case WM_CONTEXTMENU:
- if (!app.kbdq.idlep ())
+ if (!active_app_frame().kbdq.idlep ())
return 0;
if (HWND (wparam) == b_hwnd)
{
@@ -334,7 +334,7 @@ tool_bar::create (HWND hwnd_parent, DWORD style, UINT id)
{
if (!dock_bar::create (0, TOOLBARCLASSNAME, 0,
style, 0, 0, 0, 0, hwnd_parent,
- (HMENU)id, app.hinst, 0))
+ (HMENU)id, active_app_frame().hinst, 0))
return 0;
sendmsg (TB_BUTTONSTRUCTSIZE, sizeof (TBBUTTON), 0);
return 1;
@@ -521,7 +521,7 @@ tab_bar::modify_spin ()
HWND hwnd = CreateWindowEx (GetWindowLong (hwnd_spin, GWL_EXSTYLE),
UPDOWN_CLASS, "", (style ^ UDS_HORZ) & ~UDS_WRAP,
0, 0, 0, 0, b_hwnd, HMENU (IDC_TAB_SPIN),
- app.hinst, 0);
+ active_app_frame().hinst, 0);
if (!hwnd)
return;
@@ -1214,7 +1214,7 @@ tab_bar::adjust_gripper (HDC hdc, RECT &wr, const RECT &cr) const
int
tab_bar::set_cursor (WPARAM wparam, LPARAM lparam)
{
- if (app.kbdq.idlep () && HWND (wparam) == b_hwnd
+ if (active_app_frame().kbdq.idlep () && HWND (wparam) == b_hwnd
&& t_horz_text && dock_vert_p ())
{
POINT p;
@@ -1235,7 +1235,7 @@ tab_bar::set_cursor (WPARAM wparam, LPARAM lparam)
int
tab_bar::lbtn_down (int x, int y)
{
- if (!app.kbdq.idlep () || !t_horz_text || !dock_vert_p ())
+ if (!active_app_frame().kbdq.idlep () || !t_horz_text || !dock_vert_p ())
return 0;
RECT cr;
@@ -1356,7 +1356,7 @@ done:
int
tab_bar::move_tab (int x, int y)
{
- if (!app.kbdq.idlep () || GetKeyState (VK_LBUTTON) >= 0)
+ if (!active_app_frame().kbdq.idlep () || GetKeyState (VK_LBUTTON) >= 0)
return 0;
POINT pt;
GetCursorPos (&pt);
@@ -1372,7 +1372,7 @@ tab_bar::move_tab (int x, int y)
HCURSOR hcur_old = GetCursor ();
HCURSOR hcur_no = LoadCursor (0, IDC_NO);
- HCURSOR hcur_mv = LoadCursor (app.hinst,
+ HCURSOR hcur_mv = LoadCursor (active_app_frame().hinst,
MAKEINTRESOURCE (dock_vert_p ()
? IDC_MOVEUD : IDC_MOVELR));
diff --git a/src/dockbar.h b/src/dockbar.h
index e66e3b3..e114bf5 100644
--- a/src/dockbar.h
+++ b/src/dockbar.h
@@ -316,7 +316,7 @@ public:
{
return dock_bar::create (0, WC_TABCONTROL, "",
style, 0, 0, 0, 0, hwnd_parent,
- (HMENU)id, app.hinst, 0);
+ (HMENU)id, active_app_frame().hinst, 0);
}
int create (HWND);
virtual void calc_client_size (SIZE &, int) const;
diff --git a/src/ed.h b/src/ed.h
index 0142067..6e4e96b 100644
--- a/src/ed.h
+++ b/src/ed.h
@@ -11,6 +11,7 @@
struct Window;
struct Buffer;
+class ApplicationFrame;
class lwindow: public lisp_object
{
@@ -33,6 +34,27 @@ xwindow_wp (lisp x)
return ((lwindow *)x)->wp;
}
+class lappframe: public lisp_object
+{
+public:
+ ApplicationFrame *fp;
+};
+
+#define appframep(X) typep((X), Tappframe)
+
+inline void
+check_appframe(lisp x)
+{
+ check_type (x, Tappframe, Qappframe);
+}
+
+inline ApplicationFrame *&
+xappframe_fp (lisp x)
+{
+ assert (appframep (x));
+ return ((lappframe *)x)->fp;
+}
+
class lbuffer: public lisp_object
{
public:
@@ -237,6 +259,14 @@ make_window ()
return p;
}
+inline lappframe *
+make_appframe()
+{
+ lappframe *p = ldata <lappframe, Tappframe>::lalloc ();
+ p->fp = 0;
+ return p;
+}
+
inline lbuffer *
make_buffer ()
{
@@ -272,6 +302,7 @@ make_win32_dde_handle ()
struct Window;
struct Buffer;
+class main_frame;
# include "process.h"
# include "dll.h"
@@ -339,6 +370,7 @@ struct Frame
COLORREF last_caret_color;
FKWin *fnkey;
+ Frame *f_next;
};
struct ModelineParam
@@ -359,16 +391,17 @@ struct Region
point_t p2;
};
-class Application
+/*
+This class is Frame in emacs meaning.
+But Frame is already used in xyzzy and it does not contain status bar, menu, etc.
+In xyzzy, similar concept was Application, so I create ApplicationFrame and separate from Application.
+This name should be renamed.
+*/
+class ApplicationFrame
{
public:
- Application ();
- ~Application ();
-
- static const char ToplevelClassName[];
- static const char FrameClassName[];
- static const char ClientClassName[];
- static const char ModelineClassName[];
+ ApplicationFrame ();
+ ~ApplicationFrame ();
HINSTANCE hinst;
HWND toplev;
@@ -381,11 +414,11 @@ public:
ime_comp_queue ime_compq;
Frame active_frame;
+
FontSet text_font;
ModelineParam modeline_param;
StatusWindow status_window;
key_sequence keyseq;
- itimer gc_itimer;
itimer as_itimer;
status_area stat_area;
@@ -417,9 +450,6 @@ public:
UINT default_caret_blink_time;
int last_blink_caret;
- char dump_image[PATH_MAX + 8];
- char *ini_file_path;
-
lisp lquit_char;
int quit_vkey;
int quit_mod;
@@ -428,12 +458,39 @@ public:
int minibuffer_prompt_column;
utimer user_timer;
+ main_frame* mframe;
+
+ ApplicationFrame *a_next;
+ lisp lfp;
+};
+
+class Application
+{
+public:
+ Application ();
+ ~Application ();
+
+ static const char ToplevelClassName[];
+ static const char FrameClassName[];
+ static const char ClientClassName[];
+ static const char ModelineClassName[];
+
+ HINSTANCE hinst;
+
+ itimer gc_itimer;
+
+ char dump_image[PATH_MAX + 8];
+ char *ini_file_path;
void *initial_stack;
int in_gc;
};
-extern Application app;
+extern ApplicationFrame& active_app_frame ();
+extern ApplicationFrame *first_app_frame ();
+extern ApplicationFrame *retrieve_app_frame (HWND hwnd);
+extern void insert_app_frame (HWND hwnd, ApplicationFrame *app);
+extern Application g_app;
class enable_quit
{
@@ -445,7 +502,7 @@ public:
if (!q_save)
{
q_enable = 1;
- PostThreadMessage (app.quit_thread_id, WM_PRIVATE_REGISTER_HOTKEY, 0, 0);
+ PostThreadMessage (active_app_frame().quit_thread_id, WM_PRIVATE_REGISTER_HOTKEY, 0, 0);
}
}
~enable_quit () {if (!q_save) disable ();}
@@ -453,7 +510,7 @@ public:
{
if (q_enable)
{
- PostThreadMessage (app.quit_thread_id, WM_PRIVATE_UNREGISTER_HOTKEY, 0, 0);
+ PostThreadMessage (active_app_frame().quit_thread_id, WM_PRIVATE_UNREGISTER_HOTKEY, 0, 0);
q_enable = 0;
}
}
@@ -466,23 +523,24 @@ public:
# include "resource.h"
inline Window *
-selected_window ()
+selected_window (ApplicationFrame *owner = &active_app_frame())
{
- return app.active_frame.selected;
+// ApplicationFrame *frame = owner != 0? owner : &active_app_frame();
+ return owner->active_frame.selected;
}
inline Buffer *
-selected_buffer ()
+selected_buffer (ApplicationFrame *app1 = &active_app_frame())
{
- assert (selected_window ());
- return selected_window ()->w_bufp;
+ assert (selected_window (app1));
+ return selected_window (app1)->w_bufp;
}
inline HWND
get_active_window ()
{
HWND hwnd = GetActiveWindow ();
- return hwnd ? hwnd : app.toplev;
+ return hwnd ? hwnd : active_app_frame().toplev;
}
inline
@@ -558,13 +616,13 @@ class save_cursor_depth
{
int odepth;
public:
- save_cursor_depth () : odepth (app.wait_cursor_depth) {}
+ save_cursor_depth () : odepth (active_app_frame().wait_cursor_depth) {}
~save_cursor_depth ()
{
if (!odepth)
end_wait_cursor (1);
else
- app.wait_cursor_depth = odepth;
+ active_app_frame().wait_cursor_depth = odepth;
}
};
diff --git a/src/environ.cc b/src/environ.cc
index 753f7d1..8e50af1 100644
--- a/src/environ.cc
+++ b/src/environ.cc
@@ -786,7 +786,7 @@ environ::save_geometry ()
{
WINDOWPLACEMENT w;
w.length = sizeof w;
- if (GetWindowPlacement (app.toplev, &w))
+ if (GetWindowPlacement (active_app_frame().toplev, &w))
{
char name[256];
sprintf (name, "%dx%d",
diff --git a/src/except.cc b/src/except.cc
index 96e184f..ed0fb3d 100644
--- a/src/except.cc
+++ b/src/except.cc
@@ -411,7 +411,7 @@ cleanup_exception ()
# error "yet"
#endif
fprintf (fp, "Initial stack: %08x GC: %d\n\n",
- app.initial_stack, app.in_gc);
+ g_app.initial_stack, g_app.in_gc);
print_module_allocation (fp);
lisp_stack_trace (fp);
diff --git a/src/fileio.cc b/src/fileio.cc
index f73096a..284d7be 100644
--- a/src/fileio.cc
+++ b/src/fileio.cc
@@ -185,12 +185,12 @@ Buffer::read_file_contents (ReadFileContext &rfc, xread_stream &sin)
sprintf (msg, "Reading %d/%d bytes...",
total_bytes - sin.input_stream ().rest_chars (),
total_bytes);
- app.status_window.text (msg);
+ active_app_frame().status_window.text (msg);
}
}
if (*msg)
- app.status_window.restore ();
+ active_app_frame().status_window.restore ();
for (prev = 0, cp = rfc.r_chunk; cp; cp = cp->c_next)
{
@@ -1356,7 +1356,8 @@ do_auto_save (int not_all, int unnamed)
}
if (f)
format_message (Mauto_saving_done);
- app.auto_save_count = 0;
+ for(ApplicationFrame *app1 = first_app_frame(); app1; app1 = app1->a_next)
+ app1->auto_save_count = 0;
}
lisp
diff --git a/src/filer.cc b/src/filer.cc
index f8aca20..5066adc 100644
--- a/src/filer.cc
+++ b/src/filer.cc
@@ -381,7 +381,7 @@ FilerView::init_view (HWND hwnd, HWND hwnd_mask, HWND hwnd_marks,
fv_directory_index = -(filer_data::ICON_DIRECTORY + 1);
if (!fv_retrieve_icon)
{
- HIMAGELIST hil = ImageList_LoadBitmap (app.hinst,
+ HIMAGELIST hil = ImageList_LoadBitmap (active_app_frame().hinst,
MAKEINTRESOURCE (IDB_FILESEL),
16, 1, RGB (0, 0, 255));
ListView_SetImageList (fv_hwnd, hil, LVSIL_SMALL);
@@ -398,7 +398,7 @@ FilerView::init_view (HWND hwnd, HWND hwnd_mask, HWND hwnd_marks,
SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES))
fv_directory_index = fi.iIcon;
ListView_SetImageList (fv_hwnd, hil, LVSIL_SMALL);
- hil = ImageList_LoadBitmap (app.hinst,
+ hil = ImageList_LoadBitmap (active_app_frame().hinst,
MAKEINTRESOURCE (IDB_FILESEL),
16, 1, RGB (0, 0, 255));
ListView_SetSubImageList (fv_hwnd, hil, 0);
@@ -1229,16 +1229,16 @@ void
FilerView::echo_filename ()
{
if (xsymbol_value (Vfiler_echo_filename) == Qnil)
- app.status_window.clear ();
+ active_app_frame().status_window.clear ();
else if (fv_parent->check_idle ())
{
LV_ITEM lvi;
if (find_focused (&lvi) >= 0)
{
const filer_data *f = (filer_data *)lvi.lParam;
- app.status_window.text (*f->name ? f->name : "..");
+ active_app_frame().status_window.text (*f->name ? f->name : "..");
}
- app.status_window.clear (1);
+ active_app_frame().status_window.clear (1);
}
}
@@ -1565,7 +1565,7 @@ Filer::InitDialog ()
{
set_idle (0);
- HICON ico = LoadIcon (app.hinst,
+ HICON ico = LoadIcon (active_app_frame().hinst,
(modeless_p ()
? MAKEINTRESOURCE (IDI_FILER)
: MAKEINTRESOURCE (IDI_XYZZY)));
@@ -1694,7 +1694,7 @@ Filer::dispatch (lChar cc)
f_lkeymap = Qunbound;
if (fn == Qnil)
{
- app.status_window.puts (Ekey_not_bound, 1);
+ active_app_frame().status_window.puts (Ekey_not_bound, 1);
return 0;
}
@@ -2187,8 +2187,8 @@ Filer::WndProc (UINT msg, WPARAM wparam, LPARAM lparam)
if (dual_window_p ())
f_fv2.save_column ();
save_geometry ();
- if (IsWindowEnabled (app.toplev))
- SetActiveWindow (app.toplev);
+ if (IsWindowEnabled (active_app_frame().toplev))
+ SetActiveWindow (active_app_frame().toplev);
return 1;
case WM_NCDESTROY:
@@ -2218,13 +2218,13 @@ Filer::WndProc (UINT msg, WPARAM wparam, LPARAM lparam)
if (LOWORD (wparam) != WA_INACTIVE)
{
f_mlactive = f_mlfiler == this;
- app.status_window.set (f_hwnd_status);
+ active_app_frame().status_window.set (f_hwnd_status);
f_pview->echo_filename ();
}
return 0;
case WM_ACTIVATEAPP:
- PostThreadMessage (app.quit_thread_id, WM_PRIVATE_ACTIVATEAPP,
+ PostThreadMessage (active_app_frame().quit_thread_id, WM_PRIVATE_ACTIVATEAPP,
wparam, lparam);
return 0;
@@ -2272,7 +2272,7 @@ Filer::WndProc (UINT msg, WPARAM wparam, LPARAM lparam)
case WM_DRAWITEM:
if (f_ctx_menu2 && ((DRAWITEMSTRUCT *)lparam)->CtlType == ODT_MENU)
return f_ctx_menu2->HandleMenuMsg (msg, wparam, lparam) == NOERROR;
- return app.status_window.paint ((DRAWITEMSTRUCT *)lparam);
+ return active_app_frame().status_window.paint ((DRAWITEMSTRUCT *)lparam);
default:
return 0;
@@ -2458,10 +2458,10 @@ Filer::read_char () const
return decode_syschars (msg.wParam);
case WM_PRIVATE_QUIT:
- if (msg.hwnd == app.toplev && GetActiveWindow () == id_hwnd)
+ if (msg.hwnd == active_app_frame().toplev && GetActiveWindow () == id_hwnd)
{
xsymbol_value (Vquit_flag) = Qnil;
- return xchar_code (app.lquit_char);
+ return xchar_code (active_app_frame().lquit_char);
}
DispatchMessage (&msg);
QUIT;
@@ -2940,7 +2940,7 @@ vw_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
}
ViewerWindow::ViewerWindow ()
- : Window (0, 1)
+ : Window (&active_app_frame(), 0, 1)
{
w_hwnd = 0;
w_hwnd_ml = 0;
@@ -2957,7 +2957,7 @@ ViewerWindow::ViewerWindow ()
wc.lpfnWndProc = vw_wndproc;
wc.cbClsExtra = 0;
wc.cbWndExtra = sizeof (ViewerWindow *);
- wc.hInstance = app.hinst;
+ wc.hInstance = active_app_frame().hinst;
wc.hIcon = 0;
wc.hCursor = sysdep.hcur_arrow;
wc.hbrBackground = 0;
@@ -2984,7 +2984,7 @@ ViewerWindow::init (HWND parent, ViewerBuffer *bp)
return (int)CreateWindowEx (sysdep.Win4p () ? WS_EX_CLIENTEDGE : 0,
vw_classname, "",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE,
- 0, 0, 0, 0, parent, 0, app.hinst, this);
+ 0, 0, 0, 0, parent, 0, active_app_frame().hinst, this);
}
void
diff --git a/src/fnkey.cc b/src/fnkey.cc
index dc3e5e6..a70b6fc 100644
--- a/src/fnkey.cc
+++ b/src/fnkey.cc
@@ -254,7 +254,7 @@ FKWin::OnLButtonUp (int x, int y, int keys)
if (fk_vkey & FVK_CONTROL)
cc |= CCF_CTRL_BIT;
- app.kbdq.putc (cc);
+ active_app_frame().kbdq.putc (cc);
}
void
@@ -450,7 +450,7 @@ Fset_function_bar_label (lisp lcc, lisp label)
xvector_contents (xsymbol_value (Vfunction_bar_labels))[index] = label;
- app.active_frame.fnkey->refresh_button (n);
+ active_app_frame().active_frame.fnkey->refresh_button (n);
return Qt;
}
@@ -458,7 +458,7 @@ Fset_function_bar_label (lisp lcc, lisp label)
lisp
Fset_number_of_function_bar_labels (lisp n)
{
- if (!app.active_frame.fnkey->set_nbuttons (fixnum_value (n)))
+ if (!active_app_frame().active_frame.fnkey->set_nbuttons (fixnum_value (n)))
FEprogram_error (Ebad_function_bar_label_number, n);
return Qt;
}
@@ -466,5 +466,5 @@ Fset_number_of_function_bar_labels (lisp n)
lisp
Fnumber_of_function_bar_labels ()
{
- return make_fixnum (app.active_frame.fnkey->get_nbuttons ());
+ return make_fixnum (active_app_frame().active_frame.fnkey->get_nbuttons ());
}
diff --git a/src/fns.h b/src/fns.h
index afd76bb..10f335a 100644
--- a/src/fns.h
+++ b/src/fns.h
@@ -82,11 +82,12 @@ void main_loop ();
int start_quit_thread ();
int wait_process_terminate (HANDLE);
lisp execute_string (lisp);
-int end_wait_cursor (int);
-void set_ime_caret ();
-void recalc_toplevel ();
-void set_caret_blink_time ();
-void restore_caret_blink_time ();
+class ApplicationFrame;
+int end_wait_cursor (int, ApplicationFrame *app1 = NULL);
+void set_ime_caret (ApplicationFrame*);
+void recalc_toplevel (ApplicationFrame*);
+void set_caret_blink_time (ApplicationFrame *);
+void restore_caret_blink_time (ApplicationFrame*);
void toplev_gc_mark (void (*)(lisp));
int toplev_accept_mouse_move_p ();
@@ -108,7 +109,7 @@ const char *function_Char2name (Char);
const char *standard_Char2name (Char);
/* process.cc */
-void read_process_output (WPARAM, LPARAM);
+void read_process_output (ApplicationFrame *,WPARAM, LPARAM);
void wait_process_terminate (WPARAM, LPARAM);
int buffer_has_process (const Buffer *);
int query_kill_subprocesses ();
diff --git a/src/frame.cc b/src/frame.cc
new file mode 100644
index 0000000..e08a736
--- /dev/null
+++ b/src/frame.cc
@@ -0,0 +1,196 @@
+#include "ed.h"
+#include "mainframe.h"
+
+ApplicationFrame::ApplicationFrame ()
+ : mouse (kbdq)
+{
+ default_tab_columns = 8;
+ auto_save_count = 0;
+ toplevel_is_active = 0;
+ ime_composition = 0;
+ ime_open_mode = kbd_queue::IME_MODE_OFF;
+ sleep_timer_exhausted = 0;
+ last_vkeycode = -1;
+ kbd_repeat_count = 0;
+ wait_cursor_depth = 0;
+ f_in_drop = 0;
+ drop_window = 0;
+ drag_window = 0;
+ drag_buffer = 0;
+ f_protect_quit = 0;
+ hwnd_clipboard = 0;
+ last_cmd_tick = GetTickCount ();
+ f_auto_save_pending = 0;
+ default_caret_blink_time = 0;
+ last_blink_caret = 0;
+ lquit_char = make_char ('G' - '@');
+ quit_vkey = 'G';
+ quit_mod = MOD_CONTROL;
+ minibuffer_prompt_column = -1;
+ mframe = new main_frame;
+
+ memset((void*)&active_frame, 0, sizeof(active_frame));
+ a_next = 0;
+}
+
+ApplicationFrame::~ApplicationFrame ()
+{
+ mframe->cleanup();
+ delete mframe;
+}
+
+ApplicationFrame *root = NULL;
+
+static inline void
+ensure_root ()
+{
+ if(root == NULL)
+ root = new ApplicationFrame;
+}
+
+ApplicationFrame &
+active_app_frame ()
+{
+ ensure_root();
+ return *root;
+}
+
+main_frame &
+active_main_frame ()
+{
+ ensure_root();
+ return *root->mframe;
+}
+
+ApplicationFrame *
+first_app_frame ()
+{
+ ensure_root();
+ return root;
+}
+
+ApplicationFrame *
+retrieve_app_frame (HWND hwnd)
+{
+ return (ApplicationFrame *)GetWindowLong (hwnd, 0);
+}
+
+#include <vector>
+static std::vector<ApplicationFrame*> g_floating_frames;
+
+void
+app_frame_gc_mark (void (*f)(lisp))
+{
+ for(ApplicationFrame *app1 = root; app1; app1 = app1->a_next)
+ {
+ Window *wp;
+ for (wp = app1->active_frame.windows; wp; wp = wp->w_next)
+ (*f) (wp->lwp);
+ for (wp = app1->active_frame.reserved; wp; wp = wp->w_next)
+ (*f) (wp->lwp);
+ for (wp = app1->active_frame.deleted; wp; wp = wp->w_next)
+ (*f) (wp->lwp);
+
+ app1->mframe->gc_mark(f);
+
+ (*f)(app1->lfp);
+ app1->user_timer.gc_mark (f);
+ }
+}
+
+// this needs all appframe, so implement in this file.
+void
+Window::modify_all_mode_line ()
+{
+ for(ApplicationFrame *app1 = root; app1; app1 = app1->a_next)
+ for (Window *wp = app1->active_frame.windows; wp; wp = wp->w_next)
+ wp->w_disp_flags |= WDF_MODELINE;
+}
+
+void
+insert_app_frame (HWND hwnd, ApplicationFrame *app1)
+{
+ SetWindowLong (hwnd, 0, LONG (app1));
+}
+
+bool
+is_last_app_frame ()
+{
+ if(root == NULL || root->a_next == NULL)
+ return true;
+ return false;
+}
+
+void
+notify_focus (ApplicationFrame *app1)
+{
+ if (root == app1) // do nothing.
+ return;
+
+ ApplicationFrame *cur = root;
+ ApplicationFrame *prev = cur;
+ while(cur != app1)
+ {
+ prev = cur;
+ cur = cur->a_next;
+ }
+ assert(prev->a_next == app1);
+
+ prev->a_next = app1->a_next;
+ app1->a_next = root;
+ root = app1;
+ kbd_queue::change_application_window = true;
+ for(Window* wp = root->active_frame.windows; wp; wp = wp->w_next)
+ wp->update_window();
+}
+
+static void
+unchain_app_frame (ApplicationFrame *app1)
+{
+ if(root == app1){
+ root = app1->a_next;
+ app1->a_next = 0;
+ return;
+ }
+ ApplicationFrame *app = root;
+ while(app->a_next != app1)
+ app = app->a_next;
+ app->a_next = app1->a_next;
+ app1->a_next = 0;
+}
+
+void
+delete_app_frame (ApplicationFrame *app1)
+{
+ unchain_app_frame(app1);
+// delete app1;
+ g_floating_frames.push_back(app1);
+ kbd_queue::change_application_window = true;
+// notify_focus(root);
+}
+
+void
+delete_floating_app_frame ()
+{
+ for(std::vector<ApplicationFrame*>::iterator it = g_floating_frames.begin(); it != g_floating_frames.end(); it++)
+ {
+ ApplicationFrame *app1 = *it;
+ delete app1;
+ }
+ g_floating_frames.clear();
+}
+
+extern int init_app (HINSTANCE hinst, ApplicationFrame *app1);
+
+lisp
+Fmake_frame (lisp opt)
+{
+ HINSTANCE hinst = root->hinst;
+
+ ApplicationFrame *new_app = new ApplicationFrame;
+ new_app->a_next = root;
+ root = new_app;
+
+ init_app(hinst, new_app);
+ return new_app->lfp;
+}
diff --git a/src/gen-msg.cc b/src/gen-msg.cc
index d0d0455..3381f17 100644
--- a/src/gen-msg.cc
+++ b/src/gen-msg.cc
@@ -117,7 +117,7 @@ main (int argc, char **argv)
"get_message_string (int code)\n"
"{\n"
" static char buf[256];\n"
- " if (!LoadString (app.hinst, 1024 + code, buf, sizeof buf))\n"
+ " if (!LoadString (active_app().hinst, 1024 + code, buf, sizeof buf))\n"
" sprintf (buf, \"String resource %%d not found.\", code);\n"
" return buf;\n"
"}\n");
diff --git a/src/gen-syms.cc b/src/gen-syms.cc
index 3935450..339d9b2 100644
--- a/src/gen-syms.cc
+++ b/src/gen-syms.cc
@@ -835,6 +835,7 @@ static symbols sys[] =
/* init.cc */
SI_DEFVAR2 (*command-line-args*),
SI_DEFUN3 (*startup, 0, 0, 0),
+ SI_DEFUN3 (*startup-frame, 0, 0, 0),
/* toplev.cc */
SI_DEFUN3 (*minibuffer-message, 1, 1, 0),
@@ -1712,6 +1713,9 @@ static symbols ed[] =
DEFUN3 (enable-post-buffer-modified-hook, 1, 1, 0),
DEFUN3 (post-buffer-modified-hook-enabled-p, 0, 1, 0),
+ /* frame.cc */
+ DEFCMD3 (make-frame, 0, 1, 0, ""),
+
/* insdel.cc */
DEFUN3 (insert-file-contents, 1, 3, 0),
DEFUN3 (insert, 0, 0, FFneed_rest),
@@ -1763,6 +1767,7 @@ static symbols ed[] =
DEFUN3 (wait-object-p, 1, 0, 0),
DEFUN3 (char-encoding-p, 1, 0, 0),
MAKE_SYMBOL2Q (window),
+ MAKE_SYMBOL2Q (appframe),
MAKE_SYMBOL2Q (buffer),
MAKE_SYMBOL2Q (marker),
MAKE_SYMBOL2Q (regexp),
diff --git a/src/init.cc b/src/init.cc
index 7fd6a7c..17916dc 100644
--- a/src/init.cc
+++ b/src/init.cc
@@ -31,37 +31,13 @@ const char Application::ClientClassName[] = " ";
const char Application::ModelineClassName[] = " ";
const char FunctionKeyClassName[] = " ";
-Application app;
+Application g_app;
char enable_quit::q_enable;
Application::Application ()
- : mouse (kbdq)
-{
- default_tab_columns = 8;
- auto_save_count = 0;
- toplevel_is_active = 0;
- ime_composition = 0;
- ime_open_mode = kbd_queue::IME_MODE_OFF;
- sleep_timer_exhausted = 0;
- last_vkeycode = -1;
- kbd_repeat_count = 0;
- wait_cursor_depth = 0;
- f_in_drop = 0;
- drop_window = 0;
- drag_window = 0;
- drag_buffer = 0;
- f_protect_quit = 0;
- hwnd_clipboard = 0;
- last_cmd_tick = GetTickCount ();
- f_auto_save_pending = 0;
- default_caret_blink_time = 0;
- last_blink_caret = 0;
- lquit_char = make_char ('G' - '@');
- quit_vkey = 'G';
- quit_mod = MOD_CONTROL;
+{
ini_file_path = 0;
- minibuffer_prompt_column = -1;
int tem;
initial_stack = &tem;
@@ -235,7 +211,7 @@ init_user_inifile_path (const char *ini_file)
if (h != INVALID_HANDLE_VALUE)
{
CloseHandle (h);
- app.ini_file_path = xstrdup (path);
+ g_app.ini_file_path = xstrdup (path);
return;
}
}
@@ -247,16 +223,16 @@ init_user_inifile_path (const char *ini_file)
char *path = (char *)alloca (w2sl (xsymbol_value (Quser_config_path))
+ strlen (ini_file) + 32);
strcpy (w2s (path, xsymbol_value (Quser_config_path)), ini_file);
- app.ini_file_path = xstrdup (path);
+ g_app.ini_file_path = xstrdup (path);
}
static void
init_dump_path ()
{
- if (!*app.dump_image)
+ if (!*g_app.dump_image)
{
- int l = GetModuleFileName (0, app.dump_image, PATH_MAX);
- char *e = app.dump_image + l;
+ int l = GetModuleFileName (0, g_app.dump_image, PATH_MAX);
+ char *e = g_app.dump_image + l;
if (l > 4 && !_stricmp (e - 4, ".exe"))
e -= 3;
else
@@ -269,7 +245,7 @@ static void
init_env_symbols (const char *config_path, const char *ini_file)
{
xsymbol_value (Vfeatures) = xcons (Kxyzzy, xcons (Kieee_floating_point, Qnil));
- xsymbol_value (Qdump_image_path) = make_path (app.dump_image, 0);
+ xsymbol_value (Qdump_image_path) = make_path (g_app.dump_image, 0);
init_module_dir ();
init_current_dir ();
init_environ ();
@@ -567,16 +543,16 @@ static int
init_lisp_objects ()
{
const char *config_path = 0, *ini_file = 0;
- *app.dump_image = 0;
+ *g_app.dump_image = 0;
for (int ac = 1; ac < __argc - 1; ac += 2)
if (!strcmp (__argv[ac], "-image"))
{
char *tem;
- int l = WINFS::GetFullPathName (__argv[ac + 1], sizeof app.dump_image,
- app.dump_image, &tem);
- if (!l || l >= sizeof app.dump_image)
- *app.dump_image = 0;
+ int l = WINFS::GetFullPathName (__argv[ac + 1], sizeof g_app.dump_image,
+ g_app.dump_image, &tem);
+ if (!l || l >= sizeof g_app.dump_image)
+ *g_app.dump_image = 0;
}
else if (!strcmp (__argv[ac], "-config"))
config_path = __argv[ac + 1];
@@ -608,7 +584,7 @@ init_lisp_objects ()
}
catch (nonlocal_jump &)
{
- app.active_frame.selected = 0;
+ active_app_frame().active_frame.selected = 0;
report_out_of_memory ();
return 0;
}
@@ -616,16 +592,16 @@ init_lisp_objects ()
}
static int
-init_editor_objects ()
+init_editor_objects (ApplicationFrame *app1)
{
try
{
- Window::create_default_windows ();
+ Window::create_default_windows (app1);
create_default_buffers ();
}
catch (nonlocal_jump &)
{
- app.active_frame.selected = 0;
+ app1->active_frame.selected = 0;
report_out_of_memory ();
return 0;
}
@@ -638,6 +614,12 @@ Fsi_startup ()
return Fsi_load_library (make_string ("startup"), Qnil);
}
+lisp
+Fsi_startup_frame()
+{
+ return Fsi_load_library (make_string("fstartup"), Qnil);
+}
+
static int
register_wndclasses (HINSTANCE hinst)
{
@@ -646,21 +628,21 @@ register_wndclasses (HINSTANCE hinst)
wc.style = 0;
wc.lpfnWndProc = toplevel_wndproc;
wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
+ wc.cbWndExtra = sizeof(ApplicationFrame*);
wc.hInstance = hinst;
wc.hIcon = LoadIcon (hinst, MAKEINTRESOURCE (IDI_XYZZY));
wc.hCursor = sysdep.hcur_arrow;
wc.hbrBackground = 0;
wc.lpszMenuName = 0;
wc.lpszClassName = Application::ToplevelClassName;
- app.atom_toplev = RegisterClass (&wc);
- if (!app.atom_toplev)
+ active_app_frame().atom_toplev = RegisterClass (&wc);
+ if (!active_app_frame().atom_toplev)
return 0;
wc.style = 0;
wc.lpfnWndProc = frame_wndproc;
wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
+ wc.cbWndExtra = sizeof(ApplicationFrame*);
wc.hInstance = hinst;
wc.hIcon = 0;
wc.hCursor = sysdep.hcur_arrow;
@@ -778,10 +760,15 @@ sw_maximized_p (int sw)
}
static int
-init_app (HINSTANCE hinst, int passed_cmdshow, int &ole_initialized)
+init_root_app (HINSTANCE hinst, int passed_cmdshow, int &ole_initialized)
{
SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
- app.toplev = 0;
+ g_app.in_gc = 0; // whatever.
+ active_app_frame().toplev = 0;
+
+ active_app_frame().lfp = make_appframe();
+
+ xappframe_fp (active_app_frame().lfp) = &active_app_frame();
init_ucs2_table ();
@@ -807,7 +794,7 @@ init_app (HINSTANCE hinst, int passed_cmdshow, int &ole_initialized)
if (!init_lisp_objects ())
return 0;
- app.hinst = hinst;
+ active_app_frame().hinst = hinst;
if (!register_wndclasses (hinst))
return 0;
@@ -834,11 +821,11 @@ init_app (HINSTANCE hinst, int passed_cmdshow, int &ole_initialized)
ole_initialized = SUCCEEDED (OleInitialize (0));
- app.toplev = CreateWindow (Application::ToplevelClassName, TitleBarString,
+ active_app_frame().toplev = CreateWindow (Application::ToplevelClassName, TitleBarString,
WS_OVERLAPPEDWINDOW,
point.x, point.y, size.cx, size.cy,
- HWND_DESKTOP, 0, hinst, 0);
- if (!app.toplev)
+ HWND_DESKTOP, 0, hinst, &active_app_frame());
+ if (!active_app_frame().toplev)
return 0;
mouse_state::install_hook ();
@@ -848,7 +835,7 @@ init_app (HINSTANCE hinst, int passed_cmdshow, int &ole_initialized)
WINDOWPLACEMENT wp;
wp.length = sizeof wp;
- GetWindowPlacement (app.toplev, &wp);
+ GetWindowPlacement (active_app_frame().toplev, &wp);
if (point.x != CW_USEDEFAULT)
{
@@ -869,10 +856,10 @@ init_app (HINSTANCE hinst, int passed_cmdshow, int &ole_initialized)
wp.flags = 0;
wp.showCmd = cmdshow;
}
- SetWindowPlacement (app.toplev, &wp);
+ SetWindowPlacement (active_app_frame().toplev, &wp);
if (point.x != CW_USEDEFAULT && show_normal)
- SetWindowPos (app.toplev, 0, 0, 0,
+ SetWindowPos (active_app_frame().toplev, 0, 0, 0,
wp.rcNormalPosition.right - wp.rcNormalPosition.left,
wp.rcNormalPosition.bottom - wp.rcNormalPosition.top,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
@@ -881,14 +868,14 @@ init_app (HINSTANCE hinst, int passed_cmdshow, int &ole_initialized)
if (size.cx != CW_USEDEFAULT && show_normal)
{
RECT r;
- GetClientRect (app.toplev, &r);
+ GetClientRect (active_app_frame().toplev, &r);
AdjustWindowRect (&r, WS_OVERLAPPEDWINDOW, 0);
int aw = r.right - r.left, ah = r.bottom - r.top;
- GetWindowRect (app.toplev, &r);
+ GetWindowRect (active_app_frame().toplev, &r);
int ww = r.right - r.left, wh = r.bottom - r.top;
ww = min (ww, aw);
wh = min (wh, ah);
- SetWindowPos (app.toplev, 0, 0, 0, ww, wh,
+ SetWindowPos (active_app_frame().toplev, 0, 0, 0, ww, wh,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
}
#endif /* WINDOWBLINDS_FIXED */
@@ -898,13 +885,13 @@ init_app (HINSTANCE hinst, int passed_cmdshow, int &ole_initialized)
Fbegin_wait_cursor ();
- ShowWindow (app.toplev, cmdshow);
+ ShowWindow (active_app_frame().toplev, cmdshow);
if (sysdep.Win5p ())
- UpdateWindow (app.toplev);
+ UpdateWindow (active_app_frame().toplev);
- app.modeline_param.init (HFONT (SendMessage (app.hwnd_sw, WM_GETFONT, 0, 0)));
+ active_app_frame().modeline_param.init (HFONT (SendMessage (active_app_frame().hwnd_sw, WM_GETFONT, 0, 0)));
- if (!init_editor_objects ())
+ if (!init_editor_objects (&active_app_frame()))
return 0;
try {Dde::initialize ();} catch (Dde::Exception &) {}
@@ -912,13 +899,59 @@ init_app (HINSTANCE hinst, int passed_cmdshow, int &ole_initialized)
return 1;
}
+int
+init_app(HINSTANCE hinst, ApplicationFrame *app1)
+{
+ app1->toplev = 0;
+ app1->hinst = hinst;
+
+ app1->lfp = make_appframe();
+
+ app1->toplev = CreateWindow (Application::ToplevelClassName, TitleBarString,
+ WS_OVERLAPPEDWINDOW,
+ // point.x, point.y, size.cx, size.cy,
+ 10, 10, 600, 480,
+ HWND_DESKTOP, 0, hinst, app1);
+
+ if (!app1->toplev)
+ return 0;
+
+ xappframe_fp (app1->lfp) = app1;
+
+ if (!start_quit_thread())
+ return 0;
+
+ Fbegin_wait_cursor ();
+
+ ShowWindow(app1->toplev, SW_SHOW);
+
+ if (sysdep.Win5p ())
+ UpdateWindow (app1->toplev);
+
+ app1->modeline_param.init (HFONT (SendMessage (app1->hwnd_sw, WM_GETFONT, 0, 0)));
+
+ if (!init_editor_objects (app1))
+ return 0;
+
+ try
+ {
+ Ffuncall (Ssi_startup_frame, Qnil);
+ }
+ catch (nonlocal_jump &)
+ {
+ print_condition (nonlocal_jump::data());
+ }
+
+ return 1;
+}
+
int PASCAL
WinMain (HINSTANCE hinst, HINSTANCE, LPSTR, int cmdshow)
{
int ole_initialized = 0;
- if (init_app (hinst, cmdshow, ole_initialized))
+ if (init_root_app (hinst, cmdshow, ole_initialized))
{
- xyzzy_instance xi (app.toplev);
+ xyzzy_instance xi (active_app_frame().toplev);
MSG msg;
while (PeekMessage (&msg, 0, 0, 0, PM_REMOVE))
@@ -946,7 +979,7 @@ WinMain (HINSTANCE hinst, HINSTANCE, LPSTR, int cmdshow)
start_listen_server ();
Fset_cursor (xsymbol_value (Vcursor_shape));
end_wait_cursor (1);
- app.kbdq.init_kbd_encoding ();
+ active_app_frame().kbdq.init_kbd_encoding ();
while (1)
{
@@ -960,7 +993,7 @@ WinMain (HINSTANCE hinst, HINSTANCE, LPSTR, int cmdshow)
}
}
}
- app.kbdq.gime.disable ();
+ active_app_frame().kbdq.gime.disable ();
cleanup_lisp_objects ();
terminate_normally = 1;
}
@@ -980,10 +1013,10 @@ WinMain (HINSTANCE hinst, HINSTANCE, LPSTR, int cmdshow)
mouse_state::remove_hook ();
- if (app.toplev)
+ if (active_app_frame().toplev)
{
end_listen_server ();
- DestroyWindow (app.toplev);
+ DestroyWindow (active_app_frame().toplev);
}
if (ole_initialized)
@@ -998,13 +1031,13 @@ WinMain (HINSTANCE hinst, HINSTANCE, LPSTR, int cmdshow)
b_next = bp->b_next;
delete bp;
}
- for (Window *wp = app.active_frame.windows, *w_next; wp; wp = w_next)
+ for (Window *wp = active_app_frame().active_frame.windows, *w_next; wp; wp = w_next)
{
w_next = wp->w_next;
delete wp;
}
- g_frame.cleanup ();
+ // active_main_frame().cleanup ();
fflush (stdout);
fflush (stderr);
diff --git a/src/insdel.cc b/src/insdel.cc
index 5ec2d7f..73e5b78 100644
--- a/src/insdel.cc
+++ b/src/insdel.cc
@@ -366,6 +366,8 @@ Buffer::move_gap (Point &w_point, int requested)
return allocate_new_chunks (w_point, requested);
}
+extern ApplicationFrame *first_app_frame();
+
void
Buffer::adjust_insertion (const Point &point, int size)
{
@@ -399,20 +401,21 @@ Buffer::adjust_insertion (const Point &point, int size)
ADJINS (xmarker_point (x));
}
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
- if (wp->w_bufp == this)
- {
- ADJINS (wp->w_point.p_point);
- if (&wp->w_point != &point)
- set_point_no_restrictions (wp->w_point, wp->w_point.p_point);
- ADJINS (wp->w_mark);
- ADJINS (wp->w_selection_point);
- ADJINS (wp->w_selection_marker);
- ADJINS (wp->w_reverse_region.p1);
- ADJINS (wp->w_reverse_region.p2);
- ADJINS (wp->w_disp);
- ADJINS (wp->w_last_disp);
- }
+ for (ApplicationFrame *app1 = first_app_frame(); app1; app1 = app1->a_next)
+ for (Window *wp = app1->active_frame.windows; wp; wp = wp->w_next)
+ if (wp->w_bufp == this)
+ {
+ ADJINS (wp->w_point.p_point);
+ if (&wp->w_point != &point)
+ set_point_no_restrictions (wp->w_point, wp->w_point.p_point);
+ ADJINS (wp->w_mark);
+ ADJINS (wp->w_selection_point);
+ ADJINS (wp->w_selection_marker);
+ ADJINS (wp->w_reverse_region.p1);
+ ADJINS (wp->w_reverse_region.p2);
+ ADJINS (wp->w_disp);
+ ADJINS (wp->w_last_disp);
+ }
for (WindowConfiguration *wc = WindowConfiguration::wc_chain;
wc; wc = wc->wc_prev)
@@ -842,7 +845,7 @@ Buffer::adjust_deletion (const Point &point, int size)
ADJDEL (xmarker_point (x));
}
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = active_app_frame().active_frame.windows; wp; wp = wp->w_next)
if (wp->w_bufp == this)
{
if (point.p_point < wp->w_disp && point.p_point + size > wp->w_disp)
@@ -1199,7 +1202,7 @@ Fcopy_to_clipboard (lisp string)
}
int result = 0;
- if (open_clipboard (app.toplev))
+ if (open_clipboard (active_app_frame().toplev))
{
if (EmptyClipboard ())
for (int i = 0; i < numberof (clp) && clp[i].hgl; i++)
@@ -1463,7 +1466,7 @@ Fget_clipboard_data ()
{
int result = -1;
lisp lstring = make_simple_string ();
- if (open_clipboard (app.toplev))
+ if (open_clipboard (active_app_frame().toplev))
{
lisp encoding = symbol_value (Vclipboard_char_encoding,
selected_buffer ());
diff --git a/src/kbd.cc b/src/kbd.cc
index bb40d41..5d8a877 100644
--- a/src/kbd.cc
+++ b/src/kbd.cc
@@ -105,10 +105,19 @@ kbd_queue::puts (const char *string, int l)
return 1;
}
+#include <exception>
+
+bool kbd_queue::change_application_window = false;
+
lChar
kbd_queue::peek (int req_mouse_move)
{
lChar c;
+ if (kbd_queue::change_application_window)
+ {
+ kbd_queue::change_application_window = false;
+ throw std::exception();
+ }
if (pending != lChar_EOF)
{
c = pending;
@@ -195,8 +204,8 @@ kbd_queue::sleep_timer::sleep_timer (kbd_queue &q)
kbd_queue::sleep_timer::~sleep_timer ()
{
- KillTimer (app.toplev, TID_SLEEP);
- app.sleep_timer_exhausted = 0;
+ KillTimer (active_app_frame().toplev, TID_SLEEP);
+ active_app_frame().sleep_timer_exhausted = 0;
s_kbdq.st_start_time = s_save_start_time;
s_kbdq.st_timeout = s_save_timeout;
if (s_kbdq.st_timeout >= 0)
@@ -204,9 +213,9 @@ kbd_queue::sleep_timer::~sleep_timer ()
DWORD req = s_kbdq.st_start_time + s_kbdq.st_timeout;
DWORD curtime = GetTickCount ();
if (req >= curtime)
- app.sleep_timer_exhausted = 1;
+ active_app_frame().sleep_timer_exhausted = 1;
else
- SetTimer (app.toplev, TID_SLEEP, req - curtime, 0);
+ SetTimer (active_app_frame().toplev, TID_SLEEP, req - curtime, 0);
}
}
@@ -216,9 +225,9 @@ kbd_queue::sleep_timer::wait (int timeout, int kbdp)
disable_kbd dkbd (s_kbdq);
s_kbdq.st_start_time = GetTickCount ();
s_kbdq.st_timeout = timeout;
- app.sleep_timer_exhausted = 0;
- SetTimer (app.toplev, TID_SLEEP, timeout, 0);
- while ((!kbdp || s_kbdq.head == s_kbdq.tail) && !app.sleep_timer_exhausted)
+ active_app_frame().sleep_timer_exhausted = 0;
+ SetTimer (active_app_frame().toplev, TID_SLEEP, timeout, 0);
+ while ((!kbdp || s_kbdq.head == s_kbdq.tail) && !active_app_frame().sleep_timer_exhausted)
{
QUIT;
MSG msg;
@@ -329,7 +338,7 @@ kbd_queue::track_popup_menu (HMENU hmenu, int button, const POINT &p)
if (idlep ())
{
result = TrackPopupMenu (hmenu, TPM_RETURNCMD | TPM_LEFTALIGN | button,
- p.x, p.y, 0, app.toplev, 0);
+ p.x, p.y, 0, active_app_frame().toplev, 0);
if (result == -1)
result = 0;
}
@@ -347,13 +356,13 @@ kbd_queue::close_ime ()
last_ime_status = -1;
else if (last_ime_status == -1)
{
- HIMC imc = gime.ImmGetContext (app.toplev);
+ HIMC imc = gime.ImmGetContext (active_app_frame().toplev);
if (imc)
{
last_ime_status = gime.ImmGetOpenStatus (imc);
if (last_ime_status)
gime.ImmSetOpenStatus (imc, 0);
- gime.ImmReleaseContext (app.toplev, imc);
+ gime.ImmReleaseContext (active_app_frame().toplev, imc);
}
}
}
@@ -367,11 +376,11 @@ kbd_queue::restore_ime ()
&& xsymbol_value (Vime_control) != Qnil
&& last_ime_status != -1)
{
- HIMC imc = gime.ImmGetContext (app.toplev);
+ HIMC imc = gime.ImmGetContext (active_app_frame().toplev);
if (imc)
{
gime.ImmSetOpenStatus (imc, last_ime_status);
- gime.ImmReleaseContext (app.toplev, imc);
+ gime.ImmReleaseContext (active_app_frame().toplev, imc);
last_ime_status = -1;
}
}
@@ -380,13 +389,13 @@ kbd_queue::restore_ime ()
int
kbd_queue::toggle_ime (int new_stat, int update_last_ime_status)
{
- HIMC imc = gime.ImmGetContext (app.toplev);
+ HIMC imc = gime.ImmGetContext (active_app_frame().toplev);
if (!imc)
return 0;
int old_stat = gime.ImmGetOpenStatus (imc) ? IME_MODE_ON : IME_MODE_OFF;
if (new_stat == IME_MODE_TOGGLE || new_stat != old_stat)
gime.ImmSetOpenStatus (imc, old_stat != IME_MODE_ON);
- gime.ImmReleaseContext (app.toplev, imc);
+ gime.ImmReleaseContext (active_app_frame().toplev, imc);
if (update_last_ime_status)
last_ime_status = -1;
return old_stat;
@@ -442,7 +451,7 @@ kbd_queue::lookup_kbd_macro (lisp string) const
void
check_kbd_enable ()
{
- if (IsWindowEnabled (app.toplev))
+ if (IsWindowEnabled (active_app_frame().toplev))
return;
FEprogram_error (Ekbd_input_is_disabled);
}
@@ -529,7 +538,7 @@ translate_unicode (HWND hwnd, WPARAM wparam, LPARAM lparam)
BOOL
XyzzyTranslateMessage (const MSG *msg)
{
- if (msg->hwnd == app.toplev || Filer::filer_ancestor_p (msg->hwnd))
+ if (msg->hwnd == active_app_frame().toplev || Filer::filer_ancestor_p (msg->hwnd))
{
switch (msg->message)
{
@@ -545,7 +554,7 @@ XyzzyTranslateMessage (const MSG *msg)
if (msg->wParam == VK_PROCESSKEY
&& xsymbol_value (Vime_does_not_process_control_backslach) != Qnil)
{
- int key = to_ascii_char (app.kbdq.gime.ImmGetVirtualKey (msg->hwnd), msg->lParam);
+ int key = to_ascii_char (active_app_frame().kbdq.gime.ImmGetVirtualKey (msg->hwnd), msg->lParam);
if (key == '\\' || key == '_')
{
PostMessage (msg->hwnd, msg->message == WM_KEYDOWN ? WM_CHAR : WM_SYSCHAR,
@@ -555,7 +564,7 @@ XyzzyTranslateMessage (const MSG *msg)
}
else
{
- if (app.kbdq.unicode_kbd_p () && msg->message == WM_KEYDOWN
+ if (active_app_frame().kbdq.unicode_kbd_p () && msg->message == WM_KEYDOWN
&& exkey_index (msg->wParam, 0) < 0
&& translate_unicode (msg->hwnd, msg->wParam, msg->lParam))
return 1;
@@ -579,7 +588,7 @@ XyzzyTranslateMessage (const MSG *msg)
break;
}
}
- return app.kbdq.gime.TranslateMessage (msg);
+ return active_app_frame().kbdq.gime.TranslateMessage (msg);
}
static lChar
@@ -921,7 +930,7 @@ void
kbd_queue::init_kbd_encoding (LANGID langid)
{
set_kbd_langid (langid);
- ime_prop = app.kbdq.gime.ImmGetProperty (get_kbd_layout (), IGP_PROPERTY);
+ ime_prop = active_app_frame().kbdq.gime.ImmGetProperty (get_kbd_layout (), IGP_PROPERTY);
unicode_kbd = 0;
for (lisp p = xsymbol_value (Vkeyboard_layout_list); consp (p); p = xcdr (p))
@@ -965,31 +974,31 @@ kbd_queue::kbd_encoding_font ()
switch (xchar_encoding_type (encoding))
{
case encoding_sjis:
- return app.text_font.font (FONT_JP);
+ return active_app_frame().text_font.font (FONT_JP);
case encoding_big5:
- return app.text_font.font (FONT_CN_TRADITIONAL);
+ return active_app_frame().text_font.font (FONT_CN_TRADITIONAL);
case encoding_windows_codepage:
switch (xchar_encoding_windows_codepage (encoding))
{
case CP_JAPANESE:
- return app.text_font.font (FONT_JP);
+ return active_app_frame().text_font.font (FONT_JP);
case CP_KOREAN:
- return app.text_font.font (FONT_HANGUL);
+ return active_app_frame().text_font.font (FONT_HANGUL);
case CP_CN_TRADITIONAL:
- return app.text_font.font (FONT_CN_TRADITIONAL);
+ return active_app_frame().text_font.font (FONT_CN_TRADITIONAL);
case CP_CN_SIMPLIFIED:
- return app.text_font.font (FONT_CN_SIMPLIFIED);
+ return active_app_frame().text_font.font (FONT_CN_SIMPLIFIED);
case CP_CYRILLIC:
- return app.text_font.font (FONT_CYRILLIC);
+ return active_app_frame().text_font.font (FONT_CYRILLIC);
case CP_GREEK:
- return app.text_font.font (FONT_GREEK);
+ return active_app_frame().text_font.font (FONT_GREEK);
}
break;
@@ -998,20 +1007,20 @@ kbd_queue::kbd_encoding_font ()
{
case ENCODING_LANG_JP:
case ENCODING_LANG_JP2:
- return app.text_font.font (FONT_JP);
+ return active_app_frame().text_font.font (FONT_JP);
case ENCODING_LANG_KR:
- return app.text_font.font (FONT_HANGUL);
+ return active_app_frame().text_font.font (FONT_HANGUL);
case ENCODING_LANG_CN_GB:
- return app.text_font.font (FONT_CN_SIMPLIFIED);
+ return active_app_frame().text_font.font (FONT_CN_SIMPLIFIED);
case ENCODING_LANG_CN_BIG5:
case ENCODING_LANG_CN:
- return app.text_font.font (FONT_CN_TRADITIONAL);
+ return active_app_frame().text_font.font (FONT_CN_TRADITIONAL);
}
}
- return app.text_font.font (FONT_LATIN);
+ return active_app_frame().text_font.font (FONT_LATIN);
}
@@ -1046,7 +1055,7 @@ key_sequence::notice (int n, int cont)
*b++ = ' ';
}
*b = 0;
- app.status_window.puts (buf, 1);
+ active_app_frame().status_window.puts (buf, 1);
}
void
@@ -1166,11 +1175,11 @@ ime_comp_queue::pop ()
lisp
Fsit_for (lisp timeout, lisp nodisp)
{
- if (!app.kbdq.macro_is_running ())
+ if (!active_app_frame().kbdq.macro_is_running ())
{
if (!nodisp || nodisp == Qnil)
refresh_screen (0);
- app.kbdq.sit_for (DWORD (coerce_to_double_float (timeout) * 1000));
+ active_app_frame().kbdq.sit_for (DWORD (coerce_to_double_float (timeout) * 1000));
}
return Qnil;
}
@@ -1178,14 +1187,14 @@ Fsit_for (lisp timeout, lisp nodisp)
lisp
Fsleep_for (lisp timeout)
{
- app.kbdq.sleep_for (DWORD (coerce_to_double_float (timeout) * 1000));
+ active_app_frame().kbdq.sleep_for (DWORD (coerce_to_double_float (timeout) * 1000));
return Qnil;
}
lisp
Fdo_events ()
{
- app.kbdq.process_events ();
+ active_app_frame().kbdq.process_events ();
return Qnil;
}
@@ -1194,9 +1203,9 @@ Freset_prefix_args (lisp arg, lisp value)
{
xsymbol_value (Vnext_prefix_args) = arg;
xsymbol_value (Vnext_prefix_value) = value;
- app.keyseq.again (!app.kbdq.macro_is_running ());
- app.kbdq.close_ime ();
- app.kbdq.keep_next_command_key ();
+ active_app_frame().keyseq.again (!active_app_frame().kbdq.macro_is_running ());
+ active_app_frame().kbdq.close_ime ();
+ active_app_frame().kbdq.keep_next_command_key ();
Fcontinue_pre_selection ();
return Qt;
}
@@ -1209,10 +1218,10 @@ Fset_next_prefix_args (lisp arg, lisp value, lisp c)
if (c && c != Qnil)
{
check_char (c);
- app.keyseq.push (xchar_code (c), !app.kbdq.macro_is_running ());
+ active_app_frame().keyseq.push (xchar_code (c), !active_app_frame().kbdq.macro_is_running ());
Fcontinue_pre_selection ();
- app.kbdq.close_ime ();
- app.kbdq.keep_next_command_key ();
+ active_app_frame().kbdq.close_ime ();
+ active_app_frame().kbdq.keep_next_command_key ();
}
return Qt;
}
@@ -1220,30 +1229,30 @@ Fset_next_prefix_args (lisp arg, lisp value, lisp c)
lisp
Fstart_save_kbd_macro ()
{
- if (app.kbdq.save_p ())
+ if (active_app_frame().kbdq.save_p ())
return Qnil;
- app.kbdq.start_macro ();
+ active_app_frame().kbdq.start_macro ();
return Qt;
}
lisp
Fstop_save_kbd_macro ()
{
- if (!app.kbdq.save_p ())
+ if (!active_app_frame().kbdq.save_p ())
return Qnil;
- return app.kbdq.end_macro ();
+ return active_app_frame().kbdq.end_macro ();
}
lisp
Fkbd_macro_saving_p ()
{
- return boole (app.kbdq.save_p ());
+ return boole (active_app_frame().kbdq.save_p ());
}
lisp
Ftoggle_ime (lisp arg)
{
- return boole (app.kbdq.toggle_ime (arg
+ return boole (active_app_frame().kbdq.toggle_ime (arg
? (arg == Qnil
? kbd_queue::IME_MODE_OFF
: kbd_queue::IME_MODE_ON)
@@ -1254,20 +1263,20 @@ lisp
Fget_recent_keys ()
{
Char b[128];
- int n = app.kbdq.copy_queue (b, numberof (b));
+ int n = active_app_frame().kbdq.copy_queue (b, numberof (b));
return make_string (b, n);
}
lisp
Fget_ime_mode ()
{
- return boole (app.ime_open_mode == kbd_queue::IME_MODE_ON);
+ return boole (active_app_frame().ime_open_mode == kbd_queue::IME_MODE_ON);
}
lisp
Fget_ime_composition_string ()
{
- const ime_comp_queue::pair *p = app.ime_compq.fetch ();
+ const ime_comp_queue::pair *p = active_app_frame().ime_compq.fetch ();
if (!p)
return Qnil;
return xcons (make_string (p->comp, p->compl),
@@ -1277,7 +1286,7 @@ Fget_ime_composition_string ()
lisp
Fpop_ime_composition_string ()
{
- const ime_comp_queue::pair *p = app.ime_compq.pop ();
+ const ime_comp_queue::pair *p = active_app_frame().ime_compq.pop ();
if (!p)
return Qnil;
return xcons (make_string (p->comp, p->compl),
@@ -1290,7 +1299,7 @@ Fset_ime_read_string (lisp string)
char *read;
if (!string || string == Qnil)
{
- const ime_comp_queue::pair *p = app.ime_compq.fetch ();
+ const ime_comp_queue::pair *p = active_app_frame().ime_compq.fetch ();
if (!p)
return Qnil;
read = (char *)alloca (w2sl (p->read, p->readl) + 1);
@@ -1302,12 +1311,12 @@ Fset_ime_read_string (lisp string)
read = (char *)alloca (w2sl (string) + 1);
w2s (read, string);
}
- HIMC hIMC = app.kbdq.gime.ImmGetContext (app.toplev);
+ HIMC hIMC = active_app_frame().kbdq.gime.ImmGetContext (active_app_frame().toplev);
if (!hIMC)
return Qnil;
- int f = app.kbdq.gime.ImmSetCompositionString (hIMC, SCS_SETSTR, 0, 0,
+ int f = active_app_frame().kbdq.gime.ImmSetCompositionString (hIMC, SCS_SETSTR, 0, 0,
read, strlen (read));
- app.kbdq.gime.ImmReleaseContext (app.toplev, hIMC);
+ active_app_frame().kbdq.gime.ImmReleaseContext (active_app_frame().toplev, hIMC);
return boole (f);
}
@@ -1333,7 +1342,7 @@ Fime_register_word_dialog (lisp lcomp, lisp lread)
*e = 0;
}
}
- return boole (app.kbdq.gime.ImmConfigureIME (GetKeyboardLayout (0), app.toplev,
+ return boole (active_app_frame().kbdq.gime.ImmConfigureIME (GetKeyboardLayout (0), active_app_frame().toplev,
IME_CONFIG_REGISTERWORD, &rw));
}
@@ -1341,8 +1350,8 @@ lisp
Fenable_global_ime (lisp f)
{
if (f == Qnil)
- app.kbdq.gime.disable ();
- else if (!app.kbdq.gime.enable (&app.atom_toplev, 1))
+ active_app_frame().kbdq.gime.disable ();
+ else if (!active_app_frame().kbdq.gime.enable (&active_app_frame().atom_toplev, 1))
FEsimple_win32_error (GetLastError ());
return Qt;
}
@@ -1354,7 +1363,7 @@ get_kbd_layout_name (HKL hkl, char *buf, int size)
sprintf (k, "SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\%08x", hkl);
ReadRegistry r (HKEY_LOCAL_MACHINE, k);
return ((!r.fail () && r.get ("Layout Text", buf, size) > 0)
- || app.kbdq.gime.ImmGetDescription (hkl, buf, size) > 0);
+ || active_app_frame().kbdq.gime.ImmGetDescription (hkl, buf, size) > 0);
}
typedef UINT (WINAPI *GETKEYBOARDLAYOUTLIST)(int, HKL *);
@@ -1440,7 +1449,7 @@ Fselect_kbd_layout (lisp layout)
lisp
Fcurrent_kbd_layout ()
{
- HKL hkl = app.kbdq.get_kbd_layout ();
+ HKL hkl = active_app_frame().kbdq.get_kbd_layout ();
char buf[256];
if (get_kbd_layout_name (hkl, buf, sizeof buf)
|| get_kbd_layout_name (HKL (HIWORD (hkl)), buf, sizeof buf))
diff --git a/src/kbd.h b/src/kbd.h
index 1575804..b930d53 100644
--- a/src/kbd.h
+++ b/src/kbd.h
@@ -31,6 +31,7 @@ class kbd_queue
friend kbd_macro_context;
int putraw (lChar);
public:
+ static bool change_application_window;
enum input_mode
{
im_normal,
diff --git a/src/ldialog.cc b/src/ldialog.cc
index 87b5dcd..f2801d8 100644
--- a/src/ldialog.cc
+++ b/src/ldialog.cc
@@ -955,8 +955,8 @@ item_string (lisp item, char *buf, int size)
else if (c == '\t')
{
int col = b - b0;
- int goal = ((col + app.default_tab_columns) / app.default_tab_columns
- * app.default_tab_columns);
+ int goal = ((col + active_app_frame().default_tab_columns) / active_app_frame().default_tab_columns
+ * active_app_frame().default_tab_columns);
for (int n = min (goal - col, be - b); n > 0; n--)
*b++ = ' ';
}
@@ -1279,7 +1279,7 @@ ldialog_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
return 1;
case WM_ACTIVATEAPP:
- PostThreadMessage (app.quit_thread_id, WM_PRIVATE_ACTIVATEAPP,
+ PostThreadMessage (active_app_frame().quit_thread_id, WM_PRIVATE_ACTIVATEAPP,
wparam, lparam);
return 0;
@@ -1390,11 +1390,11 @@ PropSheetFont::change_font (const char *id)
return 0;
HGLOBAL result = 0;
- HRSRC hrsrc = FindResource (app.hinst, id, RT_DIALOG);
- const DLGTEMPLATE *tmpl = (DLGTEMPLATE *)LoadResource (app.hinst, hrsrc);
+ HRSRC hrsrc = FindResource (active_app_frame().hinst, id, RT_DIALOG);
+ const DLGTEMPLATE *tmpl = (DLGTEMPLATE *)LoadResource (active_app_frame().hinst, hrsrc);
if (tmpl)
{
- DWORD size = SizeofResource (app.hinst, hrsrc);
+ DWORD size = SizeofResource (active_app_frame().hinst, hrsrc);
result = change_font (tmpl, size);
}
return result;
@@ -1706,7 +1706,7 @@ Fdialog_box (lisp dialog, lisp init, lisp handlers)
| WS_CAPTION | WS_SYSMENU),
0);
- int result = DialogBoxIndirectParam (app.hinst,
+ int result = DialogBoxIndirectParam (active_app_frame().hinst,
d.get_template (),
get_active_window (), ldialog_proc,
LPARAM (&d));
@@ -1799,7 +1799,7 @@ lprop_page_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
#if 0
case WM_ACTIVATEAPP:
- PostThreadMessage (app.quit_thread_id, WM_PRIVATE_ACTIVATEAPP,
+ PostThreadMessage (active_app_frame().quit_thread_id, WM_PRIVATE_ACTIVATEAPP,
wparam, lparam);
return 0;
#endif
@@ -1832,7 +1832,7 @@ PropPage::init_page (PropSheet *parent, int page_no, PROPSHEETPAGE *psp, lisp in
p_page_no = page_no;
psp->dwSize = sizeof *psp;
psp->dwFlags = PSP_DLGINDIRECT;
- psp->hInstance = app.hinst;
+ psp->hInstance = active_app_frame().hinst;
psp->pResource = get_template (),
psp->pszIcon = 0;
psp->pfnDlgProc = lprop_page_proc;
@@ -1970,7 +1970,7 @@ Fproperty_sheet (lisp pages, lisp caption, lisp lstart_page)
psh.dwSize = sizeof psh;
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USECALLBACK | PSH_NOAPPLYNOW;
psh.hwndParent = get_active_window ();
- psh.hInstance = app.hinst;
+ psh.hInstance = active_app_frame().hinst;
psh.pszIcon = 0;
psh.pszCaption = b;
psh.nPages = total_pages;
diff --git a/src/lisp.h b/src/lisp.h
index c5fda64..7120c5e 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -121,6 +121,7 @@ enum lisp_object_type
Tdll_function, // DLL内の関数
Tc_callable, // Cから呼べる関数
Twindow, // ウィンドウ
+ Tappframe, // AppFrame, what emacs call frame.
Tbuffer, // バッファ
Tmarker, // マーカ
Tsyntax_table, // シンタックステーブル
diff --git a/src/listen.cc b/src/listen.cc
index b579930..294311f 100644
--- a/src/listen.cc
+++ b/src/listen.cc
@@ -73,7 +73,7 @@ init_listen_server ()
{
hevent_listen = CreateEvent (0, 1, 0, 0);
if (hevent_listen)
- SetProp (app.toplev, xyzzysrv_name, hevent_listen);
+ SetProp (active_app_frame().toplev, xyzzysrv_name, hevent_listen);
wm_private_xyzzysrv = RegisterWindowMessage (xyzzysrv_name);
}
@@ -92,7 +92,7 @@ end_listen_server ()
SetEvent (hevent_listen);
CloseHandle (hevent_listen);
hevent_listen = 0;
- RemoveProp (app.toplev, xyzzysrv_name);
+ RemoveProp (active_app_frame().toplev, xyzzysrv_name);
}
}
@@ -151,7 +151,7 @@ read_listen_server (WPARAM wparam, LPARAM lparam)
{
param->pid = GetCurrentProcessId ();
param->hevent = xwait_object_hevent (obj);
- param->hwnd = app.toplev;
+ param->hwnd = active_app_frame().toplev;
}
r = 1;
}
diff --git a/src/lprint.cc b/src/lprint.cc
index 387868d..b5fada6 100644
--- a/src/lprint.cc
+++ b/src/lprint.cc
@@ -236,6 +236,7 @@ print_circle::setup1 (lisp object)
case Tdouble_float:
case Tcomplex:
case Twindow:
+ case Tappframe:
case Tbuffer:
case Tmarker:
case Tsyntax_table:
@@ -1449,6 +1450,12 @@ print_window (wStream &stream, const print_control &, lisp object)
print_unreadable_object (stream, object, "window");
}
+static inline void
+print_appframe (wStream &stream, const print_control &, lisp object)
+{
+ print_unreadable_object (stream, object, "appframe");
+}
+
static void
print_buffer_name (wStream &stream, const Buffer *bp)
{
@@ -1714,6 +1721,10 @@ print_sexp (wStream &stream, const print_control &pc, lisp object, int level)
print_window (stream, pc, object);
break;
+ case Tappframe:
+ print_appframe(stream, pc, object);
+ break;
+
case Tbuffer:
print_buffer (stream, pc, object);
break;
@@ -3896,13 +3907,13 @@ putmsg (wStream &stream, int msgboxp, int style, int beep)
if (msgboxp)
{
w2s ((char *)b, b + 1, l);
- app.status_window.clear ();
+ active_app_frame().status_window.clear ();
return MsgBox (get_active_window (), (char *)b, TitleBarString, style, beep);
}
else
{
- app.status_window.puts (b + 1, l);
- app.status_window.putc ('\n');
+ active_app_frame().status_window.puts (b + 1, l);
+ active_app_frame().status_window.putc ('\n');
if (beep)
Fding ();
return 0;
@@ -4242,7 +4253,7 @@ format_message (message_code m, ...)
char buf[2048];
vsprintf (buf, fmt, ap);
va_end (ap);
- app.status_window.puts (buf, 1);
+ active_app_frame().status_window.puts (buf, 1);
}
int
diff --git a/src/lread.cc b/src/lread.cc
index fd65c49..66494dd 100644
--- a/src/lread.cc
+++ b/src/lread.cc
@@ -2123,7 +2123,7 @@ load_file (lisp filename, lisp realname, lisp if_does_not_exist,
b += l;
}
b = a2w (b, "...\n");
- app.status_window.puts (buf, b - buf);
+ active_app_frame().status_window.puts (buf, b - buf);
b--;
}
@@ -2151,7 +2151,7 @@ load_file (lisp filename, lisp realname, lisp if_does_not_exist,
if (verbose)
{
b = a2w (b, "done\n");
- app.status_window.puts (buf, b - buf);
+ active_app_frame().status_window.puts (buf, b - buf);
}
return Qt;
diff --git a/src/mainframe.h b/src/mainframe.h
index 586d0c1..a7851e5 100644
--- a/src/mainframe.h
+++ b/src/mainframe.h
@@ -39,9 +39,9 @@ public:
if (p)
m_splitter.remove_pane (p);
}
- virtual void recalc_layout () {recalc_toplevel ();}
+ virtual void recalc_layout () {recalc_toplevel (&active_app_frame());}
};
-extern main_frame g_frame;
+extern main_frame &active_main_frame();
#endif /* _mainframe_h_ */
diff --git a/src/menu.cc b/src/menu.cc
index 3089c03..6909cc7 100644
--- a/src/menu.cc
+++ b/src/menu.cc
@@ -154,7 +154,7 @@ static void
redraw_menu (lisp lmenu)
{
if (xsymbol_value (Vlast_active_menu) == lmenu)
- DrawMenuBar (app.toplev);
+ DrawMenuBar (active_app_frame().toplev);
}
static void
@@ -504,7 +504,7 @@ init_menu_popup (lisp lmenu, int enablep)
else
{
if (xwin32_menu_init (item) == Kend_macro)
- flags = (app.kbdq.save_p ()
+ flags = (active_app_frame().kbdq.save_p ()
? MF_ENABLED | MF_UNCHECKED
: MF_GRAYED | MF_UNCHECKED);
else if (enablep)
@@ -684,7 +684,7 @@ init_menu_popup (WPARAM wparam, LPARAM lparam)
return;
modify_menu_string (lmenu);
suppress_gc sgc;
- init_menu_popup (lmenu, app.kbdq.idlep ());
+ init_menu_popup (lmenu, active_app_frame().kbdq.idlep ());
}
static lisp
@@ -731,7 +731,7 @@ track_popup_menu (lisp lmenu, lisp lbutton, const POINT *point)
{
check_popup_menu (lmenu);
dynamic_bind dynb (Vtracking_menu, lmenu);
- int id = app.mouse.track_popup_menu (xwin32_menu_handle (lmenu), lbutton, point);
+ int id = active_app_frame().mouse.track_popup_menu (xwin32_menu_handle (lmenu), lbutton, point);
if (!id)
return Qnil;
lisp command = lookup_menu_command (lmenu, id);
diff --git a/src/mouse.cc b/src/mouse.cc
index 19cfca8..2225b5d 100644
--- a/src/mouse.cc
+++ b/src/mouse.cc
@@ -41,22 +41,22 @@ rowcol_from_point (Window *wp, int *xx, int *yy)
int wincx = wp->w_ech.cx;
if (wp->flags () & Window::WF_LINE_NUMBER)
{
- x -= (Window::LINENUM_COLUMNS + 1) * app.text_font.cell ().cx;
+ x -= (Window::LINENUM_COLUMNS + 1) * active_app_frame().text_font.cell ().cx;
wincx -= Window::LINENUM_COLUMNS + 1;
}
- x -= app.text_font.cell ().cx / 2;
- x -= wp->w_bufp->b_prompt_columns * app.text_font.cell ().cx; // mini buffer
+ x -= active_app_frame().text_font.cell ().cx / 2;
+ x -= wp->w_bufp->b_prompt_columns * active_app_frame().text_font.cell ().cx; // mini buffer
wincx -= wp->w_bufp->b_prompt_columns;
int oob = 0;
if (x < 0)
{
- oob = oob_small (x, app.text_font.cell ().cx);
+ oob = oob_small (x, active_app_frame().text_font.cell ().cx);
x = -1;
}
else
{
- x /= app.text_font.cell ().cx;
+ x /= active_app_frame().text_font.cell ().cx;
if (x >= wincx)
{
oob = oob_large (x, wincx);
@@ -66,12 +66,12 @@ rowcol_from_point (Window *wp, int *xx, int *yy)
if (y < 0)
{
- oob = oob_small (y, app.text_font.cell ().cy);
+ oob = oob_small (y, active_app_frame().text_font.cell ().cy);
y = -1;
}
else
{
- y /= app.text_font.cell ().cy;
+ y /= active_app_frame().text_font.cell ().cy;
if (y >= wp->w_ech.cy)
{
oob = oob_large (y, wp->w_ech.cy);
@@ -125,7 +125,7 @@ mouse_state::dispatch (Window *wp, WPARAM wparam, LPARAM lparam, int op)
break;
default:
- if (op != MOVE || !app.toplevel_is_active)
+ if (op != MOVE || !active_app_frame().toplevel_is_active)
return;
c = CCF_MOUSEMOVE;
mouse_move_p = 1;
@@ -325,8 +325,8 @@ mouse_state::track_popup_menu (HMENU hmenu, lisp lbtn, const POINT *pt)
Window *wp = selected_window ();
if (!wp)
return 0;
- p.x = wp->caret_x () + app.text_font.cell ().cx;
- p.y = wp->caret_y () + app.text_font.cell ().cy;
+ p.x = wp->caret_x () + active_app_frame().text_font.cell ().cx;
+ p.y = wp->caret_y () + active_app_frame().text_font.cell ().cy;
ClientToScreen (wp->w_hwnd, &p);
break;
}
@@ -358,10 +358,10 @@ void
mouse_state::hide_cursor ()
{
if (xsymbol_value (Vhide_mouse_cursor) != Qnil && !ms_hidden
- && !app.wait_cursor_depth)
+ && !active_app_frame().wait_cursor_depth)
{
RECT r;
- GetWindowRect (app.toplev, &r);
+ GetWindowRect (active_app_frame().toplev, &r);
DWORD pos = GetMessagePos ();
POINT p;
p.x = short (LOWORD (pos));
diff --git a/src/move.cc b/src/move.cc
index 0a72779..042a5f0 100644
--- a/src/move.cc
+++ b/src/move.cc
@@ -643,8 +643,8 @@ Window::scroll_window_horizontally (long ncolumns, int abs)
つーか、このあたりの作りがたぶん間違っているのだが。*/
RECT r;
GetClientRect (w_hwnd, &r);
- int cx = max (0L, ((r.right - sysdep.edge.cx - app.text_font.cell ().cx / 2)
- / app.text_font.cell ().cx));
+ int cx = max (0L, ((r.right - sysdep.edge.cx - active_app_frame().text_font.cell ().cx / 2)
+ / active_app_frame().text_font.cell ().cx));
#else
int cx = w_ech.cx;
#endif
@@ -2468,7 +2468,7 @@ Fcount_column (lisp string, lisp start, lisp lbuffer)
if (column < 0)
FErange_error (start);
int tab = ((!lbuffer || lbuffer == Qnil)
- ? app.default_tab_columns
+ ? active_app_frame().default_tab_columns
: Buffer::coerce_to_buffer (lbuffer)->b_tab_columns);
for (const Char *p = xstring_contents (string), *pe = p + xstring_length (string);
p < pe; p++)
diff --git a/src/msgbox.cc b/src/msgbox.cc
index 9b63cef..583bd43 100644
--- a/src/msgbox.cc
+++ b/src/msgbox.cc
@@ -119,7 +119,7 @@ BOOL
XMessageBox::init_dialog ()
{
SendMessage (hwnd, WM_SETICON, 1,
- LPARAM (LoadIcon (app.hinst, MAKEINTRESOURCE (IDI_XYZZY))));
+ LPARAM (LoadIcon (active_app_frame().hinst, MAKEINTRESOURCE (IDI_XYZZY))));
hfont = HFONT (SendMessage (hwnd, WM_GETFONT, 0, 0));
@@ -310,7 +310,7 @@ MsgBoxEx (HWND hwnd, const char *msg, const char *title,
int type, int defbtn, int icon, int beep,
const char **captions, int ncaptions, int crlf, int no_wrap)
{
- XMessageBox mb (app.hinst, msg ? msg : "", title ? title : "エラー", crlf, no_wrap);
+ XMessageBox mb (active_app_frame().hinst, msg ? msg : "", title ? title : "エラー", crlf, no_wrap);
if (!captions)
ncaptions = 0;
diff --git a/src/oledata.cc b/src/oledata.cc
index afd833d..8c63499 100644
--- a/src/oledata.cc
+++ b/src/oledata.cc
@@ -866,7 +866,7 @@ DevStudio/SharedIDE/bin/ide/DEVDBG.PKG
(set-ole-event-handler app "WindowActivate" #'(lambda (&rest x)))
(require "ole")
-(setq deb #{app.debugger})
+(setq deb #{active_app_frame().debugger})
(ole-create-event-sink deb "IDispDebuggerEvents" "DevStudio/SharedIDE/bin/ide/DEVDBG.PKG")
*/
diff --git a/src/pane.cc b/src/pane.cc
index 4c78e56..efc4b09 100644
--- a/src/pane.cc
+++ b/src/pane.cc
@@ -506,20 +506,20 @@ pane::set_pos (int flags)
XPIHANDLE WINAPI
xpiCreatePane (HWND hwnd, int cx, int cy, DWORD flags)
{
- return (XPIHANDLE)g_frame.m_splitter.create_pane (hwnd, cx, cy, flags);
+ return (XPIHANDLE)active_main_frame().m_splitter.create_pane (hwnd, cx, cy, flags);
}
BOOL WINAPI
xpiSetPaneSize (XPIHANDLE h, int size, int min, int max, int step)
{
- pane *p = g_frame.m_splitter.find_pane (h);
+ pane *p = active_main_frame().m_splitter.find_pane (h);
return p ? p->set_size (size, min, max, step) : 0;
}
BOOL WINAPI
xpiSetPanePos (XPIHANDLE h, DWORD flags)
{
- pane *p = g_frame.m_splitter.find_pane (h);
+ pane *p = active_main_frame().m_splitter.find_pane (h);
return p ? p->set_pos (flags) : 0;
}
diff --git a/src/popup.cc b/src/popup.cc
index 55f3d7d..d3da6f7 100644
--- a/src/popup.cc
+++ b/src/popup.cc
@@ -193,7 +193,7 @@ create_popup ()
wc.lpfnWndProc = wndproc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
- wc.hInstance = app.hinst;
+ wc.hInstance = active_app_frame().hinst;
wc.hIcon = 0;
wc.hCursor = LoadCursor (0, IDC_ARROW);
wc.hbrBackground = 0;
@@ -205,7 +205,7 @@ create_popup ()
hwnd_popup = CreateWindow (wclass, "",
WS_POPUP | WS_BORDER,
0, 0, 0, 0,
- app.toplev, 0, app.hinst, 0);
+ active_app_frame().toplev, 0, active_app_frame().hinst, 0);
if (!hwnd_popup)
return 0;
@@ -235,7 +235,7 @@ calc_pos (lisp lpoint, RECT &r)
wp->point2window_pos (wp->w_bufp->coerce_to_point (lpoint), *(POINT *)&r);
r.right = r.left;
- r.bottom = r.top + app.text_font.cell ().cy;
+ r.bottom = r.top + active_app_frame().text_font.cell ().cy;
r.top -= 4;
r.bottom += 8;
diff --git a/src/popupl.cc b/src/popupl.cc
index f9a86ab..8a21f60 100644
--- a/src/popupl.cc
+++ b/src/popupl.cc
@@ -75,7 +75,7 @@ wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
case VK_SPACE:
if (call_callback (hwnd))
- PostMessage (app.toplev, msg, wparam, lparam);
+ PostMessage (active_app_frame().toplev, msg, wparam, lparam);
return 0;
case VK_RETURN:
@@ -88,7 +88,7 @@ wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
return 0;
default:
- PostMessage (app.toplev, msg, wparam, lparam);
+ PostMessage (active_app_frame().toplev, msg, wparam, lparam);
DestroyWindow (hwnd);
return 0;
}
@@ -122,7 +122,7 @@ define_wndclass ()
org_wndproc = wc.lpfnWndProc;
wc.lpfnWndProc = wndproc;
- wc.hInstance = app.hinst;
+ wc.hInstance = active_app_frame().hinst;
wc.lpszClassName = csPopupList;
return RegisterClass (&wc);
}
@@ -154,7 +154,7 @@ Fpopup_list (lisp list, lisp callback, lisp lpoint)
hwnd_popup = CreateWindowEx (WS_EX_DLGMODALFRAME, csPopupList, "",
WS_POPUP | WS_VSCROLL, 0, 0, 0, 0,
- app.toplev, 0, app.hinst, 0);
+ active_app_frame().toplev, 0, active_app_frame().hinst, 0);
HFONT hf = sysdep.ui_font ();
SendMessage (hwnd_popup, WM_SETFONT, WPARAM (hf), 1);
@@ -201,11 +201,11 @@ Fpopup_list (lisp list, lisp callback, lisp lpoint)
RECT wk;
SystemParametersInfo (SPI_GETWORKAREA, 0, &wk, 0);
- if (pos.y + app.text_font.cell ().cy + sz.cy <= wk.bottom)
- pos.y += app.text_font.cell ().cy;
- else if (wk.bottom - (pos.y + app.text_font.cell ().cy) > LIST_MAXH / 2)
+ if (pos.y + active_app_frame().text_font.cell ().cy + sz.cy <= wk.bottom)
+ pos.y += active_app_frame().text_font.cell ().cy;
+ else if (wk.bottom - (pos.y + active_app_frame().text_font.cell ().cy) > LIST_MAXH / 2)
{
- pos.y += app.text_font.cell ().cy;
+ pos.y += active_app_frame().text_font.cell ().cy;
sz.cy = wk.bottom - pos.y;
}
else
diff --git a/src/pred.cc b/src/pred.cc
index 1042609..416083e 100644
--- a/src/pred.cc
+++ b/src/pred.cc
@@ -102,6 +102,9 @@ Ftype_of (lisp object)
case Twindow:
return Qwindow;
+ case Tappframe:
+ return Qappframe;
+
case Tbuffer:
return Qbuffer;
diff --git a/src/preview.cc b/src/preview.cc
index 688fdb3..5bb4129 100644
--- a/src/preview.cc
+++ b/src/preview.cc
@@ -588,7 +588,7 @@ preview_page_window::set_cursor (int hittest)
{
if (hittest != HTCLIENT)
return 0;
- SetCursor (LoadCursor (app.hinst, MAKEINTRESOURCE (IDC_MAGCUR)));
+ SetCursor (LoadCursor (active_app_frame().hinst, MAKEINTRESOURCE (IDC_MAGCUR)));
return 1;
}
@@ -718,7 +718,7 @@ preview_page_window::register_wndclass (HINSTANCE hinst)
int
preview_page_window::create (HWND hwnd, const RECT &r)
{
- if (!register_wndclass (app.hinst))
+ if (!register_wndclass (active_app_frame().hinst))
return 0;
if (!CreateWindowEx (sysdep.Win4p () ? WS_EX_CLIENTEDGE : 0,
@@ -727,7 +727,7 @@ preview_page_window::create (HWND hwnd, const RECT &r)
| WS_CLIPSIBLINGS | WS_TABSTOP
| (sysdep.Win4p () ? 0 : WS_BORDER)),
r.left, r.top, r.right - r.left, r.bottom - r.top,
- hwnd, 0, app.hinst, this))
+ hwnd, 0, active_app_frame().hinst, this))
return 0;
return 1;
}
@@ -791,7 +791,7 @@ preview_dialog::init_dialog (HWND)
for (int i = 0; i < numberof (preview_page_window::ids2scales); i++)
{
char b[128];
- LoadString (app.hinst, preview_page_window::ids2scales[i].ids,
+ LoadString (active_app_frame().hinst, preview_page_window::ids2scales[i].ids,
b, sizeof b);
UINT idx = SendDlgItemMessage (p_hwnd, IDC_SCALE, CB_ADDSTRING, 0, LPARAM (b));
SendDlgItemMessage (p_hwnd, IDC_SCALE, CB_SETITEMDATA,
@@ -961,7 +961,7 @@ preview_dialog::wndproc (UINT msg, WPARAM wparam, LPARAM lparam)
return quit ();
case WM_ACTIVATEAPP:
- PostThreadMessage (app.quit_thread_id, WM_PRIVATE_ACTIVATEAPP,
+ PostThreadMessage (active_app_frame().quit_thread_id, WM_PRIVATE_ACTIVATEAPP,
wparam, lparam);
return 0;
@@ -1005,6 +1005,6 @@ preview_dialog::wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
int
preview_dialog::do_modal (HWND hwnd)
{
- return DialogBoxParam (app.hinst, MAKEINTRESOURCE (IDD_PREVIEW),
+ return DialogBoxParam (active_app_frame().hinst, MAKEINTRESOURCE (IDD_PREVIEW),
hwnd, wndproc, LPARAM (this));
}
diff --git a/src/print.cc b/src/print.cc
index ee8bb6b..cee92df 100644
--- a/src/print.cc
+++ b/src/print.cc
@@ -1809,16 +1809,16 @@ print_engine::doprint1 (HWND hwnd)
di.lpszDocName = docname;
user_abort = 0;
- HWND printing = CreateDialog (app.hinst, MAKEINTRESOURCE (IDD_PRINTING),
- app.toplev, printing_dlgproc);
+ HWND printing = CreateDialog (active_app_frame().hinst, MAKEINTRESOURCE (IDD_PRINTING),
+ active_app_frame().toplev, printing_dlgproc);
SetDlgItemText (printing, IDC_DOCNAME, docname);
ShowWindow (printing, SW_SHOW);
UpdateWindow (printing);
- EnableWindow (app.toplev, 0);
+ EnableWindow (active_app_frame().toplev, 0);
if (StartDoc (pe_dev, &di) == SP_ERROR)
{
- EnableWindow (app.toplev, 1);
+ EnableWindow (active_app_frame().toplev, 1);
DestroyWindow (printing);
FEsimple_win32_error (GetLastError ());
}
@@ -1861,7 +1861,7 @@ print_engine::doprint1 (HWND hwnd)
else
AbortDoc (pe_dev);
- EnableWindow (app.toplev, 1);
+ EnableWindow (active_app_frame().toplev, 1);
DestroyWindow (printing);
if (user_abort)
@@ -1922,7 +1922,7 @@ int
print_engine::notice (HWND hwnd, UINT id, UINT ids)
{
char b[256];
- LoadString (app.hinst, ids, b, sizeof b);
+ LoadString (active_app_frame().hinst, ids, b, sizeof b);
MsgBox (hwnd, b, TitleBarString, MB_OK | MB_ICONEXCLAMATION,
xsymbol_value (Vbeep_on_error) != Qnil);
if (id != UINT (-1))
@@ -1934,7 +1934,7 @@ int
print_engine::notice (HWND hwnd, UINT id, UINT ids, int arg)
{
char fmt[256], b[512];
- LoadString (app.hinst, ids, fmt, sizeof fmt);
+ LoadString (active_app_frame().hinst, ids, fmt, sizeof fmt);
wsprintf (b, fmt, arg);
MsgBox (hwnd, b, TitleBarString, MB_OK | MB_ICONEXCLAMATION,
xsymbol_value (Vbeep_on_error) != Qnil);
diff --git a/src/printdlg.cc b/src/printdlg.cc
index d0bec9f..6c8b8a2 100644
--- a/src/printdlg.cc
+++ b/src/printdlg.cc
@@ -190,7 +190,7 @@ print_dialog::add_lang () const
{
char buf[128];
*buf = 0;
- LoadString (app.hinst, FontSet::lang_id (i), buf, sizeof buf);
+ LoadString (active_app_frame().hinst, FontSet::lang_id (i), buf, sizeof buf);
int idx = SendDlgItemMessage (m_hwnd, IDC_LANG, CB_ADDSTRING, 0, LPARAM (buf));
SendDlgItemMessage (m_hwnd, IDC_LANG, CB_SETITEMDATA, idx, i);
}
@@ -843,7 +843,7 @@ print_dialog::format_popup (UINT id_btn, subclass_combo &sc)
RECT r;
GetWindowRect (hwnd_btn, &r);
- HMENU hmenu = LoadMenu (app.hinst, MAKEINTRESOURCE (IDM_PRINTFMT));
+ HMENU hmenu = LoadMenu (active_app_frame().hinst, MAKEINTRESOURCE (IDM_PRINTFMT));
HMENU hsub = GetSubMenu (hmenu, 0);
int cmd = TrackPopupMenu (hsub, (TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_TOPALIGN
| TPM_NONOTIFY | TPM_RETURNCMD),
@@ -985,7 +985,7 @@ print_dialog::wndproc (UINT msg, WPARAM wparam, LPARAM lparam)
return quit ();
case WM_ACTIVATEAPP:
- PostThreadMessage (app.quit_thread_id, WM_PRIVATE_ACTIVATEAPP,
+ PostThreadMessage (active_app_frame().quit_thread_id, WM_PRIVATE_ACTIVATEAPP,
wparam, lparam);
return 0;
@@ -1016,7 +1016,7 @@ print_dialog::wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
int
print_dialog::do_modal (HWND hwnd)
{
- return DialogBoxParam (app.hinst, MAKEINTRESOURCE (IDD_PRINT),
+ return DialogBoxParam (active_app_frame().hinst, MAKEINTRESOURCE (IDD_PRINT),
hwnd, wndproc, LPARAM (this));
}
diff --git a/src/process.cc b/src/process.cc
index 9886b76..a6d0c6b 100644
--- a/src/process.cc
+++ b/src/process.cc
@@ -322,7 +322,7 @@ protected:
void terminated (int);
void notify_term () const
- {PostMessage (app.toplev, WM_PRIVATE_PROCESS_TERMINATE, 0, LPARAM (this));}
+ {PostMessage (active_app_frame().toplev, WM_PRIVATE_PROCESS_TERMINATE, 0, LPARAM (this));}
public:
virtual ~Process ();
@@ -330,7 +330,7 @@ public:
virtual void signal () = 0;
virtual void kill () = 0;
virtual void send (const char *, int) const = 0;
- void insert_process_output (void *);
+ void insert_process_output (ApplicationFrame *, void *);
lisp process_buffer () const {return p_bufp->lbp;}
void flush_input ();
void store_output (const Char *, int);
@@ -357,7 +357,7 @@ public:
LeaveCriticalSection (&p_cri);
if (!empty_p)
{
- PostMessage (app.toplev, WM_PRIVATE_PROCESS_OUTPUT, 0, LPARAM (this));
+ PostMessage (active_app_frame().toplev, WM_PRIVATE_PROCESS_OUTPUT, 0, LPARAM (this));
p_pending = 1;
}
}
@@ -428,17 +428,17 @@ Process::terminated (int exit_code)
}
p_bufp->modify_mode_line ();
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = active_app_frame().active_frame.windows; wp; wp = wp->w_next)
if (wp->w_bufp == p_bufp)
{
refresh_screen (0);
- g_frame.update_ui ();
+ active_main_frame().update_ui ();
break;
}
}
void
-Process::insert_process_output (void *p)
+Process::insert_process_output (ApplicationFrame *app1, void *p)
{
lisp lstring = 0;
try
@@ -491,7 +491,7 @@ Process::insert_process_output (void *p)
}
else
{
- Window *wp = selected_window ();
+ Window *wp = selected_window (app1);
if (xmarker_point (p_marker) == NO_MARK_SET)
xmarker_point (p_marker) = p_bufp->b_contents.p2;
int goto_tail = (wp->w_bufp == p_bufp
@@ -504,7 +504,7 @@ Process::insert_process_output (void *p)
if (goto_tail)
p_bufp->goto_char (wp->w_point, xmarker_point (p_marker));
int f = 0;
- for (wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (wp = app1->active_frame.windows; wp; wp = wp->w_next)
if (wp->w_bufp == p_bufp)
{
wp->w_disp_flags |= Window::WDF_REFRAME_SCROLL;
@@ -532,10 +532,10 @@ good_process_p (const Process *pr)
}
void
-read_process_output (WPARAM wparam, LPARAM lparam)
+read_process_output (ApplicationFrame *app1, WPARAM wparam, LPARAM lparam)
{
if (good_process_p ((Process *)lparam))
- ((Process *)lparam)->insert_process_output ((void *)wparam);
+ ((Process *)lparam)->insert_process_output (app1, (void *)wparam);
}
void
@@ -556,10 +556,10 @@ Process::store_output (const Char *w, int l)
DWORD result;
do
- if (SendMessageTimeout (app.toplev, WM_PRIVATE_PROCESS_OUTPUT,
+ if (SendMessageTimeout (active_app_frame().toplev, WM_PRIVATE_PROCESS_OUTPUT,
WPARAM (&r), LPARAM (this),
SMTO_NORMAL, 1000, &result)
- || !IsWindow (app.toplev)
+ || !IsWindow (active_app_frame().toplev)
|| r.done)
return;
while (!p_in_send_string);
diff --git a/src/resolver.cc b/src/resolver.cc
index 295592b..08e0d7e 100644
--- a/src/resolver.cc
+++ b/src/resolver.cc
@@ -46,7 +46,7 @@ resolver::create (HINSTANCE hinst)
0, 0, 0, 0, HWND_DESKTOP, 0, hinst, this);
#else
return r_hwnd || CreateWindow (resolver_wndclass, "", WS_CHILD,
- 0, 0, 0, 0, app.toplev, 0, hinst, this);
+ 0, 0, 0, 0, active_app_frame().toplev, 0, hinst, this);
#endif
}
@@ -146,7 +146,7 @@ resolver::wait (HANDLE h)
}
#ifdef __XYZZY__
- kbd_queue::disable_kbd dkbd (app.kbdq);
+ kbd_queue::disable_kbd dkbd (active_app_frame().kbdq);
#endif
int quit = 0;
diff --git a/src/statarea.cc b/src/statarea.cc
index 899a79f..9b0deef 100644
--- a/src/statarea.cc
+++ b/src/statarea.cc
@@ -182,7 +182,7 @@ status_area::set_parts () const
if (s_nitems)
{
int cx = s_clwidth;
- if (!IsZoomed (app.toplev))
+ if (!IsZoomed (active_app_frame().toplev))
cx -= s_borders[0] + sysdep.vscroll + sysdep.border.cx * 2;
w[s_nitems] = cx;
diff --git a/src/stream.cc b/src/stream.cc
index 6536601..c38ea5b 100644
--- a/src/stream.cc
+++ b/src/stream.cc
@@ -1316,7 +1316,7 @@ readc_stream (lisp stream)
if (xstream_type (stream) == st_keyboard)
{
check_kbd_enable ();
- return app.kbdq.fetch (0, 0);
+ return active_app_frame().kbdq.fetch (0, 0);
}
lChar cc = xstream_pending (stream);
@@ -1503,7 +1503,7 @@ listen_stream (lisp stream)
if (xstream_type (stream) == st_keyboard)
{
check_kbd_enable ();
- return app.kbdq.listen ();
+ return active_app_frame().kbdq.listen ();
}
lChar cc = xstream_pending (stream);
@@ -1602,8 +1602,8 @@ peekc_stream (lisp stream)
{
case st_keyboard:
check_kbd_enable ();
- cc = app.kbdq.fetch (0, 0);
- app.kbdq.push_back (cc);
+ cc = active_app_frame().kbdq.fetch (0, 0);
+ active_app_frame().kbdq.push_back (cc);
break;
case st_buffer:
@@ -1636,7 +1636,7 @@ unreadc_stream (lChar cc, lisp stream)
switch (xstream_type (stream))
{
case st_keyboard:
- app.kbdq.push_back (cc);
+ active_app_frame().kbdq.push_back (cc);
break;
case st_buffer:
@@ -1752,7 +1752,7 @@ writec_stream (lisp stream, Char cc)
break;
case st_status:
- app.status_window.putc (cc);
+ active_app_frame().status_window.putc (cc);
xstream_column (stream) = update_column (xstream_column (stream), cc);
return;
@@ -1858,7 +1858,7 @@ write_stream (lisp stream, const Char *b, size_t size)
break;
case st_status:
- app.status_window.puts (b, size);
+ active_app_frame().status_window.puts (b, size);
xstream_column (stream) = update_column (xstream_column (stream), b, size);
return;
@@ -2006,7 +2006,7 @@ flush_stream (lisp stream)
break;
case st_status:
- app.status_window.flush ();
+ active_app_frame().status_window.flush ();
return;
case st_buffer:
diff --git a/src/string.cc b/src/string.cc
index 774c16a..b924f90 100644
--- a/src/string.cc
+++ b/src/string.cc
@@ -8,8 +8,8 @@ update_column (int column, Char c)
if (c == '\n')
column = 0;
else if (c == '\t')
- column = ((column + app.default_tab_columns)
- / app.default_tab_columns * app.default_tab_columns);
+ column = ((column + active_app_frame().default_tab_columns)
+ / active_app_frame().default_tab_columns * active_app_frame().default_tab_columns);
else
column += char_width (c);
return column;
@@ -31,9 +31,9 @@ update_column (int column, Char c, int size)
if (c == '\n')
column = 0;
else if (c == '\t')
- column = ((column + app.default_tab_columns) / app.default_tab_columns
- * app.default_tab_columns
- + (size - 1) * app.default_tab_columns);
+ column = ((column + active_app_frame().default_tab_columns) / active_app_frame().default_tab_columns
+ * active_app_frame().default_tab_columns
+ + (size - 1) * active_app_frame().default_tab_columns);
else
column += char_width (c) * size;
}
diff --git a/src/syntax.cc b/src/syntax.cc
index f3ee495..eefb45f 100644
--- a/src/syntax.cc
+++ b/src/syntax.cc
@@ -1990,7 +1990,7 @@ lisp
Ftab_columns (lisp lbuffer)
{
if (!lbuffer || lbuffer == Qnil)
- return make_fixnum (app.default_tab_columns);
+ return make_fixnum (active_app_frame().default_tab_columns);
Buffer *bp = Buffer::coerce_to_buffer (lbuffer);
multiple_value::count () = 2;
multiple_value::value (1) = boole (bp->b_local_tab_columns);
@@ -2005,9 +2005,9 @@ Fset_tab_columns (lisp column, lisp lbuffer)
int n = fixnum_value (column);
if (n < 1 || n > 32)
FErange_error (column);
- if (app.default_tab_columns != n)
+ if (active_app_frame().default_tab_columns != n)
{
- app.default_tab_columns = n;
+ active_app_frame().default_tab_columns = n;
for (Buffer *bp = Buffer::b_blist; bp; bp = bp->b_next)
{
bp->b_nfolded = -1;
@@ -2017,7 +2017,7 @@ Fset_tab_columns (lisp column, lisp lbuffer)
bp->fold_width_modified ();
}
}
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = active_app_frame().active_frame.windows; wp; wp = wp->w_next)
if (wp->w_bufp && !wp->w_bufp->b_local_tab_columns)
wp->w_disp_flags |= Window::WDF_WINDOW;
}
@@ -2029,7 +2029,7 @@ Fset_tab_columns (lisp column, lisp lbuffer)
if (column == Qnil)
{
bp->b_local_tab_columns = 0;
- n = app.default_tab_columns;
+ n = active_app_frame().default_tab_columns;
}
else
{
diff --git a/src/thread.cc b/src/thread.cc
index 42ff40b..8c81dbe 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -61,5 +61,5 @@ worker_thread::wait ()
{
if (!w_hthread)
return 0;
- return app.kbdq.wait_event (w_hterm_event, 1);
+ return active_app_frame().kbdq.wait_event (w_hterm_event, 1);
}
diff --git a/src/toplev.cc b/src/toplev.cc
index 142771e..2f24856 100644
--- a/src/toplev.cc
+++ b/src/toplev.cc
@@ -14,7 +14,6 @@
text_drop_target tdropt;
#endif
-main_frame g_frame;
mouse_wheel g_wheel;
static u_int __stdcall
@@ -59,7 +58,7 @@ quit_thread_entry (void *p)
}
if (!quit_on && quit_ok)
{
- RegisterHotKey (0, HK_QUIT, app.quit_mod, app.quit_vkey);
+ RegisterHotKey (0, HK_QUIT, active_app_frame().quit_mod, active_app_frame().quit_vkey);
quit_on = 1;
}
}
@@ -82,7 +81,7 @@ quit_thread_entry (void *p)
quit_ok = 1;
if (fg && !quit_on)
{
- RegisterHotKey (0, HK_QUIT, app.quit_mod, app.quit_vkey);
+ RegisterHotKey (0, HK_QUIT, active_app_frame().quit_mod, active_app_frame().quit_vkey);
quit_on = 1;
}
break;
@@ -100,14 +99,14 @@ quit_thread_entry (void *p)
if (quit_on)
{
UnregisterHotKey (0, HK_QUIT);
- RegisterHotKey (0, HK_QUIT, app.quit_mod, app.quit_vkey);
+ RegisterHotKey (0, HK_QUIT, active_app_frame().quit_mod, active_app_frame().quit_vkey);
}
break;
case WM_HOTKEY:
- if (!app.f_protect_quit)
+ if (!active_app_frame().f_protect_quit)
{
- PostMessage (app.toplev, WM_PRIVATE_QUIT, 0, 0);
+ PostMessage (active_app_frame().toplev, WM_PRIVATE_QUIT, 0, 0);
xsymbol_value (Vquit_flag) = Qt;
}
break;
@@ -120,7 +119,7 @@ int
start_quit_thread ()
{
u_long h = _beginthreadex (0, 0, quit_thread_entry, (void *)GetCurrentThreadId (),
- 0, &app.quit_thread_id);
+ 0, &active_app_frame().quit_thread_id);
if (h == -1)
return 0;
CloseHandle (HANDLE (h));
@@ -130,7 +129,8 @@ start_quit_thread ()
static void
set_current_cursor (const Window *wp)
{
- if (app.wait_cursor_depth)
+ ApplicationFrame *app1 = wp != NULL ? wp->w_owner : first_app_frame();
+ if (app1->wait_cursor_depth)
SetCursor (sysdep.hcur_wait);
else if (!wp || !wp->w_bufp)
SetCursor (sysdep.hcur_arrow);
@@ -139,26 +139,26 @@ set_current_cursor (const Window *wp)
POINT p;
GetCursorPos (&p);
ScreenToClient (wp->w_hwnd, &p);
- int l = app.text_font.cell ().cx / 2;
+ int l = wp->w_owner->text_font.cell ().cx / 2;
if (wp->w_last_flags & Window::WF_LINE_NUMBER)
- l += (Window::LINENUM_COLUMNS + 1) * app.text_font.cell ().cx;
+ l += (Window::LINENUM_COLUMNS + 1) * wp->w_owner->text_font.cell ().cx;
SetCursor (p.x < l ? sysdep.hcur_revarrow : sysdep.hcur_current);
}
}
static void
-set_current_cursor ()
+set_current_cursor (ApplicationFrame *app1)
{
POINT p;
GetCursorPos (&p);
- set_current_cursor (Window::find_scr_point_window (p, 0, 0));
+ set_current_cursor (Window::find_scr_point_window (app1, p, 0, 0));
}
lisp
Fbegin_wait_cursor ()
{
- app.wait_cursor_depth++;
- if (app.toplevel_is_active)
+ active_app_frame().wait_cursor_depth++;
+ if (active_app_frame().toplevel_is_active)
{
SetCursor (sysdep.hcur_wait);
mouse_state::show_cursor ();
@@ -167,23 +167,24 @@ Fbegin_wait_cursor ()
}
int
-end_wait_cursor (int f)
+end_wait_cursor (int f, ApplicationFrame *app1)
{
- if (!app.wait_cursor_depth)
+ app1 = app1 == NULL ? &active_app_frame() : app1;
+ if (!app1->wait_cursor_depth)
return 1;
if (f)
- app.wait_cursor_depth = 0;
+ app1->wait_cursor_depth = 0;
else
{
- app.wait_cursor_depth--;
- if (app.wait_cursor_depth)
+ app1->wait_cursor_depth--;
+ if (app1->wait_cursor_depth)
return 0;
}
- if (app.toplevel_is_active)
+ if (app1->toplevel_is_active)
{
- if (GetFocus () == app.toplev)
+ if (GetFocus () == app1->toplev)
mouse_state::hide_cursor ();
- set_current_cursor ();
+ set_current_cursor (app1);
}
return 1;
}
@@ -203,61 +204,61 @@ Fset_cursor (lisp cur)
sysdep.hcur_current = sysdep.hcur_arrow;
else
return Qnil;
- if (app.toplevel_is_active)
- set_current_cursor ();
+ if (active_app_frame().toplevel_is_active)
+ set_current_cursor (&active_app_frame());
xsymbol_value (Vcursor_shape) = cur;
return Qt;
}
static void
-frame_rect (int w, int h, RECT &r)
+frame_rect (ApplicationFrame *app1, int w, int h, RECT &r)
{
- GetClientRect (app.hwnd_sw, &r);
+ GetClientRect (app1->hwnd_sw, &r);
r.left = 0;
r.top = 0;
r.right = w;
r.bottom = h - r.bottom;
if (Window::w_default_flags & Window::WF_FUNCTION_BAR)
- r.bottom -= app.active_frame.fnkey->height ();
+ r.bottom -= app1->active_frame.fnkey->height ();
}
static void
-resize_toplevel (int cx, int cy)
+resize_toplevel (ApplicationFrame *app1, int cx, int cy)
{
RECT r;
- frame_rect (cx, cy, r);
+ frame_rect (app1, cx, cy, r);
HWND hwnd_before;
if (Window::w_default_flags & Window::WF_FUNCTION_BAR)
{
- hwnd_before = app.active_frame.fnkey->hwnd ();
- SetWindowPos (app.active_frame.fnkey->hwnd (),
- app.hwnd_sw,
+ hwnd_before = app1->active_frame.fnkey->hwnd ();
+ SetWindowPos (app1->active_frame.fnkey->hwnd (),
+ app1->hwnd_sw,
0, r.bottom,
- cx, app.active_frame.fnkey->height (),
+ cx, app1->active_frame.fnkey->height (),
SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_SHOWWINDOW);
}
else
{
- hwnd_before = app.hwnd_sw;
- ShowWindow (app.active_frame.fnkey->hwnd (), SW_HIDE);
+ hwnd_before = app1->hwnd_sw;
+ ShowWindow (app1->active_frame.fnkey->hwnd (), SW_HIDE);
}
- g_frame.resize (r, hwnd_before);
+ app1->mframe->resize (r, hwnd_before);
}
void
-recalc_toplevel ()
+recalc_toplevel (ApplicationFrame *app1)
{
RECT r;
- GetClientRect (app.toplev, &r);
- resize_toplevel (r.right, r.bottom);
+ GetClientRect (app1->toplev, &r);
+ resize_toplevel (app1, r.right, r.bottom);
}
static void
do_dnd (HDROP hdrop)
{
int drag_finish_called = 0;
- if (app.kbdq.idlep ())
+ if (active_app_frame().kbdq.idlep ())
{
Window *wp;
POINT pt;
@@ -265,8 +266,8 @@ do_dnd (HDROP hdrop)
wp = selected_window ();
else
{
- ClientToScreen (app.toplev, &pt);
- wp = Window::find_scr_point_window (pt, 1, 0);
+ ClientToScreen (active_app_frame().toplev, &pt);
+ wp = Window::find_scr_point_window (&active_app_frame(), pt, 1, 0);
}
if (wp)
@@ -279,9 +280,9 @@ do_dnd (HDROP hdrop)
{
if (xsymbol_value (Vdrag_and_drop_auto_activate) != Qnil)
{
- if (IsIconic (app.toplev))
- ShowWindow (app.toplev, SW_RESTORE);
- ForceSetForegroundWindow (app.toplev);
+ if (IsIconic (active_app_frame().toplev))
+ ShowWindow (active_app_frame().toplev, SW_RESTORE);
+ ForceSetForegroundWindow (active_app_frame().toplev);
}
lisp list = Qnil;
int nfiles = DragQueryFile (hdrop, UINT (-1), 0, 0);
@@ -311,47 +312,47 @@ do_dnd (HDROP hdrop)
}
void
-set_ime_caret ()
+set_ime_caret (ApplicationFrame *app1)
{
- if (app.active_frame.has_caret && app.ime_composition)
+ if (app1->active_frame.has_caret && app1->ime_composition)
{
- HIMC hIMC = app.kbdq.gime.ImmGetContext (app.toplev);
+ HIMC hIMC = app1->kbdq.gime.ImmGetContext (app1->toplev);
if (!hIMC)
return;
if (xsymbol_value (Vno_input_language_change_notification) != Qnil)
- app.kbdq.init_kbd_encoding ();
+ app1->kbdq.init_kbd_encoding ();
const FontObject &font = kbd_queue::kbd_encoding_font ();
- POINT pt (app.active_frame.caret_pos);
- MapWindowPoints (app.active_frame.has_caret, app.toplev, &pt, 1);
+ POINT pt (app1->active_frame.caret_pos);
+ MapWindowPoints (app1->active_frame.has_caret, app1->toplev, &pt, 1);
pt.x += font.offset ().x;
pt.y += font.offset ().y;
RECT r;
- int need_rect = (/*!app.kbdq.gime.enable_p () // ようわからんけどとりあえず(^^;
- ||*/ PRIMARYLANGID (app.kbdq.kbd_langid ()) != LANG_KOREAN);
+ int need_rect = (/*!app1->kbdq.gime.enable_p () // ようわからんけどとりあえず(^^;
+ ||*/ PRIMARYLANGID (app1->kbdq.kbd_langid ()) != LANG_KOREAN);
if (need_rect)
{
- GetClientRect (app.active_frame.has_caret, &r);
+ GetClientRect (app1->active_frame.has_caret, &r);
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
- if (wp->w_hwnd == app.active_frame.has_caret)
+ for (Window *wp = app1->active_frame.windows; wp; wp = wp->w_next)
+ if (wp->w_hwnd == app1->active_frame.has_caret)
break;
- r.left += app.text_font.cell ().cx / 2;
+ r.left += app1->text_font.cell ().cx / 2;
if (wp && wp->w_bufp)
{
if (wp->w_last_flags & Window::WF_LINE_NUMBER)
- r.left += (Window::LINENUM_COLUMNS + 1) * app.text_font.cell ().cx;
+ r.left += (Window::LINENUM_COLUMNS + 1) * app1->text_font.cell ().cx;
if (wp->w_bufp->b_fold_columns != Buffer::FOLD_NONE)
{
- LONG t = r.left + wp->w_bufp->b_fold_columns * app.text_font.cell ().cx;
- if (t > app.active_frame.caret_pos.x)
+ LONG t = r.left + wp->w_bufp->b_fold_columns * app1->text_font.cell ().cx;
+ if (t > app1->active_frame.caret_pos.x)
r.right = min (r.right, t);
}
}
- MapWindowPoints (app.active_frame.has_caret, app.toplev,
+ MapWindowPoints (app1->active_frame.has_caret, app1->toplev,
(POINT *)&r, 2);
pt.y = max (pt.y, r.top);
}
@@ -359,70 +360,70 @@ set_ime_caret ()
COMPOSITIONFORM cf;
cf.dwStyle = CFS_POINT;
cf.ptCurrentPos = pt;
- app.kbdq.gime.ImmSetCompositionWindow (hIMC, &cf);
+ app1->kbdq.gime.ImmSetCompositionWindow (hIMC, &cf);
if (need_rect)
{
cf.dwStyle = CFS_RECT;
cf.rcArea = r;
- app.kbdq.gime.ImmSetCompositionWindow (hIMC, &cf);
+ app1->kbdq.gime.ImmSetCompositionWindow (hIMC, &cf);
}
- app.kbdq.gime.ImmSetCompositionFont (hIMC, (LOGFONT *)&font.logfont ());
- app.kbdq.gime.ImmReleaseContext (app.toplev, hIMC);
+ app1->kbdq.gime.ImmSetCompositionFont (hIMC, (LOGFONT *)&font.logfont ());
+ app1->kbdq.gime.ImmReleaseContext (app1->toplev, hIMC);
}
}
static void
-ime_open_status (HWND hwnd)
+ime_open_status (ApplicationFrame *app1, HWND hwnd)
{
- HIMC imc = app.kbdq.gime.ImmGetContext (hwnd);
+ HIMC imc = app1->kbdq.gime.ImmGetContext (hwnd);
if (imc)
{
- app.ime_open_mode = (app.kbdq.gime.ImmGetOpenStatus (imc)
+ app1->ime_open_mode = (app1->kbdq.gime.ImmGetOpenStatus (imc)
? kbd_queue::IME_MODE_ON
: kbd_queue::IME_MODE_OFF);
- app.kbdq.gime.ImmReleaseContext (hwnd, imc);
- Window::update_last_caret ();
+ app1->kbdq.gime.ImmReleaseContext (hwnd, imc);
+ Window::update_last_caret (app1);
PostMessage (hwnd, WM_PRIVATE_IME_MODE, 0, 0);
}
}
static LPARAM
-ime_composition (HWND hwnd, LPARAM lparam)
+ime_composition (ApplicationFrame *app1, HWND hwnd, LPARAM lparam)
{
if (lparam & GCS_RESULTSTR)
{
- HIMC hIMC = app.kbdq.gime.ImmGetContext (hwnd);
+ HIMC hIMC = app1->kbdq.gime.ImmGetContext (hwnd);
if (!hIMC)
return lparam;
if (xsymbol_value (Vno_input_language_change_notification) != Qnil)
- app.kbdq.init_kbd_encoding ();
+ app1->kbdq.init_kbd_encoding ();
if (xsymbol_value (Vunicode_ime) == Qnil
- ? !(app.kbdq.ime_property () & IME_PROP_UNICODE)
+ ? !(app1->kbdq.ime_property () & IME_PROP_UNICODE)
: xsymbol_value (Vunicode_ime) != Qt)
{
- int l = app.kbdq.gime.ImmGetCompositionString (hIMC, GCS_RESULTSTR, 0, 0);
+ int l = app1->kbdq.gime.ImmGetCompositionString (hIMC, GCS_RESULTSTR, 0, 0);
if (l > 0)
{
char *s = (char *)alloca (l + 1);
- if (app.kbdq.gime.ImmGetCompositionString (hIMC, GCS_RESULTSTR, s, l) == l)
+ if (app1->kbdq.gime.ImmGetCompositionString (hIMC, GCS_RESULTSTR, s, l) == l)
{
- app.kbdq.puts (s, l);
+ app1->kbdq.puts (s, l);
lparam &= ~GCS_RESULTSTR;
- int rl = app.kbdq.gime.ImmGetCompositionString (hIMC, GCS_RESULTREADSTR, 0, 0);
+ int rl = app1->kbdq.gime.ImmGetCompositionString (hIMC, GCS_RESULTREADSTR, 0, 0);
if (rl > 0)
{
char *rs = (char *)alloca (rl + 1);
- if (app.kbdq.gime.ImmGetCompositionString (hIMC, GCS_RESULTREADSTR,
+ if (app1->kbdq.gime.ImmGetCompositionString (hIMC, GCS_RESULTREADSTR,
rs, rl) == rl)
{
s[l] = rs[rl] = 0;
- app.ime_compq.push (s, l, rs, rl);
+ app1->ime_compq.push (s, l, rs, rl);
}
}
}
@@ -430,14 +431,14 @@ ime_composition (HWND hwnd, LPARAM lparam)
}
else
{
- int l = app.kbdq.gime.ImmGetCompositionStringW (hIMC, GCS_RESULTSTR, 0, 0);
+ int l = app1->kbdq.gime.ImmGetCompositionStringW (hIMC, GCS_RESULTSTR, 0, 0);
if (l > 0)
{
ucs2_t *s = (ucs2_t *)alloca (l + sizeof (ucs2_t));
- if (app.kbdq.gime.ImmGetCompositionStringW (hIMC, GCS_RESULTSTR, s, l) == l)
+ if (app1->kbdq.gime.ImmGetCompositionStringW (hIMC, GCS_RESULTSTR, s, l) == l)
{
const Char *tab = 0;
- switch (PRIMARYLANGID (app.kbdq.kbd_langid ()))
+ switch (PRIMARYLANGID (app1->kbdq.kbd_langid ()))
{
case LANG_JAPANESE:
tab = wc2cp932_table;
@@ -449,7 +450,7 @@ ime_composition (HWND hwnd, LPARAM lparam)
break;
case LANG_CHINESE:
- switch (SUBLANGID (app.kbdq.kbd_langid ()))
+ switch (SUBLANGID (app1->kbdq.kbd_langid ()))
{
case SUBLANG_CHINESE_TRADITIONAL:
case SUBLANG_CHINESE_HONGKONG:
@@ -473,82 +474,84 @@ ime_composition (HWND hwnd, LPARAM lparam)
if ((!tab || (cc = tab[*sp]) == Char (-1))
&& (cc = w2i (*sp)) == Char (-1))
{
- app.kbdq.putc (utf16_ucs2_to_undef_pair_high (*sp));
+ app1->kbdq.putc (utf16_ucs2_to_undef_pair_high (*sp));
cc = utf16_ucs2_to_undef_pair_low (*sp);
}
- app.kbdq.putc (cc);
+ app1->kbdq.putc (cc);
}
lparam &= ~GCS_RESULTSTR;
- int rl = app.kbdq.gime.ImmGetCompositionStringW (hIMC, GCS_RESULTREADSTR, 0, 0);
+ int rl = app1->kbdq.gime.ImmGetCompositionStringW (hIMC, GCS_RESULTREADSTR, 0, 0);
if (rl > 0)
{
ucs2_t *rs = (ucs2_t *)alloca (rl + sizeof (ucs2_t));
- if (app.kbdq.gime.ImmGetCompositionStringW (hIMC, GCS_RESULTREADSTR,
+ if (app1->kbdq.gime.ImmGetCompositionStringW (hIMC, GCS_RESULTREADSTR,
rs, rl) == rl)
{
rl /= sizeof (ucs2_t);
s[l] = rs[rl] = 0;
- app.ime_compq.push (s, l, rs, rl, tab);
+ app1->ime_compq.push (s, l, rs, rl, tab);
}
}
}
}
}
- app.kbdq.gime.ImmReleaseContext (hwnd, hIMC);
+ app1->kbdq.gime.ImmReleaseContext (hwnd, hIMC);
}
return lparam;
}
void
-set_caret_blink_time ()
+set_caret_blink_time (ApplicationFrame *app1)
{
if (xsymbol_value (Vblink_caret) == Qnil)
{
- if (!app.default_caret_blink_time)
- app.default_caret_blink_time = GetCaretBlinkTime ();
- if (app.default_caret_blink_time)
+ if (!app1->default_caret_blink_time)
+ app1->default_caret_blink_time = GetCaretBlinkTime ();
+ if (app1->default_caret_blink_time)
SetCaretBlinkTime (10000);
}
}
void
-restore_caret_blink_time ()
+restore_caret_blink_time (ApplicationFrame *app1)
{
- if (app.default_caret_blink_time)
+ if (app1->default_caret_blink_time)
{
- SetCaretBlinkTime (app.default_caret_blink_time);
- app.default_caret_blink_time = 0;
+ SetCaretBlinkTime (app1->default_caret_blink_time);
+ app1->default_caret_blink_time = 0;
}
}
static void
-refresh_blink_interval ()
+refresh_blink_interval (ApplicationFrame *app1)
{
- if (app.ime_composition || GetFocus () != app.toplev)
+ if (app1->ime_composition || GetFocus () != app1->toplev)
return;
if (xsymbol_value (Vblink_caret) == Qnil)
{
- set_caret_blink_time ();
- if (app.active_frame.has_caret)
+ set_caret_blink_time (app1);
+ if (app1->active_frame.has_caret)
{
- Window *wp = selected_window ();
+ Window *wp = selected_window (app1);
if (wp)
{
- wp->delete_caret ();
+ wp->delete_caret (app1);
wp->update_caret ();
}
}
}
else
- restore_caret_blink_time ();
+ restore_caret_blink_time (app1);
}
+extern void notify_focus(ApplicationFrame *app1);
+
static int
-process_mouse_activate (LPARAM lparam)
+process_mouse_activate (ApplicationFrame *app1, LPARAM lparam)
{
int r;
- if (app.toplevel_is_active
+ if (app1->toplevel_is_active
|| xsymbol_value (Veat_mouse_activate) == Qnil)
r = MA_ACTIVATE;
else
@@ -564,78 +567,105 @@ process_mouse_activate (LPARAM lparam)
r = MA_ACTIVATE;
break;
}
-
- if (GetFocus () != app.toplev)
- SetFocus (app.toplev);
+ if (GetFocus () != app1->toplev)
+ SetFocus (app1->toplev);
return r;
}
LRESULT CALLBACK
-toplevel_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
+toplevel_wnd_create(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
- lChar cc;
+ CREATESTRUCT *cs = (CREATESTRUCT *)lparam;
+ ApplicationFrame *app1 = (ApplicationFrame *)cs->lpCreateParams;
+ app1->toplev = hwnd;
+ insert_app_frame(hwnd, app1);
+ app1->hwnd_sw = CreateStatusWindow ((SBARS_SIZEGRIP | WS_CHILD | WS_VISIBLE
+ | WS_CLIPCHILDREN | WS_CLIPSIBLINGS),
+ 0, hwnd, 0);
+ if (!app1->hwnd_sw)
+ return -1;
+
+ app1->stat_area.init (app1->hwnd_sw);
+ app1->status_window.set (app1->hwnd_sw);
- mouse_state::update_cursor (msg, wparam);
- switch (msg)
+ try
{
- case WM_CREATE:
- app.toplev = hwnd;
- app.hwnd_sw = CreateStatusWindow ((SBARS_SIZEGRIP | WS_CHILD | WS_VISIBLE
+ app1->active_frame.fnkey = new FKWin;
+ }
+ catch (nonlocal_jump &)
+ {
+ report_out_of_memory ();
+ return -1;
+ }
+ if (!CreateWindow (FunctionKeyClassName, "",
+ (((Window::w_default_flags & Window::WF_FUNCTION_BAR)
+ ? WS_VISIBLE : 0)
+ | WS_CHILD | WS_CLIPSIBLINGS),
+ 0, 0, 0, 0,
+ hwnd, 0, app1->hinst, app1->active_frame.fnkey))
+ return -1;
+
+ app1->active_frame.hwnd = CreateWindow (Application::FrameClassName, "",
+ (WS_VISIBLE | WS_CHILD
| WS_CLIPCHILDREN | WS_CLIPSIBLINGS),
- 0, hwnd, 0);
- if (!app.hwnd_sw)
- return -1;
+ 0, 0, 0, 0,
+ hwnd, 0, app1->hinst, app1);
+ if (!app1->active_frame.hwnd)
+ return -1;
- app.stat_area.init (app.hwnd_sw);
- app.status_window.set (app.hwnd_sw);
+ app1->mframe->init(hwnd, app1->active_frame.hwnd);
+ app1->user_timer.init (hwnd);
- try
- {
- app.active_frame.fnkey = new FKWin;
- }
- catch (nonlocal_jump &)
- {
- report_out_of_memory ();
- return -1;
- }
- if (!CreateWindow (FunctionKeyClassName, "",
- (((Window::w_default_flags & Window::WF_FUNCTION_BAR)
- ? WS_VISIBLE : 0)
- | WS_CHILD | WS_CLIPSIBLINGS),
- 0, 0, 0, 0,
- hwnd, 0, app.hinst, app.active_frame.fnkey))
- return -1;
-
- app.active_frame.hwnd = CreateWindow (Application::FrameClassName, "",
- (WS_VISIBLE | WS_CHILD
- | WS_CLIPCHILDREN | WS_CLIPSIBLINGS),
- 0, 0, 0, 0,
- hwnd, 0, app.hinst, 0);
- if (!app.active_frame.hwnd)
- return -1;
-
- g_frame.init (hwnd, app.active_frame.hwnd);
- app.user_timer.init (hwnd);
-
- DragAcceptFiles (hwnd, 1);
+ DragAcceptFiles (hwnd, 1);
#ifdef DnDTEST
- RegisterDragDrop (hwnd, &tdropt);
+ RegisterDragDrop (hwnd, &tdropt);
#endif
- app.hwnd_clipboard = SetClipboardViewer (hwnd);
- SetTimer (hwnd, TID_ITIMER, itimer::interval * 1000, 0);
- return 0;
+ app1->hwnd_clipboard = SetClipboardViewer (hwnd);
+ SetTimer (hwnd, TID_ITIMER, itimer::interval * 1000, 0);
+ return 0;
+}
+extern ApplicationFrame *first_app_frame();
+extern bool is_last_app_frame();
+extern void delete_app_frame(ApplicationFrame *app1);
+
+LRESULT CALLBACK
+toplevel_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+ lChar cc;
+
+ mouse_state::update_cursor (msg, wparam);
+ if(msg == WM_CREATE) /* retrieve_app not yet available. */
+ return toplevel_wnd_create(hwnd, msg, wparam, lparam);
+
+ ApplicationFrame *app1 = retrieve_app_frame(hwnd);
+ if(app1 == NULL)
+ app1 = first_app_frame();
+ else if(app1 == (ApplicationFrame *)1)
+ return DefWindowProc (hwnd, msg, wparam, lparam);
+ switch (msg)
+ {
case WM_DESTROY:
- end_listen_server ();
+ if(is_last_app_frame())
+ {
+ end_listen_server ();
#ifdef DnDTEST
RevokeDragDrop (hwnd);
#endif
- app.user_timer.cleanup ();
- environ::save_geometry ();
- ChangeClipboardChain (hwnd, app.hwnd_clipboard);
- PostQuitMessage (0);
- app.toplev = 0;
+ app1->user_timer.cleanup ();
+ environ::save_geometry ();
+ ChangeClipboardChain (hwnd, app1->hwnd_clipboard);
+ PostQuitMessage (0);
+ }
+ else
+ {
+ app1->user_timer.cleanup ();
+ ChangeClipboardChain (hwnd, app1->hwnd_clipboard);
+ }
+ app1->toplev = 0;
+ delete_app_frame(app1);
+ insert_app_frame(hwnd, (ApplicationFrame *)1);
return 0;
case WM_PAINT:
@@ -652,7 +682,7 @@ toplevel_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
GetClientRect (hwnd, &r);
draw_hline (hdc, 0, r.right, 0, sysdep.btn_shadow);
- GetWindowRect (app.active_frame.hwnd, &r);
+ GetWindowRect (app1->active_frame.hwnd, &r);
MapWindowPoints (HWND_DESKTOP, hwnd, (POINT *)&r, 1);
draw_hline (hdc, r.left, r.right, r.top - 1, sysdep.btn_shadow);
@@ -662,32 +692,32 @@ toplevel_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
}
case WM_LBUTTONDOWN:
- g_frame.lbtn_down (lparam);
+ app1->mframe->lbtn_down(lparam);
return 0;
case WM_PARENTNOTIFY:
if (LOWORD (wparam) == WM_DESTROY)
- g_frame.child_destroy (HWND (lparam));
+ app1->mframe->child_destroy (HWND (lparam));
break;
case WM_NOTIFY:
{
LRESULT result = 0;
- if (g_frame.notify ((NMHDR *)lparam, result))
+ if (app1->mframe->notify ((NMHDR *)lparam, result))
return result;
break;
}
case WM_CHANGECBCHAIN:
- if (HWND (wparam) == app.hwnd_clipboard)
- app.hwnd_clipboard = HWND (lparam);
- else if (app.hwnd_clipboard)
- SendMessage (app.hwnd_clipboard, msg, wparam, lparam);
+ if (HWND (wparam) == app1->hwnd_clipboard)
+ app1->hwnd_clipboard = HWND (lparam);
+ else if (app1->hwnd_clipboard)
+ SendMessage (app1->hwnd_clipboard, msg, wparam, lparam);
break;
case WM_DRAWCLIPBOARD:
- if (app.hwnd_clipboard)
- SendMessage (app.hwnd_clipboard, msg, wparam, lparam);
+ if (app1->hwnd_clipboard)
+ SendMessage (app1->hwnd_clipboard, msg, wparam, lparam);
xsymbol_value (Vclipboard_newer_than_kill_ring_p) = Qt;
xsymbol_value (Vkill_ring_newer_than_clipboard_p) = Qnil;
break;
@@ -697,26 +727,26 @@ toplevel_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Ctl3d::color_change ();
Window::init_colors ();
reload_caret_colors ();
- Window::update_last_caret ();
- SendMessage (app.hwnd_sw, msg, wparam, lparam);
+ Window::update_last_caret (app1);
+ SendMessage (app1->hwnd_sw, msg, wparam, lparam);
break;
case WM_INPUTLANGCHANGE:
- app.kbdq.init_kbd_encoding (LANGID (lparam));
- ime_open_status (hwnd);
+ app1->kbdq.init_kbd_encoding (LANGID (lparam));
+ ime_open_status (app1, hwnd);
return 1;
case WM_WININICHANGE:
/*case WM_SETTINGCHANGE:*/
Ctl3d::ini_change ();
sysdep.load_settings ();
- g_frame.reload_settings ();
+ app1->mframe->reload_settings ();
{
RECT or, nr;
- GetClientRect (app.hwnd_sw, &or);
- SendMessage (app.hwnd_sw, msg, wparam, lparam);
- GetClientRect (app.hwnd_sw, &nr);
- app.stat_area.reload_settings ();
+ GetClientRect (app1->hwnd_sw, &or);
+ SendMessage (app1->hwnd_sw, msg, wparam, lparam);
+ GetClientRect (app1->hwnd_sw, &nr);
+ app1->stat_area.reload_settings ();
if (or.bottom != nr.bottom)
{
GetWindowRect (hwnd, &nr);
@@ -737,12 +767,12 @@ toplevel_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
#endif
}
else
- app.stat_area.resize ();
+ app1->stat_area.resize ();
}
if (!sysdep.Win4p ())
{
- app.kbdq.init_kbd_encoding ();
- ime_open_status (hwnd);
+ app1->kbdq.init_kbd_encoding ();
+ ime_open_status (app1, hwnd);
}
return 0;
@@ -750,35 +780,36 @@ toplevel_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
return 0;
case WM_SIZE:
- SendMessage (app.hwnd_sw, msg, wparam, lparam);
- app.stat_area.resize ();
+ SendMessage (app1->hwnd_sw, msg, wparam, lparam);
+ app1->stat_area.resize ();
if (wparam != SIZE_MINIMIZED)
- resize_toplevel (LOWORD (lparam), HIWORD (lparam));
+ resize_toplevel (app1, LOWORD (lparam), HIWORD (lparam));
return 0;
case WM_MOVE:
- set_ime_caret ();
+ set_ime_caret (app1);
break;
case WM_SETFOCUS:
- app.active_frame.has_focus = 1;
- app.kbdq.toggle_ime (app.ime_open_mode, 0);
- set_caret_blink_time ();
- Window::update_last_caret ();
- app.active_frame.fnkey->update_vkey (0);
+ notify_focus(app1);
+ app1->active_frame.has_focus = 1;
+ app1->kbdq.toggle_ime (app1->ime_open_mode, 0);
+ set_caret_blink_time (app1);
+ Window::update_last_caret (app1);
+ app1->active_frame.fnkey->update_vkey (0);
return 0;
case WM_KILLFOCUS:
- app.active_frame.has_focus = 0;
- restore_caret_blink_time ();
- Window::delete_caret ();
- app.active_frame.fnkey->update_vkey (1);
+ app1->active_frame.has_focus = 0;
+ restore_caret_blink_time (app1);
+ Window::delete_caret (app1);
+ app1->active_frame.fnkey->update_vkey (1);
break;
case WM_KEYUP:
case WM_SYSKEYUP:
- app.last_vkeycode = -1;
- app.active_frame.fnkey->unset_vkey (wparam);
+ app1->last_vkeycode = -1;
+ app1->active_frame.fnkey->unset_vkey (wparam);
break;
case WM_SYSKEYDOWN:
@@ -787,18 +818,18 @@ toplevel_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|| wparam == VK_F10)
#endif
{
- app.active_frame.fnkey->set_vkey (wparam);
- if (int (wparam) == app.last_vkeycode)
- app.kbd_repeat_count++;
+ app1->active_frame.fnkey->set_vkey (wparam);
+ if (int (wparam) == app1->last_vkeycode)
+ app1->kbd_repeat_count++;
else
{
- app.last_vkeycode = wparam;
- app.kbd_repeat_count = 1;
+ app1->last_vkeycode = wparam;
+ app1->kbd_repeat_count = 1;
}
cc = decode_syskeys (wparam, lparam);
if (cc != lChar_EOF)
{
- app.kbdq.putc (cc);
+ app1->kbdq.putc (cc);
return 0;
}
}
@@ -807,38 +838,38 @@ toplevel_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
case WM_MENUCHAR:
if (HIWORD (wparam))
return 0;
- app.kbdq.putc (decode_syschars (LOWORD (wparam)));
+ app1->kbdq.putc (decode_syschars (LOWORD (wparam)));
return 1;
case WM_SYSCHAR:
if (xsymbol_value (Venable_meta_key) != Qnil)
{
- app.kbdq.putc (decode_syschars (wparam));
+ app1->kbdq.putc (decode_syschars (wparam));
return 0;
}
break;
case WM_KEYDOWN:
- app.active_frame.fnkey->set_vkey (wparam);
- if (int (wparam) == app.last_vkeycode)
- app.kbd_repeat_count++;
+ app1->active_frame.fnkey->set_vkey (wparam);
+ if (int (wparam) == app1->last_vkeycode)
+ app1->kbd_repeat_count++;
else
{
- app.last_vkeycode = wparam;
- app.kbd_repeat_count = 1;
+ app1->last_vkeycode = wparam;
+ app1->kbd_repeat_count = 1;
}
cc = decode_keys (wparam, lparam);
if (cc != lChar_EOF)
{
- app.kbdq.putc (cc);
+ app1->kbdq.putc (cc);
return 0;
}
break;
case WM_CHAR:
if (xsymbol_value (Vno_input_language_change_notification) != Qnil)
- app.kbdq.init_kbd_encoding ();
- app.kbdq.putc (decode_chars (wparam));
+ app1->kbdq.init_kbd_encoding ();
+ app1->kbdq.putc (decode_chars (wparam));
return 0;
case WM_PRIVATE_WCHAR:
@@ -846,33 +877,33 @@ toplevel_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
ucs2_t wc = ucs2_t (wparam);
Char cc = w2i_half_width (wc);
if (cc != Char (-1))
- app.kbdq.putc (decode_chars (cc));
+ app1->kbdq.putc (decode_chars (cc));
else
{
- app.kbdq.putc (utf16_ucs2_to_undef_pair_high (wc));
- app.kbdq.putc (utf16_ucs2_to_undef_pair_low (wc));
+ app1->kbdq.putc (utf16_ucs2_to_undef_pair_high (wc));
+ app1->kbdq.putc (utf16_ucs2_to_undef_pair_low (wc));
}
return 0;
}
case WM_IME_ENDCOMPOSITION:
- app.ime_composition = 0;
+ app1->ime_composition = 0;
break;
case WM_IME_STARTCOMPOSITION:
- app.ime_composition = 1;
- set_ime_caret ();
+ app1->ime_composition = 1;
+ set_ime_caret (app1);
break;
case WM_IME_NOTIFY:
if (wparam == IMN_SETOPENSTATUS)
- ime_open_status (hwnd);
+ ime_open_status (app1, hwnd);
break;
case WM_PRIVATE_IME_MODE:
{
- selected_buffer ()->safe_run_hook (Vime_mode_hook, 0);
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ selected_buffer (app1)->safe_run_hook (Vime_mode_hook, 0);
+ for (Window *wp = app1->active_frame.windows; wp; wp = wp->w_next)
if (wp->w_ime_mode_line)
{
wp->w_disp_flags |= Window::WDF_MODELINE;
@@ -883,31 +914,31 @@ toplevel_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
case WM_IME_CHAR:
if (xsymbol_value (Vno_input_language_change_notification) != Qnil)
- app.kbdq.init_kbd_encoding ();
- app.kbdq.putw (wparam);
+ app1->kbdq.init_kbd_encoding ();
+ app1->kbdq.putw (wparam);
return 0;
case WM_IME_COMPOSITION:
- lparam = ime_composition (hwnd, lparam);
+ lparam = ime_composition (app1, hwnd, lparam);
break;
case WM_PRIVATE_QUIT:
{
HWND active = get_active_window ();
if (active == hwnd)
- app.kbdq.putc (xchar_code (app.lquit_char));
+ app1->kbdq.putc (xchar_code (app1->lquit_char));
else
PostMessage (active, msg, wparam, lparam);
return 0;
}
case WM_MOUSEACTIVATE:
- return process_mouse_activate (lparam);
+ return process_mouse_activate (app1, lparam);
case WM_PRIVATE_DELAYED_ACTIVATE:
{
save_cursor_depth cursor_depth;
- app.kbdq.activate (wparam);
+ app1->kbdq.activate (wparam);
return 0;
}
@@ -922,7 +953,7 @@ toplevel_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
int eq = pid == GetCurrentProcessId ();
if (LOWORD (wparam) != WA_INACTIVE)
{
- app.status_window.set (app.hwnd_sw);
+ app1->status_window.set (app1->hwnd_sw);
if (!eq && !HIWORD (wparam))
PostMessage (hwnd, WM_PRIVATE_DELAYED_ACTIVATE, 1, 0);
}
@@ -937,12 +968,12 @@ toplevel_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
case WM_ACTIVATEAPP:
case WM_PRIVATE_ACTIVATEAPP:
- app.toplevel_is_active = wparam;
- PostThreadMessage (app.quit_thread_id, msg, wparam, lparam);
+ app1->toplevel_is_active = wparam;
+ PostThreadMessage (app1->quit_thread_id, msg, wparam, lparam);
return 0;
case WM_PRIVATE_PROCESS_OUTPUT:
- read_process_output (wparam, lparam);
+ read_process_output (app1, wparam, lparam);
return 0;
case WM_PRIVATE_PROCESS_TERMINATE:
@@ -953,39 +984,39 @@ toplevel_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
switch (wparam)
{
case TID_USER:
- app.user_timer.timer ();
+ app1->user_timer.timer ();
break;
case TID_SLEEP:
- app.sleep_timer_exhausted = 1;
+ app1->sleep_timer_exhausted = 1;
break;
case TID_ITIMER:
- app.stat_area.timer ();
- app.gc_itimer.inc ();
- app.as_itimer.inc ();
- refresh_blink_interval ();
- if (app.kbdq.idlep ())
+ app1->stat_area.timer ();
+ g_app.gc_itimer.inc ();
+ app1->as_itimer.inc ();
+ refresh_blink_interval (app1);
+ if (app1->kbdq.idlep ())
{
- if (app.gc_itimer.expired (30))
+ if (g_app.gc_itimer.expired (30))
{
- app.gc_itimer.reset ();
+ g_app.gc_itimer.reset ();
if (ldataP::ld_nwasted)
- app.kbdq.gc_timer_expired ();
+ app1->kbdq.gc_timer_expired ();
}
long interval;
- if (app.f_auto_save_pending
- || (app.auto_save_count > 5
+ if (app1->f_auto_save_pending
+ || (app1->auto_save_count > 5
&& safe_fixnum_value (xsymbol_value (Vauto_save_interval_timer),
&interval)
- && app.as_itimer.expired (interval)))
+ && app1->as_itimer.expired (interval)))
{
- if (GetTickCount () - app.last_cmd_tick < 5000)
- app.f_auto_save_pending = 1;
+ if (GetTickCount () - app1->last_cmd_tick < 5000)
+ app1->f_auto_save_pending = 1;
else
{
- app.as_itimer.reset ();
+ app1->as_itimer.reset ();
try
{
Fdo_auto_save (Qt);
@@ -994,10 +1025,10 @@ toplevel_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
print_condition (nonlocal_jump::data ());
}
- app.auto_save_count = 0;
- app.f_auto_save_pending = 0;
+ app1->auto_save_count = 0;
+ app1->f_auto_save_pending = 0;
}
- end_wait_cursor (1);
+ end_wait_cursor (1, app1);
}
}
break;
@@ -1017,9 +1048,12 @@ toplevel_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
break;
/* fall thru... */
case WM_CLOSE:
- Buffer::kill_xyzzy (1);
- return 0;
-
+ if(is_last_app_frame())
+ {
+ Buffer::kill_xyzzy (1);
+ return 0;
+ }
+ break; /* call def proc */
case WM_INITMENUPOPUP:
if (!HIWORD (lparam))
{
@@ -1031,7 +1065,7 @@ toplevel_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
case WM_COMMAND:
if (!HIWORD (wparam))
{
- app.kbdq.putc (LCHAR_MENU | LOWORD (wparam));
+ app1->kbdq.putc (LCHAR_MENU | LOWORD (wparam));
return 0;
}
break;
@@ -1044,22 +1078,22 @@ toplevel_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
return 0;
case WM_SETCURSOR:
- if (app.wait_cursor_depth)
+ if (app1->wait_cursor_depth)
{
SetCursor (sysdep.hcur_wait);
return 1;
}
- else if (g_frame.set_cursor (hwnd, wparam, lparam))
+ else if (app1->mframe->set_cursor (hwnd, wparam, lparam))
return 1;
break;
case WM_ENTERMENULOOP:
- app.f_protect_quit = 1;
+ app1->f_protect_quit = 1;
erase_popup (1, 0);
break;
case WM_EXITMENULOOP:
- app.f_protect_quit = 0;
+ app1->f_protect_quit = 0;
break;
#if 1
case WM_PRIVATE_FOREGROUND:
@@ -1072,12 +1106,12 @@ toplevel_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
case WM_IME_REQUEST:
if (wparam == IMR_RECONVERTSTRING)
- return app.kbdq.reconvert ((RECONVERTSTRING *)lparam, 0);
+ return app1->kbdq.reconvert ((RECONVERTSTRING *)lparam, 0);
break;
case WM_DRAWITEM:
- if (app.status_window.paint ((DRAWITEMSTRUCT *)lparam)
- || g_frame.draw_item ((DRAWITEMSTRUCT *)lparam))
+ if (app1->status_window.paint ((DRAWITEMSTRUCT *)lparam)
+ || app1->mframe->draw_item ((DRAWITEMSTRUCT *)lparam))
return 1;
break;
@@ -1091,14 +1125,14 @@ toplevel_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
static const UINT atok = RegisterWindowMessage (WM_ATOK_RECONVERT);
if ((msg == msime || msg == atok)
&& wparam == IMR_RECONVERTSTRING)
- return app.kbdq.reconvert ((RECONVERTSTRING *)lparam, 1);
+ return app1->kbdq.reconvert ((RECONVERTSTRING *)lparam, 1);
}
wheel_info wi;
if (xsymbol_value (Vsupport_mouse_wheel) != Qnil
&& g_wheel.msg_handler (hwnd, msg, wparam, lparam, wi))
{
- Window *wp = Window::find_scr_point_window (wi.wi_pt, 0, 0);
+ Window *wp = Window::find_scr_point_window (app1, wi.wi_pt, 0, 0);
if (wp)
wp->wheel_scroll (wi);
return 0;
@@ -1106,7 +1140,19 @@ toplevel_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
break;
}
- return app.kbdq.gime.DefWindowProc (hwnd, msg, wparam, lparam);
+ return app1->kbdq.gime.DefWindowProc (hwnd, msg, wparam, lparam);
+}
+
+static inline void
+set_app_frame (HWND hwnd, ApplicationFrame *app1)
+{
+ SetWindowLong (hwnd, 0, LONG (app1));
+}
+
+static inline ApplicationFrame *
+get_app_frame (HWND hwnd)
+{
+ return (ApplicationFrame *)GetWindowLong (hwnd, 0);
}
LRESULT CALLBACK
@@ -1118,8 +1164,11 @@ frame_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
case WM_CREATE:
{
RECT r;
- GetClientRect (app.toplev, &r);
- frame_rect (r.right, r.bottom, r);
+ CREATESTRUCT *cs = (CREATESTRUCT *)lparam;
+ ApplicationFrame *app1 = (ApplicationFrame*)cs->lpCreateParams;
+ set_app_frame(hwnd, app1);
+ GetClientRect (app1->toplev, &r);
+ frame_rect (app1, r.right, r.bottom, r);
MoveWindow (hwnd, r.left, r.top, r.right - r.left, r.bottom - r.top, 0);
return 0;
}
@@ -1129,7 +1178,7 @@ frame_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
PAINTSTRUCT ps;
HDC hdc = BeginPaint (hwnd, &ps);
fill_rect (hdc, ps.rcPaint, sysdep.btn_face);
- for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
+ for (Window *wp = get_app_frame(hwnd)->active_frame.windows; wp; wp = wp->w_next)
if (wp->flags () & Window::WF_RULER)
wp->paint_ruler (hdc);
EndPaint (hwnd, &ps);
@@ -1137,27 +1186,27 @@ frame_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
}
case WM_LBUTTONDOWN:
- return Window::frame_window_resize (hwnd, lparam);
+ return Window::frame_window_resize (get_app_frame(hwnd), hwnd, lparam);
case WM_SIZE:
- if (app.active_frame.windows)
+ if (get_app_frame(hwnd)->active_frame.windows)
{
- SIZE osize = app.active_frame.size;
- app.active_frame.size.cx = LOWORD (lparam);
- app.active_frame.size.cy = HIWORD (lparam);
- Window::compute_geometry (osize);
- Window::move_all_windows ();
- Window::repaint_all_windows ();
+ SIZE osize = get_app_frame(hwnd)->active_frame.size;
+ get_app_frame(hwnd)->active_frame.size.cx = LOWORD (lparam);
+ get_app_frame(hwnd)->active_frame.size.cy = HIWORD (lparam);
+ Window::compute_geometry (get_app_frame(hwnd), osize);
+ Window::move_all_windows (get_app_frame(hwnd));
+ Window::repaint_all_windows (get_app_frame(hwnd));
}
return 0;
case WM_SETCURSOR:
- if (Window::frame_window_setcursor (hwnd, wparam, lparam))
+ if (Window::frame_window_setcursor (get_app_frame(hwnd), hwnd, wparam, lparam))
return 1;
break;
case WM_MOUSEACTIVATE:
- return process_mouse_activate (lparam);
+ return process_mouse_activate (get_app_frame(hwnd), lparam);
}
return DefWindowProc (hwnd, msg, wparam, lparam);
@@ -1176,7 +1225,7 @@ get_window (HWND hwnd)
}
static int
-on_vedge_p (HWND hwnd, POINT &p)
+on_vedge_p (ApplicationFrame *app1, HWND hwnd, POINT &p)
{
ScreenToClient (hwnd, &p);
if (p.x >= 0)
@@ -1184,16 +1233,22 @@ on_vedge_p (HWND hwnd, POINT &p)
RECT r;
GetWindowRect (hwnd, &r);
- MapWindowPoints (HWND_DESKTOP, app.active_frame.hwnd, (POINT *)&r, 2);
+ MapWindowPoints (HWND_DESKTOP, app1->active_frame.hwnd, (POINT *)&r, 2);
return r.left;
}
static int
-on_vedge_p (HWND hwnd)
+on_vedge_p (ApplicationFrame *app1, HWND hwnd)
{
POINT p;
GetCursorPos (&p);
- return on_vedge_p (hwnd, p);
+ return on_vedge_p (app1, hwnd, p);
+}
+
+static inline ApplicationFrame *
+get_app_frame_from_window(HWND hwnd)
+{
+ return get_window(hwnd)->w_owner;
}
LRESULT CALLBACK
@@ -1213,31 +1268,31 @@ client_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
}
case WM_VSCROLL:
- if (GetFocus () != app.toplev)
- SetFocus (app.toplev);
+ if (GetFocus () != get_app_frame(hwnd)->toplev)
+ SetFocus (get_app_frame(hwnd)->toplev);
get_window (hwnd)->process_vscroll (LOWORD (wparam));
return 0;
case WM_HSCROLL:
- if (GetFocus () != app.toplev)
- SetFocus (app.toplev);
+ if (GetFocus () != get_app_frame(hwnd)->toplev)
+ SetFocus (get_app_frame(hwnd)->toplev);
get_window (hwnd)->process_hscroll (LOWORD (wparam));
return 0;
case WM_LBUTTONDOWN:
- app.mouse.down (get_window (hwnd), wparam, lparam, MK_LBUTTON);
+ get_app_frame_from_window(hwnd)->mouse.down (get_window (hwnd), wparam, lparam, MK_LBUTTON);
return 0;
case WM_MBUTTONDOWN:
- app.mouse.down (get_window (hwnd), wparam, lparam, MK_MBUTTON);
+ get_app_frame_from_window(hwnd)->mouse.down (get_window (hwnd), wparam, lparam, MK_MBUTTON);
return 0;
case WM_RBUTTONDOWN:
- app.mouse.down (get_window (hwnd), wparam, lparam, MK_RBUTTON);
+ get_app_frame_from_window(hwnd)->mouse.down (get_window (hwnd), wparam, lparam, MK_RBUTTON);
return 0;
case WM_XBUTTONDOWN:
- app.mouse.down (get_window (hwnd), LOWORD (wparam), lparam,
+ get_app_frame_from_window(hwnd)->mouse.down (get_window (hwnd), LOWORD (wparam), lparam,
(HIWORD (wparam) == XBUTTON1
? MK_XBUTTON1 : MK_XBUTTON2));
return 0;
@@ -1247,28 +1302,28 @@ client_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
if (wparam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON
| MK_XBUTTON1 | MK_XBUTTON2))
set_current_cursor (wp);
- app.mouse.move (wp, wparam, lparam);
+ get_app_frame_from_window(hwnd)->mouse.move (wp, wparam, lparam);
return 0;
case WM_LBUTTONUP:
- app.mouse.up (get_window (hwnd), wparam, lparam, MK_LBUTTON);
+ get_app_frame_from_window(hwnd)->mouse.up (get_window (hwnd), wparam, lparam, MK_LBUTTON);
return 0;
case WM_MBUTTONUP:
- app.mouse.up (get_window (hwnd), wparam, lparam, MK_MBUTTON);
+ get_app_frame_from_window(hwnd)->mouse.up (get_window (hwnd), wparam, lparam, MK_MBUTTON);
return 0;
case WM_RBUTTONUP:
- app.mouse.up (get_window (hwnd), wparam, lparam, MK_RBUTTON);
+ get_app_frame_from_window(hwnd)->mouse.up (get_window (hwnd), wparam, lparam, MK_RBUTTON);
return 0;
case WM_XBUTTONUP:
- app.mouse.up (get_window (hwnd), LOWORD (wparam), lparam,
+ get_app_frame_from_window(hwnd)->mouse.up (get_window (hwnd), LOWORD (wparam), lparam,
HIWORD (wparam) == XBUTTON1 ? MK_XBUTTON1 : MK_XBUTTON2);
return 0;
case WM_CANCELMODE:
- app.mouse.cancel ();
+ get_app_frame_from_window(hwnd)->mouse.cancel ();
break;
case WM_ERASEBKGND:
@@ -1287,7 +1342,7 @@ client_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
return 1;
case HTBORDER:
- if (on_vedge_p (hwnd) > 0)
+ if (on_vedge_p (get_app_frame_from_window(hwnd), hwnd) > 0)
{
SetCursor (sysdep.hcur_sizewe);
return 1;
@@ -1302,13 +1357,13 @@ client_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
POINT point;
point.x = short (LOWORD (lparam));
point.y = short (HIWORD (lparam));
- int x = on_vedge_p (hwnd, point);
+ int x = on_vedge_p (get_app_frame_from_window(hwnd), hwnd, point);
if (x > 0)
{
point.x = short (LOWORD (lparam));
point.y = short (HIWORD (lparam));
- ScreenToClient (app.active_frame.hwnd, &point);
- Window::frame_window_resize (app.active_frame.hwnd,
+ ScreenToClient (get_app_frame_from_window(hwnd)->active_frame.hwnd, &point);
+ Window::frame_window_resize (get_app_frame_from_window(hwnd), get_app_frame_from_window(hwnd)->active_frame.hwnd,
MAKELONG (x - 1, point.y),
&point);
return 0;
@@ -1330,7 +1385,7 @@ client_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
break;
case WM_PASTE:
- app.kbdq.paste ();
+ get_app_frame_from_window(hwnd)->kbdq.paste ();
break;
case WM_NCMOUSEMOVE:
@@ -1338,10 +1393,10 @@ client_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
break;
case WM_MOUSEACTIVATE:
- return process_mouse_activate (lparam);
+ return process_mouse_activate (get_app_frame_from_window(hwnd), lparam);
case WM_SETFOCUS:
- SetFocus (app.toplev);
+ SetFocus (get_app_frame_from_window(hwnd)->toplev);
return 0;
}
@@ -1371,8 +1426,8 @@ modeline_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Window *wp = get_window (hwnd);
if (!wp)
return 0;
- MapWindowPoints (hwnd, app.active_frame.hwnd, &point, 1);
- return wp->frame_window_resize (app.active_frame.hwnd, point, 0);
+ MapWindowPoints (hwnd, get_app_frame_from_window(hwnd)->active_frame.hwnd, &point, 1);
+ return wp->frame_window_resize (get_app_frame_from_window(hwnd)->active_frame.hwnd, point, 0);
}
case WM_PAINT:
@@ -1475,21 +1530,21 @@ toplev_accept_mouse_move_p ()
}
static lisp
-dispatch (lChar cc)
+dispatch (lChar cc, ApplicationFrame *app1)
{
lisp command;
Char c = Char (cc);
- app.gc_itimer.reset ();
- app.as_itimer.reset ();
- app.last_cmd_tick = GetTickCount ();
+ g_app.gc_itimer.reset ();
+ app1->as_itimer.reset ();
+ app1->last_cmd_tick = GetTickCount ();
if (cc & LCHAR_MENU)
{
if (c >= MENU_ID_RANGE_MIN && c < MENU_ID_RANGE_MAX)
command = lookup_menu_command (c);
else if (c >= TOOL_ID_RANGE_MIN && c < TOOL_ID_RANGE_MAX)
- command = g_frame.lookup_command (c);
+ command = active_main_frame().lookup_command (c);
else
return Qt;
if (command == Qnil)
@@ -1521,9 +1576,9 @@ dispatch (lChar cc)
command = g_map.lookup (c);
if (!command)
{
- app.keyseq.push (c, !app.kbdq.macro_is_running ());
+ app1->keyseq.push (c, !app1->kbdq.macro_is_running ());
Fcontinue_pre_selection ();
- app.kbdq.close_ime ();
+ app1->kbdq.close_ime ();
return Qt;
}
}
@@ -1542,9 +1597,9 @@ run_command:
{
xsymbol_value (Vthis_command) = xsymbol_value (Vlast_command);
g_map.translate (command, new_command);
- app.keyseq.push (c, !app.kbdq.macro_is_running ());
+ app1->keyseq.push (c, !app1->kbdq.macro_is_running ());
Fcontinue_pre_selection ();
- app.kbdq.close_ime ();
+ app1->kbdq.close_ime ();
return Qt;
}
command = new_command;
@@ -1553,24 +1608,24 @@ run_command:
g_map.finish ();
- if (!app.kbdq.macro_is_running ())
- app.status_window.clear ();
- app.keyseq.done (c, !app.kbdq.macro_is_running ());
- app.kbdq.restore_ime ();
- app.kbdq.set_next_command_key ();
+ if (!app1->kbdq.macro_is_running ())
+ app1->status_window.clear ();
+ app1->keyseq.done (c, !app1->kbdq.macro_is_running ());
+ app1->kbdq.restore_ime ();
+ app1->kbdq.set_next_command_key ();
- selected_buffer ()->b_ime_mode = app.ime_open_mode;
+ selected_buffer ()->b_ime_mode = app1->ime_open_mode;
if (command == Qnil)
{
if (!char_mouse_move_p (CCF_MOUSEMOVE))
{
- app.status_window.puts (Ekey_not_bound, 1);
+ app1->status_window.puts (Ekey_not_bound, 1);
if (xsymbol_value (Vbeep_on_warn) != Qnil)
Fding ();
}
- app.kbdq.clear ();
- app.kbdq.end_last_command_key ();
+ app1->kbdq.clear ();
+ app1->kbdq.end_last_command_key ();
return Qnil;
}
@@ -1586,17 +1641,21 @@ run_command:
if (nld->type == Qexit_this_level)
throw;
print_condition (nonlocal_jump::data ());
- app.kbdq.clear ();
+ app1->kbdq.clear ();
}
protect_gc gcpro (result);
selected_buffer ()->safe_run_hook (Vpost_command_hook, 1);
- app.kbdq.end_last_command_key ();
+ app1->kbdq.end_last_command_key ();
erase_popup (0, 0);
end_wait_cursor (1);
WINFS::clear_share_cache ();
return result;
}
+#include <exception>
+
+extern void delete_floating_app_frame();
+
void
main_loop ()
{
@@ -1608,10 +1667,10 @@ main_loop ()
dynamic_bind dynb5 (Vthis_command, Qnil);
dynamic_bind dynb6 (Vlast_command, Qnil);
- save_command_key_index sck (app.kbdq);
+ save_command_key_index sck (active_app_frame().kbdq);
while (1)
{
- if (app.kbdq.macro_is_running ())
+ if (active_app_frame().kbdq.macro_is_running ())
pending_refresh_screen ();
else
{
@@ -1627,31 +1686,48 @@ main_loop ()
xsymbol_value (Vsi_find_motion) = Qt;
xsymbol_value (Vevalhook) = Qnil;
xsymbol_value (Vapplyhook) = Qnil;
- app.mouse.clear_move ();
- lChar c = app.kbdq.fetch (1, toplev_accept_mouse_move_p ());
+ active_app_frame().mouse.clear_move ();
+ lChar c;
+ try
+ {
+ c = active_app_frame().kbdq.fetch (1, toplev_accept_mouse_move_p ());
+ }
+ catch(std::exception)
+ {
+ delete_floating_app_frame();
+ continue;
+ }
if (c == lChar_EOF)
break;
while (1)
{
- dispatch (c);
- c = app.kbdq.peek (toplev_accept_mouse_move_p ());
+ dispatch (c, &active_app_frame());
+ try
+ {
+ c = active_app_frame().kbdq.peek (toplev_accept_mouse_move_p ());
+ }
+ catch(std::exception)
+ {
+ delete_floating_app_frame();
+ continue;
+ }
if (c == lChar_EOF)
break;
pending_refresh_screen ();
- if (!app.kbdq.macro_is_running ())
+ if (!active_app_frame().kbdq.macro_is_running ())
Fundo_boundary ();
}
- if (!app.f_auto_save_pending
- && !app.kbdq.macro_is_running ())
+ if (!active_app_frame().f_auto_save_pending
+ && !active_app_frame().kbdq.macro_is_running ())
{
- app.auto_save_count++;
+ active_app_frame().auto_save_count++;
long interval;
if (safe_fixnum_value (xsymbol_value (Vauto_save_interval),
&interval)
- && interval > 0 && app.auto_save_count >= interval)
- app.f_auto_save_pending = 1;
+ && interval > 0 && active_app_frame().auto_save_count >= interval)
+ active_app_frame().f_auto_save_pending = 1;
}
}
}
@@ -1660,9 +1736,9 @@ lisp
execute_string (lisp string)
{
check_stack_overflow ();
- save_command_key_index sck (app.kbdq);
+ save_command_key_index sck (active_app_frame().kbdq);
check_string (string);
- if (app.kbdq.lookup_kbd_macro (string))
+ if (active_app_frame().kbdq.lookup_kbd_macro (string))
FEsimple_error (Ekbd_macro_called_recursively);
lisp val = xsymbol_value (Vprefix_value);
int n = val == Qnil ? 1 : fixnum_value (val);
@@ -1670,15 +1746,15 @@ execute_string (lisp string)
if (xstring_length (string))
for (int i = 0; !n || i < n; i++)
{
- kbd_macro_context macro (app.kbdq, string);
+ kbd_macro_context macro (active_app_frame().kbdq, string);
while (macro.running ())
{
xsymbol_value (Vquit_flag) = Qnil;
xsymbol_value (Vinhibit_quit) = Qnil;
- lChar c = app.kbdq.fetch (0, 0);
+ lChar c = active_app_frame().kbdq.fetch (0, 0);
if (c == lChar_EOF)
return result;
- result = dispatch (c);
+ result = dispatch (c, &active_app_frame());
if (result == Qnil)
return result;
pending_refresh_screen ();
@@ -1692,7 +1768,7 @@ execute_string (lisp string)
lisp
Fsi_minibuffer_message (lisp message, lisp prompt)
{
- app.minibuffer_prompt_column = -1;
+ active_app_frame().minibuffer_prompt_column = -1;
if (message == Qnil)
xsymbol_value (Vminibuffer_message) = Qnil;
else
@@ -1702,7 +1778,7 @@ Fsi_minibuffer_message (lisp message, lisp prompt)
xsymbol_value (Vminibuffer_prompt) = boole (prompt && prompt != Qnil);
}
Window::minibuffer_window ()->w_disp_flags |= Window::WDF_WINDOW;
- if (!app.kbdq.macro_is_running ())
+ if (!active_app_frame().kbdq.macro_is_running ())
refresh_screen (0);
return Qt;
}
@@ -1710,14 +1786,14 @@ Fsi_minibuffer_message (lisp message, lisp prompt)
lisp
Fcancel_mouse_event ()
{
- app.mouse.cancel ();
+ active_app_frame().mouse.cancel ();
return Qt;
}
int
wait_process_terminate (HANDLE h)
{
- app.kbdq.wait_event (h);
+ active_app_frame().kbdq.wait_event (h);
return 1;
}
@@ -1745,8 +1821,8 @@ Fmain_loop ()
lisp
Fsi_show_window_foreground ()
{
- if (IsIconic (app.toplev))
- ShowWindow (app.toplev, SW_RESTORE);
+ if (IsIconic (active_app_frame().toplev))
+ ShowWindow (active_app_frame().toplev, SW_RESTORE);
ForceSetForegroundWindow (get_active_window ());
return Qnil;
}
@@ -1754,11 +1830,11 @@ Fsi_show_window_foreground ()
lisp
Fsi_activate_toplevel ()
{
- if (IsWindowEnabled (app.toplev))
+ if (IsWindowEnabled (active_app_frame().toplev))
{
- if (IsIconic (app.toplev))
- ShowWindow (app.toplev, SW_RESTORE);
- SetActiveWindow (app.toplev);
+ if (IsIconic (active_app_frame().toplev))
+ ShowWindow (active_app_frame().toplev, SW_RESTORE);
+ SetActiveWindow (active_app_frame().toplev);
return Qt;
}
return Qnil;
@@ -1768,7 +1844,7 @@ lisp
Fcall_menu (lisp ln)
{
int req = fixnum_value (ln);
- HMENU hmenu = GetMenu (app.toplev);
+ HMENU hmenu = GetMenu (active_app_frame().toplev);
if (!hmenu)
return Qnil;
int n = GetMenuItemCount (hmenu);
@@ -1787,7 +1863,7 @@ Fcall_menu (lisp ln)
else
break;
}
- PostMessage (app.toplev, WM_PRIVATE_CALL_MENU, b[1], (1 << 29) | 1);
+ PostMessage (active_app_frame().toplev, WM_PRIVATE_CALL_MENU, b[1], (1 << 29) | 1);
return Qt;
}
@@ -1861,11 +1937,11 @@ Fset_quit_char (lisp ch)
vk = LOBYTE (vk);
}
- app.lquit_char = ch;
- app.quit_vkey = vk;
- app.quit_mod = mod;
+ active_app_frame().lquit_char = ch;
+ active_app_frame().quit_vkey = vk;
+ active_app_frame().quit_mod = mod;
- PostThreadMessage (app.quit_thread_id, WM_PRIVATE_MODIFY_HOTKEY, 0, 0);
+ PostThreadMessage (active_app_frame().quit_thread_id, WM_PRIVATE_MODIFY_HOTKEY, 0, 0);
return ch;
}
@@ -1873,5 +1949,5 @@ Fset_quit_char (lisp ch)
lisp
Fquit_char ()
{
- return app.lquit_char;
+ return active_app_frame().lquit_char;
}
diff --git a/src/usertab.cc b/src/usertab.cc
index d70b29f..f0ed5cb 100644
--- a/src/usertab.cc
+++ b/src/usertab.cc
@@ -117,7 +117,7 @@ user_tab_bar::notify (NMHDR *nm, LRESULT &result)
case TCN_SELCHANGE:
case TCN_SELCHANGING:
- if (!app.kbdq.idlep ())
+ if (!active_app_frame().kbdq.idlep ())
{
result = 1; // prevent the selection
return 1;
@@ -314,7 +314,7 @@ user_tab_bar::list_items ()
user_tab_bar *
user_tab_bar::check_bar (lisp name)
{
- dock_bar *bar = g_frame.find (name);
+ dock_bar *bar = active_main_frame().find (name);
if (!bar)
FEsimple_error (Eundefined_toolbar, name);
if (bar->ident () != (void *)&u_ident)
@@ -325,14 +325,14 @@ user_tab_bar::check_bar (lisp name)
lisp
Fcreate_tab_bar (lisp name, lisp callback)
{
- if (g_frame.find (name))
+ if (active_main_frame().find (name))
FEsimple_error (Etoolbar_exist, name);
- user_tab_bar *bar = new user_tab_bar (g_frame, name, callback);
+ user_tab_bar *bar = new user_tab_bar (active_main_frame(), name, callback);
try
{
- bar->create (app.toplev);
+ bar->create (active_app_frame().toplev);
}
catch (nonlocal_jump &)
{
@@ -340,7 +340,7 @@ Fcreate_tab_bar (lisp name, lisp callback)
throw;
}
- g_frame.add (bar);
+ active_main_frame().add (bar);
return name;
}
diff --git a/src/usertool.cc b/src/usertool.cc
index 42fa705..f5cd52c 100644
--- a/src/usertool.cc
+++ b/src/usertool.cc
@@ -122,7 +122,7 @@ user_tool_bar::update_ui ()
{
int flags;
if (u_item[i].ti_init == Kend_macro)
- flags = (app.kbdq.save_p ()
+ flags = (active_app_frame().kbdq.save_p ()
? MF_ENABLED | MF_UNCHECKED
: MF_GRAYED | MF_UNCHECKED);
else
@@ -263,7 +263,7 @@ user_tool_bar::create (lisp bitmap, lisp items)
for (p = items, i = 0; consp (p); p = xcdr (p), i++)
has_tooltips |= set_item (u_item[i], xcar (p));
- if (!tool_bar::create (app.toplev,
+ if (!tool_bar::create (active_app_frame().toplev,
(WS_CHILD | WS_CLIPSIBLINGS | CCS_NOMOVEY
| CCS_NORESIZE | CCS_NOPARENTALIGN | CCS_NODIVIDER
| (has_tooltips ? TBSTYLE_TOOLTIPS : 0)),
@@ -314,10 +314,10 @@ user_tool_bar::create (lisp bitmap, lisp items)
lisp
Fcreate_tool_bar (lisp name, lisp bitmap, lisp items)
{
- if (g_frame.find (name))
+ if (active_main_frame().find (name))
FEsimple_error (Etoolbar_exist, name);
- user_tool_bar *bar = new user_tool_bar (g_frame, name);
+ user_tool_bar *bar = new user_tool_bar (active_main_frame(), name);
try
{
@@ -329,7 +329,7 @@ Fcreate_tool_bar (lisp name, lisp bitmap, lisp items)
throw;
}
- g_frame.add (bar);
+ active_main_frame().add (bar);
return name;
}
@@ -346,20 +346,20 @@ Fshow_tool_bar (lisp name, lisp ledge, lisp lx, lisp ly, lisp lw)
else if (ledge == Kbottom)
edge = dock_frame::EDGE_BOTTOM;
- dock_bar *bar = g_frame.find (name);
+ dock_bar *bar = active_main_frame().find (name);
if (!bar)
FEsimple_error (Eundefined_toolbar, name);
int w = lw && lw != Qnil ? fixnum_value (lw) : -1;
if (!lx || !ly || lx == Qnil || ly == Qnil)
- g_frame.show (bar, edge, 0, w);
+ active_main_frame().show (bar, edge, 0, w);
else
{
POINT p;
p.x = fixnum_value (lx);
p.y = fixnum_value (ly);
- g_frame.show (bar, edge, &p, w);
+ active_main_frame().show (bar, edge, &p, w);
}
return Qt;
@@ -390,7 +390,7 @@ edge_sym (int edge)
lisp
Fhide_tool_bar (lisp name)
{
- dock_bar *bar = g_frame.find (name);
+ dock_bar *bar = active_main_frame().find (name);
if (!bar)
FEsimple_error (Eundefined_toolbar, name);
@@ -398,7 +398,7 @@ Fhide_tool_bar (lisp name)
int edge = bar->edge ();
int w = bar->horz_width ();
- g_frame.hide (bar);
+ active_main_frame().hide (bar);
multiple_value::value (1) = make_fixnum (r.left);
multiple_value::value (2) = make_fixnum (r.top);
@@ -410,23 +410,23 @@ Fhide_tool_bar (lisp name)
lisp
Fdelete_tool_bar (lisp name)
{
- dock_bar *bar = g_frame.find (name);
+ dock_bar *bar = active_main_frame().find (name);
if (!bar)
FEsimple_error (Eundefined_toolbar, name);
- g_frame.remove (bar);
+ active_main_frame().remove (bar);
return Qt;
}
lisp
Ftool_bar_exist_p (lisp name)
{
- return boole (g_frame.find (name));
+ return boole (active_main_frame().find (name));
}
lisp
Ftool_bar_info (lisp name)
{
- dock_bar *bar = g_frame.find (name);
+ dock_bar *bar = active_main_frame().find (name);
if (!bar)
FEsimple_error (Eundefined_toolbar, name);
@@ -442,18 +442,18 @@ Ftool_bar_info (lisp name)
lisp
Flist_tool_bars ()
{
- return g_frame.list_bars ();
+ return active_main_frame().list_bars ();
}
lisp
Ffocus_tool_bar ()
{
- return boole (g_frame.focus_next (0));
+ return boole (active_main_frame().focus_next (0));
}
lisp
Frefresh_tool_bars ()
{
- g_frame.refresh ();
+ active_main_frame().refresh ();
return Qt;
}
diff --git a/src/utils.cc b/src/utils.cc
index 48146d4..28ef6e7 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -486,7 +486,7 @@ frameDC::frameDC (HWND hwnd, int flags)
f_hdc = GetDCEx (f_hwnd, 0,
flags | DCX_CACHE | (LockWindowUpdate (f_hwnd)
? DCX_LOCKWINDOWUPDATE : 0));
- HBITMAP hbm = LoadBitmap (app.hinst, MAKEINTRESOURCE (IDB_CHECK));
+ HBITMAP hbm = LoadBitmap (active_app_frame().hinst, MAKEINTRESOURCE (IDB_CHECK));
f_obr = SelectObject (f_hdc, CreatePatternBrush (hbm));
DeleteObject (hbm);
}
diff --git a/src/utimer.cc b/src/utimer.cc
index 97db8d2..6582212 100644
--- a/src/utimer.cc
+++ b/src/utimer.cc
@@ -164,12 +164,12 @@ Fstart_timer (lisp linterval, lisp lfn, lisp lone_shot_p)
double interval (coerce_to_double_float (linterval) * 1000);
if (interval < 0 || interval > LONG_MAX)
FErange_error (linterval);
- app.user_timer.add (u_long (interval), lfn, lone_shot_p && lone_shot_p != Qnil);
+ active_app_frame().user_timer.add (u_long (interval), lfn, lone_shot_p && lone_shot_p != Qnil);
return Qt;
}
lisp
Fstop_timer (lisp fn)
{
- return boole (app.user_timer.remove (fn));
+ return boole (active_app_frame().user_timer.remove (fn));
}
diff --git a/src/vfs.cc b/src/vfs.cc
index 5876703..aeb469e 100644
--- a/src/vfs.cc
+++ b/src/vfs.cc
@@ -91,7 +91,7 @@ NetPassDlg::netpass_dlgproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
int
NetPassDlg::do_modal ()
{
- return DialogBoxParam (app.hinst, MAKEINTRESOURCE (IDD_NETPASSWD),
+ return DialogBoxParam (active_app_frame().hinst, MAKEINTRESOURCE (IDD_NETPASSWD),
get_active_window (), netpass_dlgproc, LPARAM (this)) == IDOK;
}
diff --git a/src/wheel.cc b/src/wheel.cc
index 2aa2cc8..fe1d94f 100644
--- a/src/wheel.cc
+++ b/src/wheel.cc
@@ -113,7 +113,7 @@ auto_scroll_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
PAINTSTRUCT ps;
HDC hdc = BeginPaint (hwnd, &ps);
HDC mem = CreateCompatibleDC (hdc);
- HGDIOBJ obm = SelectObject (mem, LoadBitmap (app.hinst, MAKEINTRESOURCE (IDB_WHEEL)));
+ HGDIOBJ obm = SelectObject (mem, LoadBitmap (active_app_frame().hinst, MAKEINTRESOURCE (IDB_WHEEL)));
BitBlt (hdc, 0, 0, BMWIDTH, BMHEIGHT, mem, 0, 0, SRCCOPY);
DeleteObject (SelectObject (mem, obm));
DeleteDC (mem);
@@ -133,7 +133,7 @@ register_wndclass ()
wc.lpfnWndProc = auto_scroll_wndproc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
- wc.hInstance = app.hinst;
+ wc.hInstance = active_app_frame().hinst;
wc.hIcon = 0;
wc.hCursor = 0;
wc.hbrBackground = 0;
@@ -202,7 +202,7 @@ begin_auto_scroll (HWND hwnd_parent, const POINT &point,
HWND hwnd_scroll = CreateWindow (auto_scroll_class_name, "", WS_POPUP,
0, 0, 0, 0, hwnd_parent,
- 0, app.hinst, 0);
+ 0, active_app_frame().hinst, 0);
if (!hwnd_scroll)
return 0;
@@ -219,9 +219,9 @@ begin_auto_scroll (HWND hwnd_parent, const POINT &point,
param.callback = callback;
param.arg = arg;
- param.hcur[STATE_CENTER] = LoadCursor (app.hinst, MAKEINTRESOURCE (IDC_WHEEL_UD));
- param.hcur[STATE_UP] = LoadCursor (app.hinst, MAKEINTRESOURCE (IDC_WHEEL_U));
- param.hcur[STATE_DOWN] = LoadCursor (app.hinst, MAKEINTRESOURCE (IDC_WHEEL_D));
+ param.hcur[STATE_CENTER] = LoadCursor (active_app_frame().hinst, MAKEINTRESOURCE (IDC_WHEEL_UD));
+ param.hcur[STATE_UP] = LoadCursor (active_app_frame().hinst, MAKEINTRESOURCE (IDC_WHEEL_U));
+ param.hcur[STATE_DOWN] = LoadCursor (active_app_frame().hinst, MAKEINTRESOURCE (IDC_WHEEL_D));
param.o = point;
SetWindowPos (hwnd_scroll, 0, param.o.x - HOTSPOTX, param.o.y - HOTSPOTY,
diff --git a/src/winhelp.cc b/src/winhelp.cc
index 074518b..0af28de 100644
--- a/src/winhelp.cc
+++ b/src/winhelp.cc
@@ -9,12 +9,12 @@ Frun_winhelp (lisp file, lisp topic)
char path[PATH_MAX + 1];
pathname2cstr (file, path);
if (!topic || topic == Qnil)
- return boole (WinHelp (app.toplev, path, HELP_CONTENTS, 0));
+ return boole (WinHelp (active_app_frame().toplev, path, HELP_CONTENTS, 0));
check_string (topic);
char *b = (char *)alloca (xstring_length (topic) * 2 + 1);
w2s (b, topic);
- return boole (WinHelp (app.toplev, path, HELP_PARTIALKEY, DWORD (b)));
+ return boole (WinHelp (active_app_frame().toplev, path, HELP_PARTIALKEY, DWORD (b)));
}
lisp
@@ -22,7 +22,7 @@ Fkill_winhelp (lisp file)
{
char path[PATH_MAX + 1];
pathname2cstr (file, path);
- return boole (WinHelp (app.toplev, path, HELP_QUIT, 0));
+ return boole (WinHelp (active_app_frame().toplev, path, HELP_QUIT, 0));
}
struct iheader
@@ -352,7 +352,7 @@ iset::lookup ()
{
return (is_files
&& (find_index () == 1
- || DialogBoxParam (app.hinst, MAKEINTRESOURCE (IDD_HELPDLG),
+ || DialogBoxParam (active_app_frame().hinst, MAKEINTRESOURCE (IDD_HELPDLG),
get_active_window (), select_dialog_proc,
LPARAM (this)) == IDOK));
}
--
1.7.0.4
@southly
Copy link
Author

southly commented May 21, 2010

http://bitbucket.org/mumurik/xyzzy/ を追いかける。

2d9d9fef2916d7ac3126da98d4328b7b63a1d12e (xyzzy.src : fix for VC2005.)

からの差分。
mixiでやっていたとは知らなかった。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment