mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Wiki: Support renamed folders (fix)
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.guis.bnds; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
|
||||
public class Xog_bnd_box {
|
||||
private final Ordered_hash key_hash = Ordered_hash_.New();
|
||||
private final Hash_adp cmd_hash = Hash_adp_.New();
|
||||
public Xog_bnd_box(int tid, String key) {
|
||||
this.tid = tid;
|
||||
this.key = key;
|
||||
}
|
||||
public int Tid() {return tid;} private final int tid;
|
||||
public String Key() {return key;} private final String key;
|
||||
public int Len() {return key_hash.Count();}
|
||||
public Xog_bnd_itm Get_at(int i) {return (Xog_bnd_itm)key_hash.Get_at(i);}
|
||||
public void Add(Xog_bnd_itm itm) {
|
||||
key_hash.Add_if_dupe_use_nth(itm.Key(), itm); // Add_if_dupe_use_nth, else Xou_user_tst.Run fails; DATE:2014-05-15
|
||||
|
||||
// add by cmd; needed b/c gfui.ipt_mgr hashes by cmd ("sandbox"), not key ("sandbox-1"); DATE:2016-12-25
|
||||
List_adp list = (List_adp)cmd_hash.Get_by(itm.Cmd());
|
||||
if (list == null) {
|
||||
list = List_adp_.New();
|
||||
cmd_hash.Add(itm.Cmd(), list);
|
||||
}
|
||||
list.Add(itm);
|
||||
}
|
||||
public List_adp Get_list_by_cmd(String cmd) {return (List_adp)cmd_hash.Get_by(cmd);}
|
||||
public void Del(String key) {
|
||||
// delete from key_hash
|
||||
Xog_bnd_itm itm = (Xog_bnd_itm)key_hash.Get_by(key);
|
||||
key_hash.Del(key);
|
||||
|
||||
// delete from cmd_hash
|
||||
List_adp list = (List_adp)cmd_hash.Get_by(itm.Cmd());
|
||||
if (list != null) list.Del(itm);
|
||||
}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.guis.bnds; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
|
||||
import gplx.gfui.*; import gplx.gfui.ipts.*; import gplx.gfui.controls.elems.*;
|
||||
import gplx.xowa.guis.views.*; import gplx.xowa.guis.cmds.*;
|
||||
public class Xog_bnd_box_ {
|
||||
public static final String Key_browser = "browser", Key_browser_url = "browser.url", Key_browser_search = "browser.search", Key_browser_html = "browser.html", Key_browser_find = "browser.find", Key_browser_prog = "browser.prog", Key_browser_info = "browser.info";
|
||||
public static final String Gui_browser = "Window", Gui_browser_url = "Url bar", Gui_browser_search = "Search box", Gui_browser_html = "HTML browser", Gui_browser_find = "Find box", Gui_browser_prog = "Status bar", Gui_browser_info = "System Messages box";
|
||||
public static final int Tid__max = 7, Tid_browser = 0, Tid_browser_url = 1, Tid_browser_search = 2, Tid_browser_html = 3, Tid_browser_find = 4, Tid_browser_prog = 5, Tid_browser_info = 6;
|
||||
public static final int Ary_len = Tid__max;
|
||||
public static Xog_bnd_box[] Ary() {
|
||||
if (ary != null) return ary;
|
||||
ary = new Xog_bnd_box[Tid__max];
|
||||
ary_init(ary, Tid_browser , Key_browser);
|
||||
ary_init(ary, Tid_browser_url , Key_browser_url);
|
||||
ary_init(ary, Tid_browser_search , Key_browser_search);
|
||||
ary_init(ary, Tid_browser_html , Key_browser_html);
|
||||
ary_init(ary, Tid_browser_find , Key_browser_find);
|
||||
ary_init(ary, Tid_browser_prog , Key_browser_prog);
|
||||
ary_init(ary, Tid_browser_info , Key_browser_info);
|
||||
return ary;
|
||||
} private static Xog_bnd_box[] ary;
|
||||
private static void ary_init(Xog_bnd_box[] ary, int tid, String key) {ary[tid] = new Xog_bnd_box(tid, key);}
|
||||
public static String To_gui_str(String key) {
|
||||
int tid = Xto_sys_int(key);
|
||||
return Xto_gui_str(tid);
|
||||
}
|
||||
public static String To_key_str(String gui) {
|
||||
int tid = Xby_gui_str(gui);
|
||||
return Xto_sys_str(tid);
|
||||
}
|
||||
public static int[] Xto_sys_int_ary(String s) {
|
||||
String[] ary = String_.Split(s, "|");
|
||||
int len = ary.length;
|
||||
int[] rv = new int[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
rv[i] = Xto_sys_int(ary[i]);
|
||||
return rv;
|
||||
}
|
||||
public static int Xto_sys_int(String s) {
|
||||
if (String_.Eq(s, Key_browser)) return Tid_browser;
|
||||
else if (String_.Eq(s, Key_browser_url)) return Tid_browser_url;
|
||||
else if (String_.Eq(s, Key_browser_search)) return Tid_browser_search;
|
||||
else if (String_.Eq(s, Key_browser_html)) return Tid_browser_html;
|
||||
else if (String_.Eq(s, Key_browser_find)) return Tid_browser_find;
|
||||
else if (String_.Eq(s, Key_browser_prog)) return Tid_browser_prog;
|
||||
else if (String_.Eq(s, Key_browser_info)) return Tid_browser_info;
|
||||
else throw Err_.new_unhandled(s);
|
||||
}
|
||||
public static String Xto_sys_str(int v) {
|
||||
switch (v) {
|
||||
case Tid_browser: return Key_browser;
|
||||
case Tid_browser_url: return Key_browser_url;
|
||||
case Tid_browser_search: return Key_browser_search;
|
||||
case Tid_browser_html: return Key_browser_html;
|
||||
case Tid_browser_find: return Key_browser_find;
|
||||
case Tid_browser_prog: return Key_browser_prog;
|
||||
case Tid_browser_info: return Key_browser_info;
|
||||
default: throw Err_.new_unhandled(v);
|
||||
}
|
||||
}
|
||||
public static String Xto_gui_str(int v) {
|
||||
switch (v) {
|
||||
case Tid_browser: return Gui_browser;
|
||||
case Tid_browser_url: return Gui_browser_url;
|
||||
case Tid_browser_search: return Gui_browser_search;
|
||||
case Tid_browser_html: return Gui_browser_html;
|
||||
case Tid_browser_find: return Gui_browser_find;
|
||||
case Tid_browser_prog: return Gui_browser_prog;
|
||||
case Tid_browser_info: return Gui_browser_info;
|
||||
default: throw Err_.new_unhandled(v);
|
||||
}
|
||||
}
|
||||
public static int Xby_gui_str(String s) {
|
||||
if (String_.Eq(s, Gui_browser)) return Tid_browser;
|
||||
else if (String_.Eq(s, Gui_browser_url)) return Tid_browser_url;
|
||||
else if (String_.Eq(s, Gui_browser_search)) return Tid_browser_search;
|
||||
else if (String_.Eq(s, Gui_browser_html)) return Tid_browser_html;
|
||||
else if (String_.Eq(s, Gui_browser_find)) return Tid_browser_find;
|
||||
else if (String_.Eq(s, Gui_browser_prog)) return Tid_browser_prog;
|
||||
else if (String_.Eq(s, Gui_browser_info)) return Tid_browser_info;
|
||||
else throw Err_.new_unhandled(s);
|
||||
}
|
||||
public static void Set_bnd_for_grp(byte mode, Xog_win_itm win, Xog_cmd_mgr_invk invk_mgr, Xog_bnd_box box, Xog_bnd_itm itm, IptArg ipt) {
|
||||
GfuiElem box_elem = null;
|
||||
String grp_key = box.Key();
|
||||
if (String_.Eq(grp_key, Xog_bnd_box_.Key_browser_html)) {Set_bnd_for_tab(mode, win.Tab_mgr(), invk_mgr, box, itm, ipt); return;}
|
||||
else if (String_.Eq(grp_key, Xog_bnd_box_.Key_browser)) box_elem = win.Win_box();
|
||||
else if (String_.Eq(grp_key, Xog_bnd_box_.Key_browser_url)) box_elem = win.Url_box();
|
||||
else if (String_.Eq(grp_key, Xog_bnd_box_.Key_browser_search)) box_elem = win.Search_box();
|
||||
else if (String_.Eq(grp_key, Xog_bnd_box_.Key_browser_find)) box_elem = win.Find_box();
|
||||
else if (String_.Eq(grp_key, Xog_bnd_box_.Key_browser_prog)) box_elem = win.Prog_box();
|
||||
else if (String_.Eq(grp_key, Xog_bnd_box_.Key_browser_info)) box_elem = win.Info_box();
|
||||
else throw Err_.new_wo_type("unknown box", "grp", grp_key);
|
||||
Set_bnd_for_elem(mode, box, box_elem, invk_mgr, itm, ipt);
|
||||
}
|
||||
public static void Set_bnd_for_elem(byte mode, Xog_bnd_box box, GfuiElem box_elem, Xog_cmd_mgr_invk invk_mgr, Xog_bnd_itm itm, IptArg ipt) {
|
||||
switch (mode) {
|
||||
case Set_add:
|
||||
if (!IptArg_.Is_null_or_none(itm.Ipt()))
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, box_elem, invk_mgr, itm.Cmd(), itm.Ipt());
|
||||
break;
|
||||
case Set_del_key:
|
||||
box_elem.IptBnds().Del_by_key(itm.Cmd()); // NOTE: delete by cmd, since GfuiIpts use cmd for key
|
||||
break;
|
||||
case Set_del_ipt:
|
||||
box_elem.IptBnds().Del_by_ipt(ipt);
|
||||
break;
|
||||
default: throw Err_.new_unhandled(mode);
|
||||
}
|
||||
}
|
||||
private static void Set_bnd_for_tab(byte mode, Xog_tab_mgr tab_mgr, Xog_cmd_mgr_invk invk_mgr, Xog_bnd_box box, Xog_bnd_itm itm, IptArg ipt) {
|
||||
int len = tab_mgr.Tabs_len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xog_tab_itm tab_itm = tab_mgr.Tabs_get_at(i);
|
||||
Set_bnd_for_elem(mode, box, tab_itm.Html_box(), invk_mgr, itm, ipt);
|
||||
}
|
||||
}
|
||||
public static final byte Set_add = 0, Set_del_key = 1, Set_del_ipt = 2;
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.guis.bnds; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
|
||||
import gplx.gfui.*; import gplx.gfui.ipts.*;
|
||||
public class Xog_bnd_itm {
|
||||
public Xog_bnd_itm(String key, boolean sys, String cmd, int box, IptArg ipt) {
|
||||
this.key = key; this.sys = sys; this.cmd = cmd; this.box = box; this.ipt = ipt;
|
||||
uid = ++Uid_next;
|
||||
}
|
||||
public String Key() {return key;} private String key;
|
||||
public int Uid() {return uid;} private int uid;
|
||||
public boolean Sys() {return sys;} private boolean sys;
|
||||
public String Cmd() {return cmd;} public void Cmd_(String v) {cmd = v;} private String cmd;
|
||||
public int Box() {return box;} private int box;
|
||||
public IptArg Ipt() {return ipt;} public void Ipt_to_none() {ipt = IptKey_.None;} private IptArg ipt;
|
||||
public void Init_by_set(int box, IptArg ipt) {this.box = box; this.ipt = ipt;}
|
||||
private static int Uid_next = 0;
|
||||
}
|
||||
@@ -1,383 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.guis.bnds; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
|
||||
import gplx.gfui.*; import gplx.gfui.ipts.*; import gplx.gfui.controls.elems.*;
|
||||
import gplx.xowa.guis.views.*; import gplx.xowa.guis.cmds.*; import gplx.xowa.guis.menus.dom.*;
|
||||
public class Xog_bnd_mgr implements Gfo_invk {
|
||||
private Xoae_app app;
|
||||
private Xog_win_itm win; private Xog_cmd_mgr_invk invk_mgr;
|
||||
private Xog_bnd_box[] boxs = Xog_bnd_box_.Ary();
|
||||
private List_adp startup_itms = List_adp_.New();
|
||||
private Ordered_hash regy = Ordered_hash_.New();
|
||||
public Xog_bnd_mgr(Xog_win_itm win) {this.win = win; invk_mgr = win.Gui_mgr().Cmd_mgr().Invk_mgr();}
|
||||
public int Len() {return regy.Count();}
|
||||
public Xog_bnd_itm Get_at(int i) {return (Xog_bnd_itm)regy.Get_at(i);}
|
||||
public Xog_bnd_itm Get_or_null(String v) {return (Xog_bnd_itm)regy.Get_by(v);}
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
this.app = app;
|
||||
Add_system_bnds();
|
||||
Add_custom_bnds(); // NOTE: should go after Add_system_bnds in case user overrides any;
|
||||
Bind_all();
|
||||
|
||||
app.Cfg().Sub_many_app(this, Run__show_remap_win);
|
||||
app.Cfg().Bind_many_app(this
|
||||
, "xowa.gui.shortcuts.xowa.app.exit-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.go_bwd-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.go_fwd-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.cfg.main-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.cfg.menus-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.wiki.main_page-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.wiki.sandbox-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.wiki.sandbox-2"
|
||||
, "xowa.gui.shortcuts.xowa.nav.wiki.random-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.help.help-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.help.about-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.help.change_log-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.help.diagnostics-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.help.xowa_update-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.help.xowa_main-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.help.xowa_blog-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.setup.download_central-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.setup.import_from_list-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.setup.import_from_script-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.setup.maintenance-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.setup.download-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.system_data.log_session-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.system_data.cfg_app-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.system_data.cfg_lang-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.system_data.usr_history-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.font.increase-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.font.decrease-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.font.reset-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.page.view.mode_read-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.page.view.mode_edit-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.page.view.mode_html-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.page.view.mode_html-2"
|
||||
, "xowa.gui.shortcuts.xowa.gui.page.view.refresh-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.page.view.reload-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.page.view.save_as-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.page.view.print-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.page.edit.save-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.page.edit.save_draft-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.page.edit.focus_edit_box-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.page.edit.preview-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.page.edit.dbg_tmpl-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.page.edit.dbg_tmpl-2"
|
||||
, "xowa.gui.shortcuts.xowa.gui.page.edit.dbg_html-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.page.edit.exec-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.page.selection.select_all-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.page.selection.copy-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.page.selection.save_file_as-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.url.focus-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.url.focus-2"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.url.exec-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.url.exec_by_paste-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.url.exec_by_paste-2"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.url.exec_new_tab_by_paste-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.url.restore-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.search.focus-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.search.exec-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.html.focus-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.html.focus-2"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.html.focus-3"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.html.focus-4"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.html.selection_focus_toggle-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.find.show-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.find.show_by_paste-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.find.hide-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.find.exec-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.find.find_fwd-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.find.find_bwd-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.find.case_toggle-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.find.wrap_toggle-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.prog.focus-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.prog_log.show-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.prog_log.show-2"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.info.focus-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.info.clear-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.new_dflt__at_dflt__focus_y-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.new_link__at_dflt__focus_y-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.new_link__at_dflt__focus_n-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.new_href__at_dflt__focus_y-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.select_bwd-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.select_bwd-2"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.select_fwd-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.select_fwd-2"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.select_by_idx_1-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.select_by_idx_2-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.select_by_idx_3-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.select_by_idx_4-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.select_by_idx_5-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.select_by_idx_6-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.select_by_idx_7-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.select_by_idx_8-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.select_by_idx_9-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.move_bwd-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.move_fwd-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.close_cur-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.close_others-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.close_to_bgn-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.close_to_end-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.close_undo-1"
|
||||
, "xowa.gui.shortcuts.xowa.gui.browser.tabs.pin_toggle-1"
|
||||
, "xowa.gui.shortcuts.xowa.html.tidy.toggle-1"
|
||||
, "xowa.gui.shortcuts.xowa.net.enabled_n_-1"
|
||||
, "xowa.gui.shortcuts.xowa.net.enabled_y_-1"
|
||||
, "xowa.gui.shortcuts.xowa.net.enabled_x_-1"
|
||||
, "xowa.gui.shortcuts.xowa.usr.bookmarks.add-1"
|
||||
, "xowa.gui.shortcuts.xowa.usr.bookmarks.show-1"
|
||||
, "xowa.gui.shortcuts.xowa.usr.history.goto_recent-1"
|
||||
, "xowa.gui.shortcuts.xowa.usr.history.show-1"
|
||||
);
|
||||
}
|
||||
public Xog_bnd_itm Set(Xog_bnd_itm itm, int new_box, IptArg new_ipt) {
|
||||
if (win.Win_box() == null) { // kit not built yet; occurs when restoring bindings through cfg file; DATE:2014-05-16
|
||||
Xog_bnd_itm new_itm = new Xog_bnd_itm(itm.Key(), false, "", new_box, new_ipt);
|
||||
startup_itms.Add(new_itm);
|
||||
return new_itm;
|
||||
}
|
||||
Del(itm, new_ipt);
|
||||
itm.Init_by_set(new_box, new_ipt);
|
||||
Add(itm);
|
||||
return itm;
|
||||
}
|
||||
public void Del(Xog_bnd_itm new_bnd, IptArg new_ipt) {
|
||||
boolean new_ipt_exists = !IptArg_.Is_null_or_none(new_ipt);
|
||||
List_adp deleted = List_adp_.New();
|
||||
|
||||
// loop over each box
|
||||
for (int i = 0; i < Xog_bnd_box_.Ary_len; i++) {
|
||||
Xog_bnd_box old_box = boxs[i];
|
||||
int old_itms_len = old_box.Len();
|
||||
|
||||
// loop over each bnd
|
||||
for (int j = 0; j < old_itms_len; j++) {
|
||||
Xog_bnd_itm old_bnd = old_box.Get_at(j);
|
||||
|
||||
// if keys match, delete old_bnd
|
||||
if ( String_.Eq(old_bnd.Key(), new_bnd.Key())) {
|
||||
Xog_bnd_box_.Set_bnd_for_grp(Xog_bnd_box_.Set_del_key, win, invk_mgr, old_box, old_bnd, new_bnd.Ipt());
|
||||
deleted.Add(new_bnd);
|
||||
}
|
||||
// if ipts match, delete old_bnd
|
||||
else if ( new_ipt_exists
|
||||
&& old_bnd.Box() == new_bnd.Box()
|
||||
&& String_.Eq(old_bnd.Ipt().Key(), new_ipt.Key())) {
|
||||
Xog_bnd_box_.Set_bnd_for_grp(Xog_bnd_box_.Set_del_ipt, win, invk_mgr, old_box, old_bnd, old_bnd.Ipt());
|
||||
old_bnd.Ipt_to_none();
|
||||
}
|
||||
}
|
||||
|
||||
// remove old bnd from box
|
||||
int deleted_len = deleted.Count();
|
||||
for (int j = 0; j < deleted_len; j++) {
|
||||
// delete from box
|
||||
Xog_bnd_itm deleted_itm = (Xog_bnd_itm)deleted.Get_at(j);
|
||||
old_box.Del(deleted_itm.Key());
|
||||
|
||||
// add back other items with same cmd but different key; needed b/c gfui.ipt_mgr hashes by cmd ("sandbox"), not key ("sandbox-1"); DATE:2016-12-25
|
||||
List_adp list = old_box.Get_list_by_cmd(deleted_itm.Cmd());
|
||||
if (list != null) {
|
||||
int len = list.Len();
|
||||
for (int k = 0; k < len; k++) {
|
||||
Xog_bnd_itm restore_itm = (Xog_bnd_itm)list.Get_at(k);
|
||||
Xog_bnd_box_.Set_bnd_for_grp(Xog_bnd_box_.Set_add, win, invk_mgr, old_box, restore_itm, restore_itm.Ipt());
|
||||
}
|
||||
}
|
||||
}
|
||||
deleted.Clear();
|
||||
}
|
||||
}
|
||||
private void Add(Xog_bnd_itm itm) {
|
||||
Xog_bnd_box box = boxs[itm.Box()];
|
||||
Xog_bnd_box_.Set_bnd_for_grp(Xog_bnd_box_.Set_add, win, invk_mgr, box, itm, itm.Ipt());
|
||||
box.Add(itm);
|
||||
}
|
||||
public void Bind(int tid, GfuiElem box_elem) {
|
||||
Xog_bnd_box box = boxs[tid];
|
||||
int len = box.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xog_bnd_itm itm = box.Get_at(i);
|
||||
Xog_bnd_box_.Set_bnd_for_elem(Xog_bnd_box_.Set_add, box, box_elem, invk_mgr, itm, itm.Ipt());
|
||||
}
|
||||
}
|
||||
public void Init() {
|
||||
regy.Clear(); // clear regy, else 1 test will fail
|
||||
Init_itm(Xog_cmd_itm_.Key_app_exit , Xog_bnd_box_.Tid_browser , "mod.c+key.q");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_go_bwd , Xog_bnd_box_.Tid_browser , "mod.a+key.left");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_go_fwd , Xog_bnd_box_.Tid_browser , "mod.a+key.right");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_cfg_main , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_cfg_menu , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_wiki_main_page , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_wiki_random , Xog_bnd_box_.Tid_browser , "mod.cs+key.r");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_wiki_sandbox , Xog_bnd_box_.Tid_browser , "mod.cs+key.g,mod.cs+key.s", "mod.c+key.f1");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_help_help , Xog_bnd_box_.Tid_browser , "key.f1");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_help_change_log , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_help_diagnostics , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_help_about , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_help_xowa_main , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_help_xowa_blog , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_help_xowa_update , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_setup_download_central , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_setup_import_from_list , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_setup_import_from_script , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_setup_maintenance , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_setup_download , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_system_data_log_session , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_system_data_cfg_app , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_system_data_cfg_lang , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_system_data_usr_history , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_font_increase , Xog_bnd_box_.Tid_browser , "mod.c+key.equal");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_font_decrease , Xog_bnd_box_.Tid_browser , "mod.c+key.minus");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_font_reset , Xog_bnd_box_.Tid_browser , "mod.c+key.d0");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_page_view_mode_read , Xog_bnd_box_.Tid_browser , "mod.c+key.m,mod.c+key.r");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_page_view_mode_edit , Xog_bnd_box_.Tid_browser , "mod.c+key.m,mod.c+key.e");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_page_view_mode_html , Xog_bnd_box_.Tid_browser , "mod.c+key.m,mod.c+key.h", "mod.c+key.u");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_page_view_reload , Xog_bnd_box_.Tid_browser , "key.f5");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_page_view_refresh , Xog_bnd_box_.Tid_browser , "mod.s+key.f5");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_page_view_save_as , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_page_view_print , Xog_bnd_box_.Tid_browser , "mod.c+key.p");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_page_selection_select_all , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_page_selection_copy , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_page_selection_save_file_as , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_edit_save , Xog_bnd_box_.Tid_browser , "mod.as+key.s");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_edit_save_draft , Xog_bnd_box_.Tid_browser , "mod.c+key.s");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_edit_focus_edit_box , Xog_bnd_box_.Tid_browser , "mod.as+key.comma");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_edit_preview , Xog_bnd_box_.Tid_browser , "mod.as+key.p");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_edit_dbg_tmpl , Xog_bnd_box_.Tid_browser , "mod.c+key.e,mod.c+key.e", "mod.as+key.d,mod.as+key.d");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_edit_dbg_html , Xog_bnd_box_.Tid_browser , "mod.c+key.e,mod.c+key.h");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_edit_exec , Xog_bnd_box_.Tid_browser , "mod.c+key.e,mod.c+key.g");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_url_focus , Xog_bnd_box_.Tid_browser , "mod.a+key.d", "mod.c+key.l");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_url_exec , Xog_bnd_box_.Tid_browser_url , "key.enter");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_url_exec_new_tab_by_paste , Xog_bnd_box_.Tid_browser_url , "mod.c+key.enter");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_url_exec_by_paste , Xog_bnd_box_.Tid_browser_url , "mouse.middle", "mod.a+key.enter");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_url_restore , Xog_bnd_box_.Tid_browser_url , "mod.c+key.u");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_search_focus , Xog_bnd_box_.Tid_browser , "mod.ca+key.s");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_search_exec , Xog_bnd_box_.Tid_browser_search , "key.enter");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_new_dflt__at_dflt__focus_y , Xog_bnd_box_.Tid_browser , "mod.c+key.t");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_new_link__at_dflt__focus_n , Xog_bnd_box_.Tid_browser_html , "mouse.middle");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_new_link__at_dflt__focus_y , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_new_href__at_dflt__focus_y , Xog_bnd_box_.Tid_browser , "mod.c+key.g,mod.c+key.f");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_close_cur , Xog_bnd_box_.Tid_browser , "mod.c+key.w");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_close_others , Xog_bnd_box_.Tid_browser , "mod.cs+key.w,mod.cs+key.w");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_close_to_bgn , Xog_bnd_box_.Tid_browser , "mod.cs+key.w,mod.cs+key.left");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_close_to_end , Xog_bnd_box_.Tid_browser , "mod.cs+key.w,mod.cs+key.right");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_close_undo , Xog_bnd_box_.Tid_browser , "mod.cs+key.t");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_select_fwd , Xog_bnd_box_.Tid_browser , "mod.c+key.tab", "mod.c+key.pageDown");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_select_bwd , Xog_bnd_box_.Tid_browser , "mod.cs+key.tab", "mod.c+key.pageUp");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_select_by_idx_1 , Xog_bnd_box_.Tid_browser , "mod.c+key.d1");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_select_by_idx_2 , Xog_bnd_box_.Tid_browser , "mod.c+key.d2");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_select_by_idx_3 , Xog_bnd_box_.Tid_browser , "mod.c+key.d3");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_select_by_idx_4 , Xog_bnd_box_.Tid_browser , "mod.c+key.d4");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_select_by_idx_5 , Xog_bnd_box_.Tid_browser , "mod.c+key.d5");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_select_by_idx_6 , Xog_bnd_box_.Tid_browser , "mod.c+key.d6");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_select_by_idx_7 , Xog_bnd_box_.Tid_browser , "mod.c+key.d7");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_select_by_idx_8 , Xog_bnd_box_.Tid_browser , "mod.c+key.d8");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_select_by_idx_9 , Xog_bnd_box_.Tid_browser , "mod.c+key.d9");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_move_bwd , Xog_bnd_box_.Tid_browser , "mod.a+key.pageUp");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_move_fwd , Xog_bnd_box_.Tid_browser , "mod.a+key.pageDown");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_pin_toggle , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_html_focus , 0, Xog_bnd_box_.Tid_browser_url , "key.escape");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_html_focus , 1, Xog_bnd_box_.Tid_browser_search , "key.escape");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_html_focus , 2, Xog_bnd_box_.Tid_browser_prog , "key.escape");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_html_focus , 3, Xog_bnd_box_.Tid_browser_info , "key.escape");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_html_selection_focus_toggle , Xog_bnd_box_.Tid_browser , "mod.c+key.g,mod.c+key.g");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_find_show , Xog_bnd_box_.Tid_browser , "mod.c+key.f");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_find_show_by_paste , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_find_hide , Xog_bnd_box_.Tid_browser_find , "key.escape");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_find_exec , Xog_bnd_box_.Tid_browser_find , "key.enter");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_find_find_fwd , Xog_bnd_box_.Tid_browser_find , "mod.a+key.n");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_find_find_bwd , Xog_bnd_box_.Tid_browser_find , "mod.a+key.p");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_find_case_toggle , Xog_bnd_box_.Tid_browser_find , "mod.a+key.c");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_find_wrap_toggle , Xog_bnd_box_.Tid_browser_find , "mod.a+key.w");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_prog_focus , Xog_bnd_box_.Tid_browser , "mod.ca+key.p");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_info_focus , Xog_bnd_box_.Tid_browser , "mod.ca+key.i");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_info_clear , Xog_bnd_box_.Tid_browser , "mod.ca+key.c");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_prog_log_show , Xog_bnd_box_.Tid_browser_prog , "mouse.middle", "mod.cs+key.p");
|
||||
Init_itm(Xog_cmd_itm_.Key_html_tidy_toggle , Xog_bnd_box_.Tid_browser , "key.f7");
|
||||
Init_itm(Xog_cmd_itm_.Key_usr_bookmarks_add , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_usr_bookmarks_show , Xog_bnd_box_.Tid_browser , "key.f3");
|
||||
Init_itm(Xog_cmd_itm_.Key_usr_history_goto_recent , Xog_bnd_box_.Tid_browser , "mod.cs+key.l");
|
||||
Init_itm(Xog_cmd_itm_.Key_usr_history_show , Xog_bnd_box_.Tid_browser , "mod.cs+key.h");
|
||||
Init_itm(Xog_cmd_itm_.Key_net_enabled_n_ , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_net_enabled_y_ , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_net_enabled_x_ , Xog_bnd_box_.Tid_browser , "");
|
||||
}
|
||||
private void Init_itm(String cmd, int box, String... ipts) {
|
||||
int ipts_len = ipts.length;
|
||||
for (int i = 0; i < ipts_len; i++) {
|
||||
String ipt_str = ipts[i];
|
||||
Init_itm(cmd, i, box, IptArg_.parse_or_none_(ipt_str));
|
||||
}
|
||||
}
|
||||
private void Init_itm(String cmd, int idx, int box, String ipt) {Init_itm(cmd, idx, box, IptArg_.parse_or_none_(ipt));}
|
||||
private void Init_itm(String cmd, int idx, int box, IptArg ipt) {
|
||||
String key = cmd + "-" + Int_.To_str(idx + List_adp_.Base1); // EX: xowa.widgets.url.focus-1 xowa.widgets.url.focus-2
|
||||
Xog_bnd_itm itm = new Xog_bnd_itm(key, Bool_.Y, cmd, box, ipt);
|
||||
boxs[box].Add(itm);
|
||||
regy.Add(itm.Key(), itm);
|
||||
}
|
||||
private void Add_system_bnds() {
|
||||
IptCfg null_cfg = IptCfg_.Null; IptEventType btn_event_type = IptEventType_.add_(IptEventType_.MouseUp, IptEventType_.KeyDown); IptArg[] btn_args = IptArg_.Ary(IptMouseBtn_.Left, IptKey_.Enter, IptKey_.Space);
|
||||
IptBnd_.ipt_to_(null_cfg , win.Go_bwd_btn() , invk_mgr, Xog_cmd_itm_.Key_nav_go_bwd , btn_event_type, btn_args);
|
||||
IptBnd_.ipt_to_(null_cfg , win.Go_fwd_btn() , invk_mgr, Xog_cmd_itm_.Key_nav_go_fwd , btn_event_type, btn_args);
|
||||
IptBnd_.ipt_to_(null_cfg , win.Url_exec_btn() , invk_mgr, Xog_cmd_itm_.Key_gui_browser_url_exec , btn_event_type, btn_args);
|
||||
IptBnd_.ipt_to_(null_cfg , win.Search_exec_btn() , invk_mgr, Xog_cmd_itm_.Key_gui_browser_search_exec , btn_event_type, btn_args);
|
||||
IptBnd_.ipt_to_(null_cfg , win.Find_close_btn() , invk_mgr, Xog_cmd_itm_.Key_gui_browser_find_hide , btn_event_type, btn_args);
|
||||
IptBnd_.ipt_to_(null_cfg , win.Find_fwd_btn() , invk_mgr, Xog_cmd_itm_.Key_gui_browser_find_find_fwd , btn_event_type, btn_args);
|
||||
IptBnd_.ipt_to_(null_cfg , win.Find_bwd_btn() , invk_mgr, Xog_cmd_itm_.Key_gui_browser_find_find_bwd , btn_event_type, btn_args);
|
||||
IptBnd_.ipt_to_(null_cfg , win.Find_box() , invk_mgr, Xog_cmd_itm_.Key_gui_browser_find_type , IptEventType_.KeyUp, IptKey_.printableKeys_(IptKey_.Ary(IptKey_.Back, IptKey_.Escape, IptKey_.Ctrl.Add(IptKey_.V)), IptKey_.Ary()));
|
||||
IptBnd_.ipt_to_(null_cfg , win.Url_box() , invk_mgr, Xog_cmd_itm_.Key_gui_browser_url_type , IptEventType_.KeyUp, IptKey_.printableKeys_(IptKey_.Ary(IptKey_.Back, IptKey_.Escape, IptKey_.Ctrl.Add(IptKey_.X), IptKey_.Ctrl.Add(IptKey_.V)), IptKey_.Ary()));
|
||||
}
|
||||
private void Add_custom_bnds() { // NOTE: custom bnds are stored in cfg; cfg executes before Init_by_kit when all windows elements are null; run cfg now, while Init_by_kit is called and elems are now created
|
||||
int len = startup_itms.Count();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xog_bnd_itm new_itm = (Xog_bnd_itm)startup_itms.Get_at(i);
|
||||
try {
|
||||
Xog_bnd_itm cur_itm = (Xog_bnd_itm)regy.Get_by(new_itm.Key());
|
||||
if (cur_itm == null) {win.Usr_dlg().Warn_many("", "", "binding no longer exists; key=~{0}", new_itm.Key());} // could happen when breaking backward compatibility
|
||||
cur_itm.Init_by_set(new_itm.Box(), new_itm.Ipt());
|
||||
} catch (Exception e) {win.Usr_dlg().Warn_many("", "", "failed to set custom binding; key=~{0} err=~{1}", new_itm.Key(), Err_.Message_gplx_full(e));}
|
||||
}
|
||||
startup_itms.Clear();
|
||||
}
|
||||
private void Bind_all() {
|
||||
this.Bind(Xog_bnd_box_.Tid_browser , win.Win_box());
|
||||
this.Bind(Xog_bnd_box_.Tid_browser_url , win.Url_box());
|
||||
this.Bind(Xog_bnd_box_.Tid_browser_find , win.Find_box());
|
||||
this.Bind(Xog_bnd_box_.Tid_browser_search , win.Search_box());
|
||||
this.Bind(Xog_bnd_box_.Tid_browser_prog , win.Prog_box());
|
||||
this.Bind(Xog_bnd_box_.Tid_browser_info , win.Info_box());
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (String_.Eq(k, Run__show_remap_win)) {
|
||||
Xog_bnd_win win = new Xog_bnd_win();
|
||||
String[] args = m.ReadStrAry("v", "\n");
|
||||
win.Show(app, app.Gui_mgr().Kit(), app.Gui_mgr().Browser_win().Win_box(), args[0], args[1], args[2]);
|
||||
}
|
||||
else {
|
||||
String[] flds = gplx.xowa.addons.apps.cfgs.enums.Xoitm_gui_binding.To_ary(m.ReadStr("v"));
|
||||
int box = Xog_bnd_box_.Xto_sys_int(flds[0]);
|
||||
String key = String_.Replace(k, "xowa.gui.shortcuts.", "");
|
||||
Xog_bnd_itm bnd = app.Gui_mgr().Bnd_mgr().Get_or_null(key);
|
||||
Set(bnd, box, IptArg_.parse(flds[1]));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
private static final String Run__show_remap_win = "xowa.gui.shortcuts.show_remap_win";
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.guis.bnds; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
|
||||
import gplx.gfui.ipts.*; import gplx.xowa.guis.cmds.*;
|
||||
interface Xog_bnd_wkr {
|
||||
void Bind_ipt_to_box(String box, String ipt);
|
||||
}
|
||||
class Xog_bnd_wkr__null implements Xog_bnd_wkr {
|
||||
public void Bind_ipt_to_box(String box, String ipt) {}
|
||||
}
|
||||
class Xog_bnd_temp implements Gfo_invk {
|
||||
private Xoae_app app;
|
||||
private final Ordered_hash regy = Ordered_hash_.New();
|
||||
private final Xog_bnd_wkr bnd_wkr = new Xog_bnd_wkr__null();
|
||||
private Xog_bnd_box[] boxs = Xog_bnd_box_.Ary();
|
||||
public void Init_by_app(Xoae_app app) {
|
||||
this.app = app;
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_new_dflt__at_dflt__focus_y , Xog_bnd_box_.Tid_browser , "mod.c+key.t");
|
||||
}
|
||||
private void Init_itm(String cmd, int box, String... ipts) {
|
||||
int ipts_len = ipts.length;
|
||||
for (int i = 0; i < ipts_len; i++) {
|
||||
String ipt_str = ipts[i];
|
||||
Init_itm(cmd, i, box, IptArg_.parse_or_none_(ipt_str));
|
||||
}
|
||||
}
|
||||
// private void Init_itm(String cmd, int idx, int box, String ipt) {Init_itm(cmd, idx, box, IptArg_.parse_or_none_(ipt));}
|
||||
private void Init_itm(String cmd, int idx, int box, IptArg ipt) {
|
||||
String key = cmd + "-" + Int_.To_str(idx + List_adp_.Base1); // EX: xowa.widgets.url.focus-1 xowa.widgets.url.focus-2
|
||||
Xog_bnd_itm itm = new Xog_bnd_itm(key, Bool_.Y, cmd, box, ipt);
|
||||
boxs[box].Add(itm);
|
||||
regy.Add(itm.Key(), itm);
|
||||
app.Cfg().Bind_many_app(this, cmd);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
Xog_bnd_cfg_itm itm = Xog_bnd_cfg_itm.Parse(m.ReadStr("v"));
|
||||
bnd_wkr.Bind_ipt_to_box(itm.Box(), itm.Ipt());
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class Xog_bnd_cfg_itm {
|
||||
public Xog_bnd_cfg_itm(String box, String ipt) {
|
||||
this.box = box;
|
||||
this.ipt = ipt;
|
||||
}
|
||||
public String Box() {return box;} private final String box;
|
||||
public String Ipt() {return ipt;} private final String ipt;
|
||||
public static Xog_bnd_cfg_itm Parse(String s) {
|
||||
String[] parts = String_.Split(s, "|");
|
||||
return new Xog_bnd_cfg_itm(parts[0], parts[1]);
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.guis.bnds; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
|
||||
import gplx.gfui.*; import gplx.gfui.draws.*; import gplx.gfui.ipts.*; import gplx.gfui.kits.core.*; import gplx.gfui.envs.*; import gplx.gfui.controls.windows.*; import gplx.gfui.controls.elems.*; import gplx.gfui.controls.standards.*;
|
||||
import gplx.xowa.guis.cbks.*;
|
||||
public class Xog_bnd_win implements Gfo_invk {
|
||||
private GfuiWin win;
|
||||
private GfuiTextBox shortcut_txt, binding_txt, keycode_txt;
|
||||
private GfuiBtn clear_btn, ok_btn, cxl_btn;
|
||||
private Gfui_bnd_parser bnd_parser = Gfui_bnd_parser.new_en_();
|
||||
private Xoa_app app;
|
||||
private String key_text;
|
||||
public void Show(Xoa_app app, Gfui_kit kit, GfuiWin owner_win, String key_text, String shortcut_text, String binding_text) {
|
||||
this.app = app;
|
||||
this.key_text = key_text;
|
||||
|
||||
// create controls
|
||||
this.win = kit.New_win_utl("shortcut_win", owner_win); win.BackColor_(ColorAdp_.White).Size_(240, 140);
|
||||
GfuiLbl shortcut_lbl = Make_lbl(kit, win, "shortcut_lbl" , "Shortcut:");
|
||||
GfuiLbl binding_lbl = Make_lbl(kit, win, "binding_lbl" , "Binding:");
|
||||
GfuiLbl keycode_lbl = Make_lbl(kit, win, "keycode_lbl" , "Keycode:");
|
||||
this.shortcut_txt = Make_txt(kit, win, "shortcut_txt" , shortcut_text);
|
||||
this.binding_txt = Make_txt(kit, win, "binding_txt" , binding_text);
|
||||
this.keycode_txt = Make_txt(kit, win, "keycode_txt" , "");
|
||||
this.clear_btn = Make_btn(kit, win, "clear_btn" , "Clear");
|
||||
this.ok_btn = Make_btn(kit, win, "ok_btn" , "Ok");
|
||||
this.cxl_btn = Make_btn(kit, win, "cxl_btn" , "Cancel");
|
||||
|
||||
// layout controls
|
||||
Layout( 0, shortcut_lbl , shortcut_txt);
|
||||
Layout(20, binding_lbl , binding_txt);
|
||||
Layout(40, keycode_lbl , keycode_txt);
|
||||
clear_btn.Pos_(70, 70); ok_btn.Pos_(110, 70); cxl_btn.Pos_(150, 70);
|
||||
|
||||
// hookup events
|
||||
IptCfg null_cfg = IptCfg_.Null; IptEventType btn_event_type = IptEventType_.add_(IptEventType_.MouseDown, IptEventType_.KeyDown); IptArg[] btn_args = IptArg_.Ary(IptMouseBtn_.Left, IptKey_.Enter, IptKey_.Space);
|
||||
IptBnd_.ipt_to_(null_cfg , binding_txt , this, Invk__when_key_down , IptEventType_.KeyDown, IptArg_.Wildcard);
|
||||
IptBnd_.ipt_to_(null_cfg , binding_txt , this, Invk__when_key_up , IptEventType_.KeyUp, IptArg_.Wildcard);
|
||||
IptBnd_.ipt_to_(null_cfg , clear_btn , this, Invk__when_clear , btn_event_type, btn_args);
|
||||
IptBnd_.ipt_to_(null_cfg , ok_btn , this, Invk__when_ok , btn_event_type, btn_args);
|
||||
IptBnd_.ipt_to_(null_cfg , cxl_btn , this, Invk__when_cxl , btn_event_type, btn_args);
|
||||
|
||||
// open
|
||||
win.Pos_(SizeAdp_.center_(ScreenAdp_.Primary.Size(), win.Size()));
|
||||
win.Show();
|
||||
binding_txt.Focus();
|
||||
}
|
||||
private void When_key_down(GfoMsg m) {
|
||||
IptEventData event_data = (IptEventData)m.Args_getAt(0).Val();
|
||||
int keycode = event_data.Key().Val();
|
||||
binding_txt.Text_(bnd_parser.Xto_norm(IptKey_.To_str(keycode)));
|
||||
keycode_txt.Text_(Int_.To_str(keycode));
|
||||
event_data.Handled_on();
|
||||
}
|
||||
private void When_key_up(GfoMsg m) {
|
||||
IptEventData event_data = (IptEventData)m.Args_getAt(0).Val();
|
||||
event_data.Handled_on();
|
||||
}
|
||||
private GfuiLbl Make_lbl(Gfui_kit kit, GfuiWin owner_win, String key, String text) {
|
||||
return (GfuiLbl)kit.New_lbl(key, owner_win).Text_(text).Size_(80, 20).BackColor_(ColorAdp_.White);
|
||||
}
|
||||
private GfuiTextBox Make_txt(Gfui_kit kit, GfuiWin owner_win, String key, String text) {
|
||||
return (GfuiTextBox)kit.New_text_box(key, owner_win).Text_(text).Size_(120, 20).Border_on_();
|
||||
}
|
||||
private GfuiBtn Make_btn(Gfui_kit kit, GfuiWin owner_win, String key, String text) {
|
||||
return (GfuiBtn)kit.New_btn(key, owner_win).Text_(text).Size_(40, 20).Focus_able_(true).Border_on_();
|
||||
}
|
||||
private void Layout(int y, GfuiElem elem_1, GfuiElem elem_2) {
|
||||
elem_1.Y_(y);
|
||||
elem_2.Y_(y);
|
||||
elem_2.X_(elem_1.X_max());
|
||||
}
|
||||
|
||||
private final Xog_cbk_trg cbk_trg = Xog_cbk_trg.New(gplx.xowa.addons.apps.cfgs.specials.edits.pages.Xocfg_edit_special.Prototype.Special__meta().Ttl_bry());
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk__when_key_down)) When_key_down(m);
|
||||
else if (ctx.Match(k, Invk__when_key_press)) When_key_up(m);
|
||||
else if (ctx.Match(k, Invk__when_key_up)) When_key_up(m);
|
||||
else if (ctx.Match(k, Invk__when_clear)) binding_txt.Text_("None");
|
||||
else if (ctx.Match(k, Invk__when_ok)) Remap_and_close(binding_txt.Text());
|
||||
|
||||
else if (ctx.Match(k, Invk__when_cxl)) {win.Close();}
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk__when_key_down = "when_key_down", Invk__when_key_press = "when_key_press", Invk__when_key_up = "when_key_up"
|
||||
, Invk__when_clear= "when_clear", Invk__when_ok = "when_ok", Invk__when_cxl = "when_cxl"
|
||||
;
|
||||
private void Remap_and_close(String new_ipt) {
|
||||
app.Gui__cbk_mgr().Send_json(cbk_trg, "xo.cfg_edit.gui_binding__remap_recv", gplx.core.gfobjs.Gfobj_nde.New().Add_str("key", key_text).Add_str("bnd", new_ipt));
|
||||
win.Close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user