1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2014-06-30 00:04:32 -04:00
parent 85594d3cdd
commit bae88e739c
2482 changed files with 198730 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
/*
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.apis; import gplx.*; import gplx.xowa.*;
import gplx.xowa.apis.xowa.*; import gplx.xowa.gui.cmds.*;
public class Xoapi_root implements GfoInvkAble {
public Xoa_app app;
public Xoapi_root(Xoa_app app) {usr_api.Ctor_by_app(app);}
public void Init_by_kit(Xoa_app app) {
this.app = app;
app_api.Init_by_kit(app);
nav.Init_by_kit(app);
gui_api.Init_by_kit(app);
html_api.Init_by_kit(app);
net_api.Init_by_kit(app);
usr_api.Init_by_kit(app);
xtns_api.Init_by_kit(app);
}
public Xoapi_app App() {return app_api;} private Xoapi_app app_api = new Xoapi_app();
public Xoapi_nav Nav() {return nav;} private Xoapi_nav nav = new Xoapi_nav();
public Xoapi_gui Gui() {return gui_api;} private Xoapi_gui gui_api = new Xoapi_gui();
public Xoapi_html Html() {return html_api;} private Xoapi_html html_api = new Xoapi_html();
public Xoapi_net Net() {return net_api;} private Xoapi_net net_api = new Xoapi_net();
public Xoapi_usr Usr() {return usr_api;} private Xoapi_usr usr_api = new Xoapi_usr();
public Xoapi_xtns Xtns() {return xtns_api;} private Xoapi_xtns xtns_api = new Xoapi_xtns();
private void Exec(String key) {
Xog_cmd_itm cmd_itm = app.Gui_mgr().Cmd_mgr().Get_or_null(key);
if (cmd_itm == null) app.Usr_dlg().Warn_many("", "", "could not find cmd; key=~{0}", key);
app.Gfs_mgr().Run_str_for(app, cmd_itm.Cmd());
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_app)) return app_api;
else if (ctx.Match(k, Invk_nav)) return nav;
else if (ctx.Match(k, Invk_gui)) return gui_api;
else if (ctx.Match(k, Invk_html)) return html_api;
else if (ctx.Match(k, Invk_net)) return net_api;
else if (ctx.Match(k, Invk_usr)) return usr_api;
else if (ctx.Match(k, Invk_xtns)) return xtns_api;
else if (ctx.Match(k, Invk_exec)) Exec(m.ReadStr("v"));
return this;
}
private static final String
Invk_exec = "exec"
, Invk_app = "app", Invk_nav = "nav", Invk_gui = "gui", Invk_html = "html", Invk_net = "net", Invk_usr = "usr", Invk_xtns = "xtns"
;
}

View File

@@ -0,0 +1,32 @@
/*
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.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*;
import gplx.xowa.gui.views.*;
public class Xoapi_app implements GfoInvkAble {
private Xog_win_itm win;
public void Init_by_kit(Xoa_app app) {
win = app.Gui_mgr().Browser_win();
}
public void Exit() {win.App__exit();}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_exit)) this.Exit();
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_exit = "exit";
}

View File

@@ -0,0 +1,36 @@
/*
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.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*;
import gplx.xowa.apis.xowa.gui.*;
public class Xoapi_gui implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {
browser.Init_by_kit(app);
font.Init_by_kit(app);
page.Init_by_kit(app);
}
public Xoapi_browser Browser() {return browser;} private Xoapi_browser browser = new Xoapi_browser();
public Xoapi_font Font() {return font;} private Xoapi_font font = new Xoapi_font();
public Xoapi_page Page() {return page;} private Xoapi_page page = new Xoapi_page();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_browser)) return browser;
else if (ctx.Match(k, Invk_font)) return font;
else if (ctx.Match(k, Invk_page)) return page;
return this;
}
private static final String Invk_browser = "browser", Invk_font = "font", Invk_page = "page";
}

View File

@@ -0,0 +1,33 @@
/*
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.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*;
import gplx.xowa.apis.xowa.html.*;
public class Xoapi_html implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {
tidy.Init_by_kit(app);
modules.Init_by_kit(app);
}
public Xoapi_tidy Tidy() {return tidy;} private Xoapi_tidy tidy = new Xoapi_tidy();
public Xoapi_modules Modules() {return modules;} private Xoapi_modules modules = new Xoapi_modules();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_tidy)) return tidy;
else if (ctx.Match(k, Invk_modules)) return modules;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_tidy = "tidy", Invk_modules = "modules";
}

View File

@@ -0,0 +1,40 @@
/*
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.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*;
import gplx.xowa.gui.views.*;
import gplx.xowa.apis.xowa.navs.*;
public class Xoapi_nav implements GfoInvkAble {
private Xog_win_itm win;
public void Init_by_kit(Xoa_app app) {
win = app.Gui_mgr().Browser_win();
wiki.Init_by_kit(app);
}
public Xoapi_wiki Wiki() {return wiki;} private Xoapi_wiki wiki = new Xoapi_wiki();
public void Goto(String page) {win.Page__navigate_by_url_bar(page);}
public void Go_bwd() {win.Page__navigate_by_history(Bool_.N);}
public void Go_fwd() {win.Page__navigate_by_history(Bool_.Y);}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_go_bwd)) this.Go_bwd();
else if (ctx.Match(k, Invk_go_fwd)) this.Go_fwd();
else if (ctx.Match(k, Invk_goto)) this.Goto(m.ReadStr("v"));
else if (ctx.Match(k, Invk_wiki)) return wiki;
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_go_bwd = "go_bwd", Invk_go_fwd = "go_fwd", Invk_goto = "goto", Invk_wiki = "wiki";
}

View File

@@ -0,0 +1,42 @@
/*
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.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*;
public class Xoapi_net implements GfoInvkAble, GfoEvObj {
public Xoapi_net() {this.ev_mgr = GfoEvMgr.new_(this);}
public GfoEvMgr EvMgr() {return ev_mgr;} private GfoEvMgr ev_mgr;
public void Init_by_kit(Xoa_app app) {
}
public boolean Enabled() {return enabled;} private boolean enabled;
public void Enabled_(boolean v) {
this.enabled = v;
gplx.ios.IoEngine_system.Web_access_enabled = v;
GfoEvMgr_.PubVal(this, gplx.xowa.gui.menus.dom.Xog_mnu_evt_mgr.Evt_selected_changed, v);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_enabled)) return this.Enabled();
else if (ctx.Match(k, Invk_enabled_n_)) this.Enabled_(Bool_.N);
else if (ctx.Match(k, Invk_enabled_y_)) this.Enabled_(Bool_.Y);
else if (ctx.Match(k, Invk_enabled_x_)) this.Enabled_(this.Enabled());
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_enabled = "enabled", Invk_enabled_n_ = "enabled_n_", Invk_enabled_y_ = "enabled_y_", Invk_enabled_x_ = "enabled_x_"
;
public static final String Evt_enabled_changed = "enabled_changed";
}

View File

@@ -0,0 +1,40 @@
/*
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.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*;
import gplx.xowa.apis.xowa.usrs.*;
public class Xoapi_usr implements GfoInvkAble {
public void Ctor_by_app(Xoa_app app) {
bookmarks.Ctor_by_app(app);
history.Ctor_by_app(app);
logs.Ctor_by_app(app);
}
public void Init_by_kit(Xoa_app app) {
bookmarks.Init_by_kit(app);
history.Init_by_kit(app);
}
public Xoapi_bookmarks Bookmarks() {return bookmarks;} private Xoapi_bookmarks bookmarks = new Xoapi_bookmarks();
public Xoapi_history History() {return history;} private Xoapi_history history = new Xoapi_history();
public Xoapi_logs Logs() {return logs;} private Xoapi_logs logs = new Xoapi_logs();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_bookmarks)) return bookmarks;
else if (ctx.Match(k, Invk_history)) return history;
else if (ctx.Match(k, Invk_logs)) return logs;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_bookmarks = "bookmarks", Invk_history = "history", Invk_logs = "logs";
}

View File

@@ -0,0 +1,32 @@
/*
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.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*;
import gplx.xowa.apis.xowa.xtns.*;
public class Xoapi_xtns implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {
scribunto.Init_by_kit(app);
}
public Xoapi_scribunto Scribunto() {return scribunto;} private Xoapi_scribunto scribunto = new Xoapi_scribunto();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_scribunto)) return scribunto;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String
Invk_scribunto = "scribunto"
;
}

View File

@@ -0,0 +1,53 @@
/*
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.apis.xowa.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
import gplx.xowa.apis.xowa.gui.browsers.*;
public class Xoapi_browser implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {
url.Init_by_kit(app);
search.Init_by_kit(app);
tabs.Init_by_kit(app);
html.Init_by_kit(app);
find.Init_by_kit(app);
prog.Init_by_kit(app);
info.Init_by_kit(app);
prog_log.Init_by_kit(app);
}
public Xoapi_url Url() {return url;} private Xoapi_url url = new Xoapi_url();
public Xoapi_search Search() {return search;} private Xoapi_search search = new Xoapi_search();
public Xoapi_tabs Tabs() {return tabs;} private Xoapi_tabs tabs = new Xoapi_tabs();
public Xoapi_html_box Html() {return html;} private Xoapi_html_box html = new Xoapi_html_box();
public Xoapi_find Find() {return find;} private Xoapi_find find = new Xoapi_find();
public Xoapi_prog Prog() {return prog;} private Xoapi_prog prog = new Xoapi_prog();
public Xoapi_info Info() {return info;} private Xoapi_info info = new Xoapi_info();
public Xoapi_prog_log Prog_log() {return prog_log;} private Xoapi_prog_log prog_log = new Xoapi_prog_log();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_url)) return url;
else if (ctx.Match(k, Invk_search)) return search;
else if (ctx.Match(k, Invk_tabs)) return tabs;
else if (ctx.Match(k, Invk_html)) return html;
else if (ctx.Match(k, Invk_find)) return find;
else if (ctx.Match(k, Invk_prog)) return prog;
else if (ctx.Match(k, Invk_info)) return info;
else if (ctx.Match(k, Invk_prog_log)) return prog_log;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String
Invk_url = "url", Invk_search = "search", Invk_tabs = "tabs", Invk_html = "html"
, Invk_find = "find", Invk_prog = "prog", Invk_info = "info", Invk_prog_log = "prog_log";
}

View File

@@ -0,0 +1,55 @@
/*
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.apis.xowa.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
import gplx.xowa.cfgs.gui.*; import gplx.xowa.html.*;
public class Xoapi_font implements GfoInvkAble {
private Xoa_app app;
public void Init_by_kit(Xoa_app app) {
this.app = app;
}
public void Increase() {Adj(1);}
public void Decrease() {Adj(-1);}
public void Reset() {Set(false, Xoh_page_mgr.Font_size_default, Xocfg_win.Font_size_default);}
private void Adj(int adj) {
float html_font_size = app.Html_mgr().Page_mgr().Font_size() + adj;
float gui_font_size = app.Gui_mgr().Win_cfg().Font().Size() + adj; // (html_font_size * .75f) - 4; // .75f b/c 16px = 12 pt; -4 b/c gui font is currently 4 pt smaller
if (html_font_size < 1 || gui_font_size < 1) return;
Set(true, html_font_size, gui_font_size);
}
private void Set(boolean enabled, float html_font_size, float gui_font_size) {
if (html_font_size <= 0) return; // font must be positive
app.Html_mgr().Page_mgr().Font_enabled_(enabled);
app.Html_mgr().Page_mgr().Font_size_(html_font_size);
app.Cfg_mgr().Set_by_app("app.html.page.font_enabled", "y");
app.Cfg_mgr().Set_by_app("app.html.page.font_size", Float_.XtoStr(app.Html_mgr().Page_mgr().Font_size()));
app.Gui_mgr().Win_cfg().Font().Size_(gui_font_size);
app.Cfg_mgr().Set_by_app("app.gui.win_opts.font.size", Float_.XtoStr(gui_font_size));
app.Cfg_mgr().Db_save_txt();
app.Gui_mgr().Browser_win().Page__reload(); // NOTE: force reload; needed if viewing Help:Options/HTML, else Font size won't update
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_increase)) this.Increase();
else if (ctx.Match(k, Invk_decrease)) this.Decrease();
else if (ctx.Match(k, Invk_reset)) this.Reset();
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_increase = "increase", Invk_decrease = "decrease", Invk_reset = "reset"
;
}

View File

@@ -0,0 +1,36 @@
/*
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.apis.xowa.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
import gplx.xowa.apis.xowa.gui.pages.*;
public class Xoapi_page implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {
view.Init_by_kit(app);
selection.Init_by_kit(app);
edit.Init_by_kit(app);
}
public Xoapi_view View() {return view;} private Xoapi_view view = new Xoapi_view();
public Xoapi_edit Edit() {return edit;} private Xoapi_edit edit = new Xoapi_edit();
public Xoapi_selection Selection() {return selection;} private Xoapi_selection selection = new Xoapi_selection();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_view)) return view;
else if (ctx.Match(k, Invk_selection)) return selection;
else if (ctx.Match(k, Invk_edit)) return edit;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_view = "view", Invk_selection = "selection", Invk_edit = "edit";
}

View File

@@ -0,0 +1,80 @@
/*
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.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.gui.*;
import gplx.gfui.*; import gplx.xowa.gui.*; import gplx.xowa.gui.views.*;
public class Xoapi_find implements GfoInvkAble {
private Xog_find_box find_box;
public void Init_by_kit(Xoa_app app) {
find_box = new Xog_find_box(app);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_show)) find_box.Show();
else if (ctx.Match(k, Invk_show_by_paste)) find_box.Show_by_paste();
else if (ctx.Match(k, Invk_exec)) find_box.Exec();
else if (ctx.Match(k, Invk_type)) find_box.Exec(); // NOTE: same as exec; provided so that exec doesn't accidentally overwrite auto-type for find
else if (ctx.Match(k, Invk_find_fwd)) find_box.Exec_by_dir(Bool_.Y);
else if (ctx.Match(k, Invk_find_bwd)) find_box.Exec_by_dir(Bool_.N);
else if (ctx.Match(k, Invk_case_toggle)) find_box.Case_toggle();
else if (ctx.Match(k, Invk_wrap_toggle)) find_box.Wrap_toggle();
else if (ctx.Match(k, Invk_hide)) find_box.Hide();
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_show = "show", Invk_show_by_paste = "show_by_paste", Invk_hide = "hide", Invk_exec = "exec", Invk_type = "type"
, Invk_find_bwd = "find_bwd", Invk_find_fwd = "find_fwd", Invk_case_toggle = "case_toggle", Invk_wrap_toggle = "wrap_toggle";
}
class Xog_find_box {
private Xoa_app app; private Xog_win_itm win; private GfuiTextBox find_box;
private boolean dir_fwd = true, case_match = false, wrap_search = true;
public Xog_find_box(Xoa_app app) {
this.app = app;
this.win = app.Gui_mgr().Browser_win();
this.find_box = win.Find_box();
}
public void Show() {app.Gui_mgr().Layout().Find_show();}
public void Hide() {app.Gui_mgr().Layout().Find_close();}
public void Show_by_paste() {
this.Show();
if (win.Tab_mgr().Active_tab_is_null()) return; // if no active_tab, just show box; don't try to copy what's on tab;
find_box.Text_(win.Active_html_itm().Html_selected_get_text_or_href());
}
public void Exec_by_dir(boolean fwd) {
boolean changed = dir_fwd != fwd;
dir_fwd = fwd;
Exec();
if (changed) // clicking on buttons calls Exec_by_dir; in case of repeated clicks on same button, don't flash changed message again
win.Usr_dlg().Prog_direct("Find direction changed to " + (fwd ? "forward" : "backward"));
}
public void Exec() {
Xog_tab_itm tab = win.Tab_mgr().Active_tab(); if (tab == Xog_tab_itm_.Null) return;
String elem_id = tab.View_mode() == Xog_page_mode.Tid_read
? Gfui_html.Elem_id_body
: Xog_html_itm.Elem_id__xowa_edit_data_box
;
tab.Html_box().Html_doc_find(elem_id, find_box.Text(), dir_fwd, case_match, wrap_search);
win.Usr_dlg().Prog_direct("");
}
public void Case_toggle() {
case_match = !case_match;
win.Usr_dlg().Prog_direct("Case match " + (case_match ? "enabled" : "disabled"));
}
public void Wrap_toggle() {
wrap_search = !wrap_search;
win.Usr_dlg().Prog_direct("Wrap search " + (wrap_search ? "enabled" : "disabled"));
}
}

View File

@@ -0,0 +1,36 @@
/*
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.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.gui.*;
import gplx.gfui.*; import gplx.xowa.gui.*; import gplx.xowa.gui.views.*;
public class Xoapi_html_box implements GfoInvkAble {
private Xog_win_itm win;
public void Init_by_kit(Xoa_app app) {this.win = app.Gui_mgr().Browser_win();}
public void Focus() {
Xog_tab_itm tab = win.Active_tab(); if (tab == Xog_tab_itm_.Null) return;
Gfui_html html_box = tab.Html_itm().Html_box();
html_box.Focus();
if (tab.View_mode() != Xog_page_mode.Tid_read) // if edit / html, place focus in edit box
html_box.Html_elem_focus(Xog_html_itm.Elem_id__xowa_edit_data_box);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_focus)) this.Focus();
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_focus = "focus";
}

View File

@@ -0,0 +1,37 @@
/*
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.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.gui.*;
import gplx.gfui.*; import gplx.xowa.gui.views.*;
public class Xoapi_info implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {this.app = app;} private Xoa_app app;
private Xog_win_itm Win() {return app.Gui_mgr().Browser_win();}
public void Focus() {this.Win().Info_box().Focus();}
public void Clear() {app.Usr_dlg().Ui_wkr().Clear();}
public void Launch() {
Io_url session_fil = app.Log_wtr().Session_fil();
app.Fsys_mgr().App_mgr().App_view_text().Run(session_fil);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_focus)) this.Focus();
else if (ctx.Match(k, Invk_clear)) this.Clear();
else if (ctx.Match(k, Invk_launch)) this.Launch();
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_focus = "focus", Invk_clear = "clear", Invk_launch = "launch";
}

View File

@@ -0,0 +1,30 @@
/*
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.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.gui.*;
import gplx.gfui.*; import gplx.xowa.gui.views.*;
public class Xoapi_prog implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {this.app = app;} private Xoa_app app;
private Xog_win_itm Win() {return app.Gui_mgr().Browser_win();}
public void Focus() {this.Win().Prog_box().Focus();}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_focus)) this.Focus();
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_focus = "focus";
}

View File

@@ -0,0 +1,29 @@
/*
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.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.gui.*;
import gplx.gfui.*; import gplx.xowa.gui.views.*;
public class Xoapi_prog_log implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {this.app = app;} private Xoa_app app;
public void Show() {app.Gui_mgr().Show_prog();}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_show)) this.Show();
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_show = "show";
}

View File

@@ -0,0 +1,34 @@
/*
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.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.gui.*;
import gplx.gfui.*; import gplx.xowa.gui.views.*;
public class Xoapi_search implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {this.app = app;} private Xoa_app app;
private GfuiTextBox Search_box() {return app.Gui_mgr().Browser_win().Search_box();}
private Xog_win_itm Win() {return app.Gui_mgr().Browser_win();}
public void Focus() {this.Search_box().Focus_select_all();}
public void Exec() {this.Win().Page__navigate_by_search();}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_focus)) this.Focus();
else if (ctx.Match(k, Invk_exec)) this.Exec();
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_focus = "focus";
public static final String Invk_exec = "exec";
}

View File

@@ -0,0 +1,90 @@
/*
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.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.gui.*;
import gplx.xowa.gui.views.*;
public class Xoapi_tabs implements GfoInvkAble {
private Xog_tab_mgr tab_mgr;
public void Init_by_kit(Xoa_app app) {
this.tab_mgr = app.Gui_mgr().Browser_win().Tab_mgr();
}
private boolean Active_tab_is_null() {return tab_mgr.Active_tab_is_null();}
public void New_dupe(boolean focus) {tab_mgr.Tabs_new_dupe(focus);}
public void New_dflt(boolean focus) {tab_mgr.Tabs_new_dflt(focus);}
public void New_link(boolean focus, String link) {tab_mgr.Tabs_new_link(focus, link);}
public void New_href(boolean focus) {
Xog_tab_itm tab = tab_mgr.Active_tab(); if (tab == Xog_tab_itm_.Null) return;
String link = tab.Html_itm().Html_selected_get_href_or_text();
if (String_.Len_eq_0(link)) {tab_mgr.Win().Usr_dlg().Prog_many("", "", "no link or text selected"); return;}
tab_mgr.Tabs_new_dflt(true);
tab_mgr.Win().Page__navigate_by_url_bar(link);
}
public void Close_cur() {tab_mgr.Tabs_close_cur();}
public void Select_bwd() {tab_mgr.Tabs_select(Bool_.N);}
public void Select_fwd() {tab_mgr.Tabs_select(Bool_.Y);}
public void Select_by_idx(int v) {tab_mgr.Tabs_select_by_idx(v - ListAdp_.Base1);}
public void Move_bwd() {tab_mgr.Tabs_move(Bool_.N);}
public void Move_fwd() {tab_mgr.Tabs_move(Bool_.Y);}
public void Close_others() {tab_mgr.Tabs_close_others();}
public void Close_to_bgn() {tab_mgr.Tabs_close_to_bgn();}
public void Close_to_end() {tab_mgr.Tabs_close_to_end();}
public void Close_undo() {tab_mgr.Tabs_close_undo();}
public void Pin_toggle() {if (this.Active_tab_is_null()) return; tab_mgr.Active_tab().Pin_toggle();}
public void Tab_bookmark_all() {}//app.Gui_mgr().Browser_win().Tab_mgr().Tabs_close_others();}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_new_dflt__at_dflt__focus_y)) this.New_dflt(Bool_.Y);
else if (ctx.Match(k, Invk_new_link__at_dflt__focus_n)) this.New_link(Bool_.N, m.ReadStrOr("v", null));
else if (ctx.Match(k, Invk_new_link__at_dflt__focus_y)) this.New_link(Bool_.Y, m.ReadStrOr("v", null));
else if (ctx.Match(k, Invk_new_href__at_dflt__focus_y)) this.New_href(Bool_.Y);
else if (ctx.Match(k, Invk_new_dupe__at_dflt__focus_y)) this.New_dupe(Bool_.Y);
else if (ctx.Match(k, Invk_close_cur)) this.Close_cur();
else if (ctx.Match(k, Invk_select_bwd)) this.Select_bwd();
else if (ctx.Match(k, Invk_select_fwd)) this.Select_fwd();
else if (ctx.Match(k, Invk_move_bwd)) this.Move_bwd();
else if (ctx.Match(k, Invk_move_fwd)) this.Move_fwd();
else if (ctx.Match(k, Invk_close_others)) this.Close_others();
else if (ctx.Match(k, Invk_close_to_bgn)) this.Close_to_bgn();
else if (ctx.Match(k, Invk_close_to_end)) this.Close_to_end();
else if (ctx.Match(k, Invk_close_undo)) this.Close_undo();
else if (ctx.Match(k, Invk_pin_toggle)) this.Pin_toggle();
else if (ctx.Match(k, Invk_select_by_idx_1)) this.Select_by_idx(1);
else if (ctx.Match(k, Invk_select_by_idx_2)) this.Select_by_idx(2);
else if (ctx.Match(k, Invk_select_by_idx_3)) this.Select_by_idx(3);
else if (ctx.Match(k, Invk_select_by_idx_4)) this.Select_by_idx(4);
else if (ctx.Match(k, Invk_select_by_idx_5)) this.Select_by_idx(5);
else if (ctx.Match(k, Invk_select_by_idx_6)) this.Select_by_idx(6);
else if (ctx.Match(k, Invk_select_by_idx_7)) this.Select_by_idx(7);
else if (ctx.Match(k, Invk_select_by_idx_8)) this.Select_by_idx(8);
else if (ctx.Match(k, Invk_select_by_idx_9)) this.Select_by_idx(9);
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_new_dflt__at_dflt__focus_y = "new_dflt__at_dflt__focus_y"
, Invk_new_link__at_dflt__focus_n = "new_link__at_dflt__focus_n"
, Invk_new_link__at_dflt__focus_y = "new_link__at_dflt__focus_y"
, Invk_new_href__at_dflt__focus_y = "new_href__at_dflt__focus_y"
, Invk_new_dupe__at_dflt__focus_y = "new_dupe__at_dflt__focus_y"
, Invk_close_cur = "close_cur"
, Invk_select_bwd = "select_bwd", Invk_select_fwd = "select_fwd"
, Invk_move_bwd = "move_bwd", Invk_move_fwd = "move_fwd"
, Invk_close_others = "close_others", Invk_close_to_bgn = "close_to_bgn", Invk_close_to_end = "close_to_end", Invk_close_undo = "close_undo"
, Invk_pin_toggle = "pin_toggle"
, Invk_select_by_idx_1 = "select_by_idx_1", Invk_select_by_idx_2 = "select_by_idx_2", Invk_select_by_idx_3 = "select_by_idx_3", Invk_select_by_idx_4 = "select_by_idx_4", Invk_select_by_idx_5 = "select_by_idx_5"
, Invk_select_by_idx_6 = "select_by_idx_6", Invk_select_by_idx_7 = "select_by_idx_7", Invk_select_by_idx_8 = "select_by_idx_8", Invk_select_by_idx_9 = "select_by_idx_9"
;
}

View File

@@ -0,0 +1,57 @@
/*
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.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.gui.*;
import gplx.gfui.*; import gplx.xowa.gui.views.*;
public class Xoapi_url implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {this.app = app;} private Xoa_app app;
private GfuiTextBox Url_box() {return app.Gui_mgr().Browser_win().Url_box();}
public void Focus() {this.Url_box().Focus_select_all();}
public void Exec() {Exec_wkr(Bool_.N, this.Url_box().Text());}
public void Exec_by_paste() {Exec_wkr(Bool_.N, ClipboardAdp_.GetText());}
public void Exec_new_tab_by_paste() {Exec_wkr(Bool_.Y, ClipboardAdp_.GetText());}
private void Exec_wkr(boolean new_tab, String urls_text) {
if (Op_sys.Cur().Tid_is_wnt())
urls_text = String_.Replace(urls_text, Op_sys.Wnt.Nl_str(), Op_sys.Lnx.Nl_str());
String[] urls = String_.Split(String_.Trim(urls_text), Op_sys.Lnx.Nl_str());
int urls_len = urls.length;
if (urls_len == 0) return;
if (urls_len == 1) {
String url = urls[0];
this.Url_box().Text_(url);
app.Gui_mgr().Browser_win().Page__navigate_by_url_bar(url);
}
else {
for (int i = 0; i < urls_len; i++) {
String url = urls[i];
if (String_.HasAtBgn(url, "\"") && String_.HasAtBgn(url, "\""))
url = String_.Mid(url, 1, String_.Len(url) - 1);
app.Gui_mgr().Browser_win().Tab_mgr().Tabs_new_link(url, false);
}
}
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_focus)) this.Focus();
else if (ctx.Match(k, Invk_exec)) this.Exec();
else if (ctx.Match(k, Invk_exec_by_paste)) this.Exec_by_paste();
else if (ctx.Match(k, Invk_exec_new_tab_by_paste)) this.Exec_new_tab_by_paste();
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_focus = "focus", Invk_exec_by_paste = "exec_by_paste", Invk_exec_new_tab_by_paste = "exec_new_tab_by_paste";
public static final String Invk_exec = "exec";
}

View File

@@ -0,0 +1,56 @@
/*
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.apis.xowa.gui.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.gui.*;
import gplx.xowa.gui.*; import gplx.xowa.gui.views.*;
public class Xoapi_edit implements GfoInvkAble {
private Xog_win_itm win;
public void Init_by_kit(Xoa_app app) {
win = app.Gui_mgr().Browser_win();
}
private boolean Active_tab_is_null() {return win.Tab_mgr().Active_tab_is_null();}
public void Copy() {if (Active_tab_is_null()) return; win.Kit().Clipboard().Copy(win.Active_html_itm().Html_selected_get_text_or_href());}
public void Select_all() {if (Active_tab_is_null()) return; GfoInvkAble_.InvkCmd(win.Win_box().Kit().Clipboard(), gplx.gfui.Gfui_clipboard_.Invk_select_all);}
public void Save() {if (Active_tab_is_null()) return; Xog_tab_itm_edit_mgr.Save(win.Active_tab(), false);}
public void Save_draft() {if (Active_tab_is_null()) return; Xog_tab_itm_edit_mgr.Save(win.Active_tab(), true);}
public void Preview() {if (Active_tab_is_null()) return; Xog_tab_itm_edit_mgr.Preview(win.Active_tab());}
public void Dbg_tmpl() {if (Active_tab_is_null()) return; Xog_tab_itm_edit_mgr.Debug(win, Xog_page_mode.Tid_edit);}
public void Dbg_html() {if (Active_tab_is_null()) return; Xog_tab_itm_edit_mgr.Debug(win, Xog_page_mode.Tid_html);}
public void Focus_edit_box(){if (Active_tab_is_null()) return; Xog_tab_itm_edit_mgr.Focus(win, Xog_html_itm.Elem_id__xowa_edit_data_box);}
public void Exec() {
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_copy)) this.Copy();
else if (ctx.Match(k, Invk_select_all)) this.Select_all();
else if (ctx.Match(k, Invk_save)) this.Save();
else if (ctx.Match(k, Invk_save_draft)) this.Save_draft();
else if (ctx.Match(k, Invk_preview)) this.Preview();
else if (ctx.Match(k, Invk_focus_edit_box)) this.Focus_edit_box();
else if (ctx.Match(k, Invk_dbg_tmpl)) this.Dbg_tmpl();
else if (ctx.Match(k, Invk_dbg_html)) this.Dbg_html();
else if (ctx.Match(k, Invk_exec)) this.Exec();
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_copy = "copy"
, Invk_select_all = "select_all"
, Invk_save = "save", Invk_save_draft = "save_draft", Invk_preview = "preview"
, Invk_focus_edit_box = "focus_edit_box"
, Invk_dbg_tmpl = "dbg_tmpl", Invk_dbg_html = "dbg_html", Invk_exec = "exec"
;
}

View File

@@ -0,0 +1,52 @@
/*
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.apis.xowa.gui.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.gui.*;
import gplx.gfui.*; import gplx.xowa.gui.*; import gplx.xowa.gui.views.*;
public class Xoapi_selection implements GfoInvkAble {
private Xoa_app app; private Xog_win_itm win;
public void Init_by_kit(Xoa_app app) {
this.app = app;
win = app.Gui_mgr().Browser_win();
}
private boolean Active_tab_is_null() {return win.Tab_mgr().Active_tab_is_null();}
public void Copy() {if (Active_tab_is_null()) return; win.Kit().Clipboard().Copy(win.Active_html_itm().Html_selected_get_text_or_href());}
public void Select_all() {if (Active_tab_is_null()) return; GfoInvkAble_.InvkCmd(win.Win_box().Kit().Clipboard(), gplx.gfui.Gfui_clipboard_.Invk_select_all);}
public void Save_file_as() {
if (this.Active_tab_is_null()) return;
Xog_html_itm html_itm = win.Tab_mgr().Active_tab().Html_itm();
String src = html_itm.Html_selected_get_src_or_empty();
if (String_.Len_eq_0(src)) {app.Usr_dlg().Prog_many("", "", "no file selected: tab=~{0}", html_itm.Owner_tab().Page().Url().X_to_full_str()); return;}
Io_url src_url = Io_url_.http_any_(src, Op_sys.Cur().Tid_is_wnt());
String trg_name = src_url.NameAndExt();
if (String_.Has(src, "/thumb/")) trg_name = src_url.OwnerDir().NameOnly();
String trg = app.Gui_mgr().Kit().New_dlg_file(Gfui_kit_.File_dlg_type_save, "Select file to save to:").Init_file_(trg_name).Ask();
if (String_.Len_eq_0(trg)) return;
Io_url trg_url = Io_url_.new_fil_(trg);
Io_mgr._.CopyFil(src_url, trg_url, true);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_copy)) this.Copy();
else if (ctx.Match(k, Invk_select_all)) this.Select_all();
else if (ctx.Match(k, Invk_save_file_as)) this.Save_file_as();
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_copy = "copy", Invk_select_all = "select_all", Invk_save_file_as = "save_file_as"
;
}

View File

@@ -0,0 +1,61 @@
/*
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.apis.xowa.gui.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.gui.*;
import gplx.gfui.*; import gplx.xowa.gui.*; import gplx.xowa.gui.views.*;
public class Xoapi_view implements GfoInvkAble {
private Xoa_app app; private Xog_win_itm win;
public void Init_by_kit(Xoa_app app) {
this.app = app; this.win = app.Gui_mgr().Browser_win();
}
private boolean Active_tab_is_null() {return win.Tab_mgr().Active_tab_is_null();}
public void Mode_read() {Mode(Xog_page_mode.Tid_read);}
public void Mode_edit() {Mode(Xog_page_mode.Tid_edit);}
public void Mode_html() {Mode(Xog_page_mode.Tid_html);}
private void Mode(byte v) {if (Active_tab_is_null()) return; win.Page__mode_(v);}
public void Reload() {if (Active_tab_is_null()) return; win.Page__reload();}
public void Refresh() {if (Active_tab_is_null()) return; win.Page__refresh();}
public void Print() {
if (this.Active_tab_is_null()) return;
win.Active_html_box().Html_window_print_preview();
}
public void Save_as() {
if (this.Active_tab_is_null()) return;
Xog_tab_itm tab = win.Tab_mgr().Active_tab();
String file_name = app.Url_converter_fsys_safe().Encode_str(String_.new_utf8_(tab.Page().Ttl().Full_url())) + ".html";
String file_url = app.Gui_mgr().Kit().New_dlg_file(Gfui_kit_.File_dlg_type_save, "Select file to save to:").Init_file_(file_name).Ask();
if (String_.Len_eq_0(file_url)) return;
Io_mgr._.SaveFilStr(file_url, tab.Html_box().Text());
app.Usr_dlg().Prog_many("", "", "saved page: file=~{0}", file_url);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_mode_read)) this.Mode_read();
else if (ctx.Match(k, Invk_mode_edit)) this.Mode_edit();
else if (ctx.Match(k, Invk_mode_html)) this.Mode_html();
else if (ctx.Match(k, Invk_reload)) this.Reload();
else if (ctx.Match(k, Invk_refresh)) this.Refresh();
else if (ctx.Match(k, Invk_print)) this.Print();
else if (ctx.Match(k, Invk_save_as)) this.Save_as();
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_mode_read = "mode_read", Invk_mode_edit = "mode_edit", Invk_mode_html = "mode_html"
, Invk_reload = "reload", Invk_refresh = "refresh"
, Invk_print = "print", Invk_save_as = "save_as"
;
}

View File

@@ -0,0 +1,36 @@
/*
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.apis.xowa.html; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
import gplx.xowa.apis.xowa.html.modules.*;
public class Xoapi_modules implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {
popups.Init_by_app(app);
}
public Xoapi_collapsible Collapsible() {return collapsible;} private Xoapi_collapsible collapsible = new Xoapi_collapsible();
public Xoapi_navframe Navframe() {return navframe;} private Xoapi_navframe navframe = new Xoapi_navframe();
public Xoapi_toc Toc() {return toc;} private Xoapi_toc toc = new Xoapi_toc();
public Xoapi_popups Popups() {return popups;} private Xoapi_popups popups = new Xoapi_popups();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_collapsible)) return collapsible;
else if (ctx.Match(k, Invk_navframe)) return navframe;
else if (ctx.Match(k, Invk_toc)) return toc;
else if (ctx.Match(k, Invk_popups)) return popups;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_collapsible = "collapsible", Invk_navframe = "navframe", Invk_toc = "toc", Invk_popups = "popups";
}

View File

@@ -0,0 +1,40 @@
/*
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.apis.xowa.html; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
import gplx.xowa.html.tidy.*;
public class Xoapi_tidy implements GfoInvkAble {
private Xoa_app app;
public void Init_by_kit(Xoa_app app) {
this.app = app;
}
public void Toggle() {
app.Html_mgr().Tidy_mgr().Enabled_toggle();
app.Gui_mgr().Browser_win().Page__refresh();
}
public void Engine_(byte v) {
app.Html_mgr().Tidy_mgr().Wkr_tid_(v);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_toggle)) this.Toggle();
else if (ctx.Match(k, Invk_engine_tidy_)) Engine_(Xoh_tidy_wkr_.Tid_tidy);
else if (ctx.Match(k, Invk_engine_jtidy_)) Engine_(Xoh_tidy_wkr_.Tid_jtidy);
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_toggle = "toggle", Invk_engine_tidy_ = "engine_tidy_", Invk_engine_jtidy_ = "engine_jtidy_";
}

View File

@@ -0,0 +1,32 @@
/*
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.apis.xowa.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.html.*;
public class Xoapi_collapsible implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {
}
public boolean Collapsed() {return collapsed;} private boolean collapsed;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_collapsed)) return Yn.X_to_str(collapsed);
else if (ctx.Match(k, Invk_collapsed_)) collapsed = m.ReadYn("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_collapsed = "collapsed", Invk_collapsed_ = "collapsed_"
;
}

View File

@@ -0,0 +1,32 @@
/*
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.apis.xowa.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.html.*;
public class Xoapi_navframe implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {
}
public boolean Collapsed() {return collapsed;} private boolean collapsed;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_collapsed)) return Yn.X_to_str(collapsed);
else if (ctx.Match(k, Invk_collapsed_)) collapsed = m.ReadYn("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_collapsed = "collapsed", Invk_collapsed_ = "collapsed_"
;
}

View File

@@ -0,0 +1,194 @@
/*
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.apis.xowa.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.html.*;
import gplx.xowa.html.modules.popups.*;
public class Xoapi_popups implements GfoInvkAble, GfoEvMgrOwner {
private Xoa_app app;
public Xoapi_popups() {
evMgr = GfoEvMgr.new_(this);
}
public GfoEvMgr EvMgr() {return evMgr;} private GfoEvMgr evMgr;
public void Init_by_app(Xoa_app app) {this.app = app;}
public boolean Enabled() {return enabled;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled = false;
public int Show_init_word_count() {return show_init_word_count;} private int show_init_word_count = Dflt_show_init_word_count;
public int Show_more_word_count() {return show_more_word_count;} private int show_more_word_count = Dflt_show_more_word_count;
public int Show_all_if_less_than() {return show_all_if_less_than;} public void Show_all_if_less_than_(int v) {show_all_if_less_than = v;} private int show_all_if_less_than = Dflt_show_all_if_less_than;
public byte[] Html_fmt() {return html_fmt;} private byte[] html_fmt = Dflt_html_fmt;
public byte[] Html_fmt_dflt() {return html_fmt_dflt;} private byte[] html_fmt_dflt = Dflt_html_fmt;
public int Win_show_delay() {return win_show_delay;} private int win_show_delay = Dflt_win_show_delay;
public int Win_hide_delay() {return win_hide_delay;} private int win_hide_delay = Dflt_win_hide_delay;
public int Win_max_w() {return win_max_w;} private int win_max_w = Dflt_win_max_w;
public int Win_max_h() {return win_max_h;} private int win_max_h = Dflt_win_max_h;
public int Win_show_all_max_w() {return win_show_all_max_w;} private int win_show_all_max_w = Dflt_win_show_all_max_w;
public boolean Win_bind_focus_blur() {return win_bind_focus_blur;} private boolean win_bind_focus_blur = Dflt_win_bind_focus_blur;
public byte[] Xnde_ignore_ids() {return xnde_ignore_ids;} private byte[] xnde_ignore_ids = Dflt_coordinates;
public int Scan_len() {return scan_len;} private int scan_len = Dflt_scan_len;
public int Scan_max() {return scan_max;} private int scan_max = Dflt_scan_max;
public byte[] Ns_allowed() {return ns_allowed;} private byte[] ns_allowed = Dflt_ns_allowed;
public int Read_til_stop_fwd() {return read_til_stop_fwd;} private int read_til_stop_fwd = Dflt_read_til_stop_fwd;
public int Read_til_stop_bwd() {return read_til_stop_bwd;} private int read_til_stop_bwd = Dflt_read_til_stop_bwd;
public int Tmpl_tkn_max() {return tmpl_tkn_max;} private int tmpl_tkn_max = Dflt_tmpl_tkn_max;
public void Show_more(String popup_id) {
Xow_wiki wiki = app.Gui_mgr().Browser_win().Active_tab().Page().Wiki();
wiki.Html_mgr().Module_mgr().Popup_mgr().Show_more(popup_id);
}
public void Show_all(String popup_id) {
Xow_wiki wiki = app.Gui_mgr().Browser_win().Active_tab().Page().Wiki();
wiki.Html_mgr().Module_mgr().Popup_mgr().Show_all(popup_id);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_enabled)) return Yn.X_to_str(enabled);
else if (ctx.Match(k, Invk_enabled_)) enabled = m.ReadYn("v");
else if (ctx.Match(k, Invk_show_more)) Show_more(m.ReadStr("popup_id"));
else if (ctx.Match(k, Invk_show_all)) Show_all (m.ReadStr("popup_id"));
else if (ctx.Match(k, Invk_show_init_word_count)) return show_init_word_count;
else if (ctx.Match(k, Invk_show_init_word_count_)) {show_init_word_count = Set_int_gt_0(m, show_init_word_count, Evt_show_init_word_count_changed);}
else if (ctx.Match(k, Invk_show_more_word_count)) return show_more_word_count;
else if (ctx.Match(k, Invk_show_more_word_count_)) {show_more_word_count = Set_int_gt_0(m, show_more_word_count, Evt_show_more_word_count_changed);}
else if (ctx.Match(k, Invk_show_all_if_less_than)) return show_all_if_less_than;
else if (ctx.Match(k, Invk_show_all_if_less_than_)) {show_all_if_less_than = Set_int(m, show_all_if_less_than, Evt_show_all_if_less_than_changed);}
else if (ctx.Match(k, Invk_win_show_delay)) return win_show_delay;
else if (ctx.Match(k, Invk_win_show_delay_)) {win_show_delay = Set_int(m, win_show_delay, Evt_win_show_delay_changed);}
else if (ctx.Match(k, Invk_win_hide_delay)) return win_hide_delay;
else if (ctx.Match(k, Invk_win_hide_delay_)) {win_hide_delay = Set_int(m, win_hide_delay, Evt_win_hide_delay_changed);}
else if (ctx.Match(k, Invk_win_max_w)) return win_max_w;
else if (ctx.Match(k, Invk_win_max_w_)) {win_max_w = Set_int(m, win_max_w, Evt_win_max_w_changed);}
else if (ctx.Match(k, Invk_win_max_h)) return win_max_h;
else if (ctx.Match(k, Invk_win_max_h_)) {win_max_h = Set_int(m, win_max_h, Evt_win_max_h_changed);}
else if (ctx.Match(k, Invk_win_show_all_max_w)) return win_show_all_max_w;
else if (ctx.Match(k, Invk_win_show_all_max_w_)) {win_show_all_max_w = m.ReadInt("v");}
else if (ctx.Match(k, Invk_win_bind_focus_blur)) return Yn.X_to_str(win_bind_focus_blur);
else if (ctx.Match(k, Invk_win_bind_focus_blur_)) win_bind_focus_blur = m.ReadYn("v");
else if (ctx.Match(k, Invk_xnde_ignore_ids)) return String_.new_utf8_(xnde_ignore_ids);
else if (ctx.Match(k, Invk_xnde_ignore_ids_)) {xnde_ignore_ids = m.ReadBry("v"); GfoEvMgr_.PubVal(this, Evt_xnde_ignore_ids_changed, xnde_ignore_ids);}
else if (ctx.Match(k, Invk_scan_len)) return scan_len;
else if (ctx.Match(k, Invk_scan_len_)) {scan_len = Set_int_gt_0(m, scan_len, Evt_scan_len_changed);}
else if (ctx.Match(k, Invk_scan_max)) return scan_max;
else if (ctx.Match(k, Invk_scan_max_)) {scan_max = Set_int_gt_0(m, scan_max, Evt_scan_max_changed);}
else if (ctx.Match(k, Invk_html_fmt)) return String_.new_utf8_(html_fmt);
else if (ctx.Match(k, Invk_html_fmt_)) {html_fmt = m.ReadBry("v"); GfoEvMgr_.PubVal(this, Evt_html_fmt_changed, html_fmt);}
else if (ctx.Match(k, Invk_html_fmt_dflt)) return String_.new_utf8_(html_fmt_dflt);
else if (ctx.Match(k, Invk_html_fmt_dflt_)) {html_fmt_dflt = m.ReadBry("v");}
else if (ctx.Match(k, Invk_read_til_stop_fwd)) return read_til_stop_fwd;
else if (ctx.Match(k, Invk_read_til_stop_fwd_)) {read_til_stop_fwd = m.ReadInt("v"); GfoEvMgr_.PubVal(this, Evt_read_til_stop_fwd_changed, read_til_stop_fwd);}
else if (ctx.Match(k, Invk_read_til_stop_bwd)) return read_til_stop_bwd;
else if (ctx.Match(k, Invk_read_til_stop_bwd_)) {read_til_stop_bwd = m.ReadInt("v"); GfoEvMgr_.PubVal(this, Evt_read_til_stop_bwd_changed, read_til_stop_bwd);}
else if (ctx.Match(k, Invk_ns_allowed)) return String_.new_utf8_(ns_allowed);
else if (ctx.Match(k, Invk_ns_allowed_)) {ns_allowed = m.ReadBry("v"); GfoEvMgr_.PubVal(this, Evt_ns_allowed_changed, ns_allowed);}
else if (ctx.Match(k, Invk_tmpl_tkn_max)) return tmpl_tkn_max;
else if (ctx.Match(k, Invk_tmpl_tkn_max_)) {tmpl_tkn_max = m.ReadInt("v"); GfoEvMgr_.PubVal(this, Evt_tmpl_tkn_max_changed, tmpl_tkn_max);}
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private int Set_int_gt_0(GfoMsg m, int cur_val, String evt) {
int tmp = m.ReadInt("v");
if (tmp < 1) return cur_val;
GfoEvMgr_.PubVal(this, evt, tmp);
return tmp;
}
private int Set_int(GfoMsg m, int cur_val, String evt) {
int tmp = m.ReadInt("v");
GfoEvMgr_.PubVal(this, evt, tmp);
return tmp;
}
private static final String
Invk_enabled = "enabled", Invk_enabled_ = "enabled_"
, Invk_show_init_word_count = "show_init_word_count", Invk_show_init_word_count_ = "show_init_word_count_"
, Invk_show_more_word_count = "show_more_word_count", Invk_show_more_word_count_ = "show_more_word_count_"
, Invk_show_all_if_less_than = "show_all_if_less_than", Invk_show_all_if_less_than_ = "show_all_if_less_than_"
, Invk_xnde_ignore_ids = "xnde_ignore_ids", Invk_xnde_ignore_ids_ = "xnde_ignore_ids_"
, Invk_scan_len = "scan_len", Invk_scan_len_ = "scan_len_"
, Invk_scan_max = "scan_max", Invk_scan_max_ = "scan_max_"
, Invk_show_more = "show_more", Invk_show_all = "show_all"
, Invk_html_fmt = "html_fmt", Invk_html_fmt_ = "html_fmt_"
, Invk_html_fmt_dflt = "html_fmt_dflt", Invk_html_fmt_dflt_ = "html_fmt_dflt_"
, Invk_win_show_delay = "win_show_delay", Invk_win_show_delay_ = "win_show_delay_"
, Invk_win_hide_delay = "win_hide_delay", Invk_win_hide_delay_ = "win_hide_delay_"
, Invk_win_bind_focus_blur = "win_bind_focus_blur", Invk_win_bind_focus_blur_ = "win_bind_focus_blur_"
, Invk_win_max_w = "win_max_w", Invk_win_max_w_ = "win_max_w_"
, Invk_win_max_h = "win_max_h", Invk_win_max_h_ = "win_max_h_"
, Invk_win_show_all_max_w = "win_show_all_max_w", Invk_win_show_all_max_w_ = "win_show_all_max_w_"
, Invk_read_til_stop_fwd = "read_til_stop_fwd", Invk_read_til_stop_fwd_ = "read_til_stop_fwd_"
, Invk_read_til_stop_bwd = "read_til_stop_bwd", Invk_read_til_stop_bwd_ = "read_til_stop_bwd_"
, Invk_ns_allowed = "ns_allowed", Invk_ns_allowed_ = "ns_allowed_"
, Invk_tmpl_tkn_max = "tmpl_tkn_max", Invk_tmpl_tkn_max_ = "tmpl_tkn_max_"
;
public static final String
Evt_show_init_word_count_changed = "show_init_word_count_changed"
, Evt_show_more_word_count_changed = "show_more_word_count_changed"
, Evt_show_all_if_less_than_changed = "show_all_if_less_than_changed"
, Evt_win_show_delay_changed = "win_show_delay_changed"
, Evt_win_hide_delay_changed = "win_hide_delay_changed"
, Evt_win_max_w_changed = "win_max_w_changed"
, Evt_win_max_h_changed = "win_max_h_changed"
, Evt_xnde_ignore_ids_changed = "xnde_ignore_ids_changed"
, Evt_scan_len_changed = "scan_len_changed"
, Evt_scan_max_changed = "scan_max_changed"
, Evt_html_fmt_changed = "html_fmt_changed"
, Evt_read_til_stop_fwd_changed = "read_til_stop_fwd_changed"
, Evt_read_til_stop_bwd_changed = "read_til_stop_bwd_changed"
, Evt_ns_allowed_changed = "ns_allowed_changed"
, Evt_tmpl_tkn_max_changed = "tmpl_tkn_max_changed"
;
public static final byte[]
Dflt_coordinates = Bry_.new_ascii_("coordinates")
, Dflt_html_fmt = Bry_.new_ascii_(String_.Concat_lines_nl_skip_last
( "<div dir=~{page_lang_ltr}>"
, " <div>~{content}"
, " </div>"
, " <hr/>"
, " <div>"
, " <span class='data_val'><b>~{page_title}</b></span>~{wiki_item}"
, " <span class='data_key'>~{<>msgs.get('api-xowa.html.modules.popups.msgs.size-name');<>}:</span><span class='data_val'>~{page_size}</span>"
, " <span class='data_key'>~{<>msgs.get('api-xowa.html.modules.popups.msgs.edited-name');<>}:</span><span class='data_val'>~{edit_time}</span>~{view_time_item}"
, " </div>"
, " <hr/>"
, " <div style='float:bottom;'>"
, " <span><a href='xowa-cmd:xowa.api.nav.goto(\"~{page_url}\");' title='~{<>msgs.get('api-xowa.gui.browser.url.exec-name');<>}'><img src='~{xowa_root_dir}user/anonymous/app/img/window/menu/page/open.png'></a></span>"
, " <span><a href='xowa-cmd:xowa.api.gui.browser.tabs.new_link__at_dflt__focus_y(\"~{page_url}\");' title='~{<>msgs.get('api-xowa.gui.browser.tabs.new_link__at_dflt__focus_y-name');<>}'><img src='~{xowa_root_dir}user/anonymous/app/img/window/menu/tabs/new.png'></a></span>"
, " <span><a href='xowa-cmd:xowa.api.gui.browser.tabs.new_link__at_dflt__focus_n(\"~{page_url}\");' title='~{<>msgs.get('api-xowa.gui.browser.tabs.new_link__at_dflt__focus_n-name');<>}'><img src='~{xowa_root_dir}user/anonymous/app/img/window/menu/tabs/new_background.png'></a></span>"
, " <span><a href='xowa-cmd:xowa.api.usr.bookmarks.add(\"~{page_url}\");' title='~{<>msgs.get('api-xowa.usr.bookmarks.add-name');<>}'><img src='~{xowa_root_dir}user/anonymous/app/img/window/menu/bookmarks/add.png'></a></span>"
, " <span><a href='xowa-cmd:xowa.api.html.modules.popups.show_more(\"~{popup_id}\");' title='~{<>msgs.get('api-xowa.html.modules.popups.show_more-tip');<>}'><img src='~{xowa_root_dir}bin/any/xowa/html/modules/xowa.popups/imgs/show_more.png'></a></span>"
, " <span><a href='xowa-cmd:xowa.api.html.modules.popups.show_all (\"~{popup_id}\");' title='~{<>msgs.get('api-xowa.html.modules.popups.show_all-tip');<>}'> <img src='~{xowa_root_dir}bin/any/xowa/html/modules/xowa.popups/imgs/show_all.png' ></a></span>"
, " <span><a href='xowa-cmd:xowa.api.gui.browser.tabs.new_link__at_dflt__focus_y(\"home/wiki/Help:Options/Popups\");' title='~{<>msgs.get('api-xowa.nav.cfg.main-name');<>}'><img src='~{xowa_root_dir}user/anonymous/app/img/window/menu/tools/options.png'></a></span>"
, " </div>"
, "</div>"
))
;
public static final String[] Dflt_html_fmt_keys = String_.Ary("content", "page_lang_ltr", "page_url", "page_title", "wiki_domain", "wiki_item", "page_size", "edit_time", "view_time_item", "xowa_root_dir", "popup_id");
public static final byte[]
Dflt_ns_allowed = Bry_.Empty
;
public static final int
Dflt_show_init_word_count = 64
, Dflt_show_more_word_count = 64
, Dflt_show_all_if_less_than = -1
, Dflt_show_all_win_max_w = -1
, Dflt_win_show_delay = 400, Dflt_win_hide_delay = 400
, Dflt_win_max_w = -1, Dflt_win_max_h = -1
, Dflt_win_show_all_max_w = -1
, Dflt_scan_len = 1 * Io_mgr.Len_kb
, Dflt_scan_max = 32 * Io_mgr.Len_kb
, Dflt_read_til_stop_fwd = -1
, Dflt_read_til_stop_bwd = -1
, Dflt_tmpl_tkn_max = 8192
;
public static final boolean
Dflt_win_bind_focus_blur = false
;
}

View File

@@ -0,0 +1,32 @@
/*
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.apis.xowa.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.html.*;
public class Xoapi_toc implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {
}
public boolean Collapsed() {return collapsed;} private boolean collapsed = false;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_collapsed)) return Yn.X_to_str(collapsed);
else if (ctx.Match(k, Invk_collapsed_)) collapsed = m.ReadYn("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_collapsed = "collapsed", Invk_collapsed_ = "collapsed_"
;
}

View File

@@ -0,0 +1,36 @@
/*
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.apis.xowa.navs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
import gplx.xowa.gui.views.*;
public class Xoapi_wiki implements GfoInvkAble {
private Xog_win_itm win;
public void Init_by_kit(Xoa_app app) {
win = app.Gui_mgr().Browser_win();
}
public void Main_page() {win.Page__navigate_by_url_bar(win.Active_page().Wiki().Domain_str() + Xoh_href_parser.Href_wiki_str);} // NOTE: add "/wiki/" to generate non-page like url; EX: "home" -> "home/wiki/" which will be interpreted as a url, as opposed to "home" which will be intrepretted as page; DATE:2014-04-14
public void Random() {win.Page__navigate_by_url_bar("Special:Random");}
public void Sandbox() {win.Page__navigate_by_url_bar("Project:Sandbox");}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_main_page)) this.Main_page();
else if (ctx.Match(k, Invk_random)) this.Random();
else if (ctx.Match(k, Invk_sandbox)) this.Sandbox();
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_main_page = "main_page", Invk_random = "random", Invk_sandbox = "sandbox";
}

View File

@@ -0,0 +1,78 @@
/*
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.apis.xowa.startup; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
class Xoapi_startup_tabs implements GfoInvkAble {
public String[] Calc_startup_strs() {
switch (type) {
case Xoapi_startup_tabs_type_.Tid_blank: return new String[] {gplx.xowa.specials.xowa.default_tab.Default_tab_page.Ttl_full_str};
case Xoapi_startup_tabs_type_.Tid_xowa: return new String[] {gplx.xowa.users.Xouc_pages_mgr.Page_xowa};
case Xoapi_startup_tabs_type_.Tid_custom: return String_.SplitLines_nl(custom);
case Xoapi_startup_tabs_type_.Tid_previous: return String_.SplitLines_nl(previous);
default: throw Err_.unhandled(type);
}
}
public String Custom() {return custom;} private String custom;
public boolean Custom_is_expr() {return custom_is_expr;} private boolean custom_is_expr;
public String Previous() {return previous;} public Xoapi_startup_tabs Previous_(String v) {previous = v; return this;} private String previous = "";
public byte Type() {return type;} private byte type = Xoapi_startup_tabs_type_.Tid_xowa;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_type)) return Xoapi_startup_tabs_type_.X_to_key(type);
else if (ctx.Match(k, Invk_type_)) type = Xoapi_startup_tabs_type_.X_to_tid(m.ReadStr("v"));
else if (ctx.Match(k, Invk_custom)) return custom;
else if (ctx.Match(k, Invk_custom_)) custom = m.ReadStr("v");
else if (ctx.Match(k, Invk_custom_is_expr)) return Yn.X_to_str(custom_is_expr);
else if (ctx.Match(k, Invk_custom_is_expr_)) custom_is_expr = m.ReadYn("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_type = "type", Invk_type_ = "type_"
, Invk_custom = "custom", Invk_custom_ = "custom_"
, Invk_custom_is_expr = "custom_is_expr", Invk_custom_is_expr_ = "custom_is_expr_"
;
}
class Xoapi_startup_tabs_type_ {
public static final byte Tid_blank = 0, Tid_xowa = 1, Tid_previous = 2, Tid_custom = 3;
public static final String Key_blank = "blank", Key_xowa = "xowa", Key_previous = "previous", Key_custom = "custom";
public static String X_to_key(byte v) {
switch (v) {
case Tid_blank: return Key_blank;
case Tid_xowa: return Key_xowa;
case Tid_previous: return Key_previous;
case Tid_custom: return Key_custom;
default: throw Err_.not_implemented_();
}
}
public static byte X_to_tid(String s) {
if (String_.Eq(s, Key_blank)) return Tid_blank;
else if (String_.Eq(s, Key_xowa)) return Tid_xowa;
else if (String_.Eq(s, Key_previous)) return Tid_previous;
else if (String_.Eq(s, Key_custom)) return Tid_custom;
else throw Err_.not_implemented_();
}
public static KeyVal[] Options__list = KeyVal_.Ary(KeyVal_.new_(Key_blank), KeyVal_.new_(Key_xowa), KeyVal_.new_(Key_previous), KeyVal_.new_(Key_custom));
}
/*
startup {
tabs {
type = 'previous|blank|custom|xowa_home';
custom = 'en.wikipedia.org/wiki/{{{MONTHNAME}}} {{{DAY}}';
custom_has_wikitext = 'n';
}
}
*/

View File

@@ -0,0 +1,53 @@
/*
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.apis.xowa.usrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
import gplx.xowa.gui.history.*; import gplx.xowa.gui.views.*;
public class Xoapi_bookmarks implements GfoInvkAble {
private Xoa_app app; private Xog_win_itm win;
public void Ctor_by_app(Xoa_app app) {this.app = app;}
public void Init_by_kit(Xoa_app app) {this.win = app.Gui_mgr().Browser_win();}
public boolean Enabled() {return enabled;} private boolean enabled = true;
public void Enabled_(boolean v) {enabled = v;}
public void Add(String url_str) {
if (!enabled) return;
Xog_tab_itm tab = win.Active_tab(); if (tab == Xog_tab_itm_.Null) return;
Xoa_page page = tab.Page();
byte[] wiki_domain = null, ttl_full_txt = null;
if (url_str == null) {
wiki_domain = page.Wiki().Domain_bry();
ttl_full_txt = page.Ttl().Full_txt();
}
else {
Xoa_url url = Xoa_url_parser.Parse_from_url_bar(app, page.Wiki(), url_str);
wiki_domain = url.Wiki_bry();
ttl_full_txt = url.Page_bry();
}
app.User().Bookmarks_add(wiki_domain, ttl_full_txt);
app.Usr_dlg().Prog_many("", "", "bookmark added: ~{0}", String_.new_utf8_(ttl_full_txt));
}
public void Show() {win.Page__navigate_by_url_bar("home/wiki/Data:Bookmarks");}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_enabled)) return Yn.X_to_str(this.Enabled());
else if (ctx.Match(k, Invk_enabled_)) Enabled_(m.ReadYn("v"));
else if (ctx.Match(k, Invk_add)) this.Add(m.ReadStrOr("v", null));
else if (ctx.Match(k, Invk_show)) this.Show();
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_enabled = "enabled", Invk_enabled_ = "enabled_", Invk_add = "add", Invk_show = "show";
}

View File

@@ -0,0 +1,37 @@
/*
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.apis.xowa.usrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
import gplx.xowa.gui.views.*;
public class Xoapi_history implements GfoInvkAble {
private Xoa_app app; private Xog_win_itm win;
public void Ctor_by_app(Xoa_app app) {this.app = app;}
public void Init_by_kit(Xoa_app app) {this.win = app.Gui_mgr().Browser_win();}
public boolean Enabled() {return enabled;} private boolean enabled = true;
public void Enabled_(boolean v) {enabled = v;}
public void Goto_recent() {win.Page__navigate_by_url_bar(app.User().History_mgr().Get_at_last(app));}
public void Show() {win.Page__navigate_by_url_bar("home/wiki/Special:XowaPageHistory");}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_enabled)) return Yn.X_to_str(this.Enabled());
else if (ctx.Match(k, Invk_enabled_)) Enabled_(m.ReadYn("v"));
else if (ctx.Match(k, Invk_goto_recent)) this.Goto_recent();
else if (ctx.Match(k, Invk_show)) this.Show();
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_enabled = "enabled", Invk_enabled_ = "enabled_", Invk_goto_recent = "goto_recent", Invk_show = "show";
}

View File

@@ -0,0 +1,37 @@
/*
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.apis.xowa.usrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
import gplx.xowa.gui.views.*;
public class Xoapi_logs implements GfoInvkAble {
private Xoa_app app;
public void Ctor_by_app(Xoa_app app) {this.app = app;}
public void Init_by_kit(Xoa_app app) {}
public boolean Enabled() {return app.Log_wtr().Enabled();}
public void Enabled_(boolean v) {
app.Log_wtr().Enabled_(v);
if (!v)
Io_mgr._.DeleteFil_args(app.Log_wtr().Session_fil()).MissingFails_off().Exec();
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_enabled)) return Yn.X_to_str(this.Enabled());
else if (ctx.Match(k, Invk_enabled_)) Enabled_(m.ReadYn("v"));
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_enabled = "enabled", Invk_enabled_ = "enabled_";
}

View File

@@ -0,0 +1,38 @@
/*
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.apis.xowa.xtns; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.scribunto.engines.*;
public class Xoapi_scribunto implements GfoInvkAble {
private Xoa_app app;
public void Init_by_kit(Xoa_app app) {
this.app = app;
}
public void Engine_(byte v) {
Scrib_xtn_mgr scrib_xtn = (Scrib_xtn_mgr)app.Xtn_mgr().Get_or_fail(Scrib_xtn_mgr.XTN_KEY);
scrib_xtn.Engine_type_(v);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_engine_lua_)) Engine_(Scrib_engine_type.Type_lua);
else if (ctx.Match(k, Invk_engine_luaj_)) Engine_(Scrib_engine_type.Type_luaj);
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_engine_lua_ = "engine_lua_", Invk_engine_luaj_ = "engine_luaj_"
;
}