1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

'v3.3.4.1'

This commit is contained in:
gnosygnu
2016-03-27 23:44:59 -04:00
parent de67253a9c
commit baaef32df2
903 changed files with 13339 additions and 8695 deletions

View File

@@ -50,10 +50,10 @@ xowa {
gui {
browser {
url {
focus();
exec_by_paste();
exec_new_tab_by_paste();
restore();
focus();
exec_by_paste();
exec_new_tab_by_paste();
restore();
exec();
}
search {
@@ -61,45 +61,45 @@ xowa {
exec();
}
tabs {
new_dflt__at_dflt__focus_y();
new_link__at_dflt__focus_n();
new_link__at_dflt__focus_y();
new_href__at_dflt__focus_y();
new_dupe__at_dflt__focus_y();
close_cur();
select_bwd();
select_fwd();
move_bwd();
move_fwd();
close_others();
close_to_bgn();
close_to_end();
close_undo();
pin_toggle();
select_by_idx_1();
select_by_idx_2();
select_by_idx_3();
select_by_idx_4();
select_by_idx_5();
select_by_idx_6();
select_by_idx_7();
select_by_idx_8();
new_dflt__at_dflt__focus_y();
new_link__at_dflt__focus_n();
new_link__at_dflt__focus_y();
new_href__at_dflt__focus_y();
new_dupe__at_dflt__focus_y();
close_cur();
select_bwd();
select_fwd();
move_bwd();
move_fwd();
close_others();
close_to_bgn();
close_to_end();
close_undo();
pin_toggle();
select_by_idx_1();
select_by_idx_2();
select_by_idx_3();
select_by_idx_4();
select_by_idx_5();
select_by_idx_6();
select_by_idx_7();
select_by_idx_8();
select_by_idx_9();
}
html {
focus();
selection_focus_toggle();
focus();
selection_focus_toggle();
load_tid; // [mem,url]
}
find {
show();
show_by_paste();
hide();
exec();
type();
find_bwd();
find_fwd();
case_toggle();
show();
show_by_paste();
hide();
exec();
type();
find_bwd();
find_fwd();
case_toggle();
wrap_toggle();
}
prog {
@@ -107,11 +107,11 @@ xowa {
show_short_link;
}
info {
focus();
clear();
launch();
warn_enabled;
note_enabled;
focus();
clear();
launch();
warn_enabled;
note_enabled;
}
prog_log {
show();
@@ -124,30 +124,30 @@ xowa {
}
page {
edit {
copy();
select_all();
save();
save_draft();
preview();
focus_edit_box();
dbg_tmpl();
dbg_html();
exec();
}
selection {
copy();
select_all();
save_file_as();
}
view {
mode_read();
mode_edit();
mode_html();
reload();
refresh();
print();
save_as();
}
copy();
select_all();
save();
save_draft();
preview();
focus_edit_box();
dbg_tmpl();
dbg_html();
exec();
}
selection {
copy();
select_all();
save_file_as();
}
view {
mode_read();
mode_edit();
mode_html();
reload();
refresh();
print();
save_as();
}
}
}
html {

View File

@@ -40,16 +40,17 @@ public class Xoapi_root implements GfoInvkAble {
html_api.Page().Toggle_mgr().Img_dir_(img_dir);
usr_api.Init_by_app(app);
}
public Xoapi_app App() {return app_api;} private final Xoapi_app app_api = new Xoapi_app();
public Xoapi_nav Nav() {return nav_api;} private final Xoapi_nav nav_api = new Xoapi_nav();
public Xoapi_gui Gui() {return gui_api;} private final Xoapi_gui gui_api = new Xoapi_gui();
public Xoapi_html Html() {return html_api;} private final Xoapi_html html_api = new Xoapi_html();
public Xoapi_bldr Bldr() {return bldr_api;} private final Xoapi_bldr bldr_api = new Xoapi_bldr();
public Xoapi_net Net() {return net_api;} private final Xoapi_net net_api = new Xoapi_net();
public Xoapi_usr Usr() {return usr_api;} private final Xoapi_usr usr_api = new Xoapi_usr();
public Xoapi_special Special() {return special_api;} private final Xoapi_special special_api = new Xoapi_special();
public Xoapi_xtns Xtns() {return xtns_api;} private final Xoapi_xtns xtns_api = new Xoapi_xtns();
public Xoapi_app_wikis Wikis() {return app_wikis;} private final Xoapi_app_wikis app_wikis = new Xoapi_app_wikis();
public Xoapi_addon Addon() {return addon_api;} private final Xoapi_addon addon_api = new Xoapi_addon();
public Xoapi_app App() {return app_api;} private final Xoapi_app app_api = new Xoapi_app();
public Xoapi_nav Nav() {return nav_api;} private final Xoapi_nav nav_api = new Xoapi_nav();
public Xoapi_gui Gui() {return gui_api;} private final Xoapi_gui gui_api = new Xoapi_gui();
public Xoapi_html Html() {return html_api;} private final Xoapi_html html_api = new Xoapi_html();
public Xoapi_bldr Bldr() {return bldr_api;} private final Xoapi_bldr bldr_api = new Xoapi_bldr();
public Xoapi_net Net() {return net_api;} private final Xoapi_net net_api = new Xoapi_net();
public Xoapi_usr Usr() {return usr_api;} private final Xoapi_usr usr_api = new Xoapi_usr();
public Xoapi_special Special() {return special_api;} private final Xoapi_special special_api = new Xoapi_special();
public Xoapi_xtns Xtns() {return xtns_api;} private final Xoapi_xtns xtns_api = new Xoapi_xtns();
public Xoapi_app_wikis Wikis() {return app_wikis;} private final Xoapi_app_wikis app_wikis = new Xoapi_app_wikis();
public String Test_str() {return test_str;} public void Test_str_(String v) {test_str = v;} private String test_str; // TEST
private void Exec(String key) {
Xog_cmd_itm cmd_itm = app.Gui_mgr().Cmd_mgr().Get_or_null(key);
@@ -58,6 +59,7 @@ public class Xoapi_root implements GfoInvkAble {
}
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_addon)) return addon_api;
else if (ctx.Match(k, Invk_bldr)) return bldr_api;
else if (ctx.Match(k, Invk_nav)) return nav_api;
else if (ctx.Match(k, Invk_gui)) return gui_api;
@@ -74,7 +76,8 @@ public class Xoapi_root implements GfoInvkAble {
}
private static final String
Invk_exec = "exec"
, Invk_app = "app", Invk_bldr = "bldr", Invk_nav = "nav", Invk_gui = "gui", Invk_html = "html", Invk_net = "net", Invk_usr = "usr", Invk_special = "special", Invk_xtns = "xtns"
, Invk_app = "app", Invk_addon = "addon"
, Invk_bldr = "bldr", Invk_nav = "nav", Invk_gui = "gui", Invk_html = "html", Invk_net = "net", Invk_usr = "usr", Invk_special = "special", Invk_xtns = "xtns"
, Invk_test_str = "test_str", Invk_test_str_ = "test_str_"
, Invk_wikis = "wikis"
;

View File

@@ -0,0 +1,28 @@
/*
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.apps.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*;
import gplx.xowa.apps.apis.xowa.addons.*;
public class Xoapi_addon implements GfoInvkAble {
public void Ctor_by_app(Xoa_app app) {}
public Xoapi_search_addon Search() {return search;} private final Xoapi_search_addon search = new Xoapi_search_addon();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk__search)) return search;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk__search = "search";
}

View File

@@ -0,0 +1,39 @@
/*
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.apps.apis.xowa.addons; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.domains.crts.*;
import gplx.xowa.apps.apis.xowa.addons.searchs.*;
public class Xoapi_search_addon implements GfoInvkAble {
public Xoapi_search_addon() {}
public Xoapi_url_bar Url_bar() {return url_bar;} private final Xoapi_url_bar url_bar = new Xoapi_url_bar();
@gplx.Internal protected Xoapi_search_box Search_box() {return search_box;} private final Xoapi_search_box search_box = new Xoapi_search_box();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk__url_bar)) return url_bar;
else if (ctx.Match(k, Invk__search_box)) return search_box;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String
Invk__url_bar = "url_bar"
, Invk__search_box = "search_box"
;
}
class Xoapi_search_box implements GfoInvkAble {
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
return null;
}
}

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.apps.apis.xowa.addons.searchs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.addons.*;
public class Xoapi_search_mode_ {
public static final int Tid__title_full = 0, Tid__title_word = 1;
public static final String Str__title_full = "title.full", Str__title_word = "title.word";
public static String To_str(int v) {
switch (v) {
case Tid__title_full: return Str__title_full;
case Tid__title_word: return Str__title_word;
default: throw Err_.new_unhandled_default(v);
}
}
public static int To_int(String v) {
if (String_.Eq(v, Str__title_full)) return Tid__title_full;
else if (String_.Eq(v, Str__title_word)) return Tid__title_word;
else throw Err_.new_unhandled_default(v);
}
}

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.apps.apis.xowa.addons.searchs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.addons.*;
import gplx.xowa.addons.searchs.searchers.*; import gplx.xowa.addons.searchs.searchers.crts.*;
public class Xoapi_url_bar implements GfoInvkAble, GfoEvMgrOwner {
public Xoapi_url_bar() {
this.evMgr = GfoEvMgr.new_(this);
}
public GfoEvMgr EvMgr() {return evMgr;} private final GfoEvMgr evMgr;
public boolean Enabled() {return enabled;} private boolean enabled = true;
public int Search_mode() {return search_mode;} private int search_mode = Xoapi_search_mode_.Tid__title_word;
public int Max_results() {return max_results;} private int max_results = 10;
public boolean Auto_wildcard() {return auto_wildcard;} private boolean auto_wildcard = true;
public Srch_ns_mgr Ns_mgr() {return ns_mgr;} private final Srch_ns_mgr ns_mgr = new Srch_ns_mgr().Add_main_if_empty();
public Srch_crt_scanner_syms Syms() {return syms;} private Srch_crt_scanner_syms syms = Srch_search_mgr.Scanner_syms;
public Keyval[] Operators() {return symbols;} private Keyval[] symbols = Keyval_.Ary_empty;
public int Visible_rows() {return visible_rows;} private int visible_rows = 10;
public int Jump_len() {return jump_len;} private int jump_len = 5;
private void Ns_ids_(String s) {
int[] ns_ids = Int_.Ary_empty;
if (String_.Eq(s, "*")) {} // leave as int[0]; ns_mgr will interpret as wildcard
else {
ns_ids = Int_.Ary_parse(s, ",");
}
ns_mgr.Add_by_int_ids(ns_ids);
GfoEvMgr_.Pub(this, Evt__ns_ids_changed);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk__enabled)) return Yn.To_str(enabled);
else if (ctx.Match(k, Invk__enabled_)) enabled = m.ReadBool("v");
else if (ctx.Match(k, Invk__search_mode)) return Xoapi_search_mode_.To_str(search_mode);
else if (ctx.Match(k, Invk__search_mode_)) search_mode = Xoapi_search_mode_.To_int(m.ReadStr("v"));
else if (ctx.Match(k, Invk__max_results)) return Int_.To_str(max_results);
else if (ctx.Match(k, Invk__max_results_)) max_results = m.ReadInt("v");
else if (ctx.Match(k, Invk__auto_wildcard)) return Yn.To_str(auto_wildcard);
else if (ctx.Match(k, Invk__auto_wildcard_)) auto_wildcard = m.ReadBool("v");
else if (ctx.Match(k, Invk__ns_ids)) return Int_.To_str(ns_mgr.To_int_ary(), "|");
else if (ctx.Match(k, Invk__ns_ids_)) Ns_ids_(m.ReadStr("v"));
else if (ctx.Match(k, Invk__symbols)) return String_.new_u8(syms.To_bry());
else if (ctx.Match(k, Invk__symbols_)) syms.Parse(m.ReadBry("v"));
else if (ctx.Match(k, Invk__visible_rows)) return Int_.To_str(visible_rows);
else if (ctx.Match(k, Invk__visible_rows_)) {visible_rows = m.ReadInt("v"); GfoEvMgr_.PubVal(this, Evt__visible_rows_changed, visible_rows);}
else if (ctx.Match(k, Invk__jump_len)) return Int_.To_str(jump_len);
else if (ctx.Match(k, Invk__jump_len_)) {jump_len = m.ReadInt("v"); GfoEvMgr_.PubVal(this, Evt__jump_len_changed, jump_len);}
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk__enabled = "enabled" , Invk__enabled_ = "enabled_"
, Invk__search_mode = "search_mode" , Invk__search_mode_ = "search_mode_"
, Invk__max_results = "max_results" , Invk__max_results_ = "max_results_"
, Invk__auto_wildcard = "auto_wildcard" , Invk__auto_wildcard_ = "auto_wildcard_"
, Invk__ns_ids = "ns_ids" , Invk__ns_ids_ = "ns_ids_"
, Invk__symbols = "symbols" , Invk__symbols_ = "symbols_"
, Invk__visible_rows = "visible_rows" , Invk__visible_rows_ = "visible_rows_"
, Invk__jump_len = "jump_len" , Invk__jump_len_ = "jump_len_"
;
public static final String
Evt__visible_rows_changed = "visible_rows_changed"
, Evt__jump_len_changed = "jump_len_changed"
, Evt__ns_ids_changed = "ns_ids_changed"
;
}

View File

@@ -16,8 +16,9 @@ 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.apps.apis.xowa.bldrs.imports; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.bldrs.*;
import gplx.core.ios.*; import gplx.xowa.wikis.data.*;
import gplx.core.ios.*; import gplx.xowa.wikis.data.*; import gplx.xowa.apps.apis.xowa.bldrs.imports.page_ranks.*;
public class Xoapi_import implements GfoInvkAble {
public Xoapi_page_rank Page_rank() {return page_rank;} private final Xoapi_page_rank page_rank = new Xoapi_page_rank();
public long Layout_all_max() {return layout_all_max;} private long layout_all_max = 0; // disable by default; may set to 200 MB in future
public long Layout_text_max() {return layout_text_max;} private long layout_text_max = Io_size_.To_long_by_int_mb(1500); // 1.5 GB
public long Layout_html_max() {return layout_html_max;} private long layout_html_max = Io_size_.To_long_by_int_mb(1500); // 1.5 GB
@@ -77,10 +78,11 @@ public class Xoapi_import implements GfoInvkAble {
else if (ctx.Match(k, Invk_hzip_mode_is_b256_)) hzip_mode_is_b256 = m.ReadYn("v");
else if (ctx.Match(k, Invk_user_name)) return user_name;
else if (ctx.Match(k, Invk_user_name_)) user_name = m.ReadStr("v");
else if (ctx.Match(k, Invk_page_rank)) return page_rank;
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static KeyVal[] Options_zip_tid__list = KeyVal_.Ary(KeyVal_.new_("raw", "text"), KeyVal_.new_("gzip"), KeyVal_.new_("bzip2"));
private static Keyval[] Options_zip_tid__list = Keyval_.Ary(Keyval_.new_("raw", "text"), Keyval_.new_("gzip"), Keyval_.new_("bzip2"));
private static final String
Invk_layout_all_max = "layout_all_max" , Invk_layout_all_max_ = "layout_all_max_"
, Invk_layout_text_max = "layout_text_max" , Invk_layout_text_max_ = "layout_text_max_"
@@ -96,6 +98,7 @@ public class Xoapi_import implements GfoInvkAble {
, Invk_user_name = "user_name" , Invk_user_name_ = "user_name_"
, Invk_hzip_enabled = "hzip_enabled" , Invk_hzip_enabled_ = "hzip_enabled_"
, Invk_hzip_mode_is_b256 = "hzip_mode_is_b256" , Invk_hzip_mode_is_b256_ = "hzip_mode_is_b256_"
, Invk_page_rank = "page_rank"
;
public static final byte[] Ns_file_map__each = Bry_.new_a7("<each>");
}

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.apps.apis.xowa.bldrs.imports.page_ranks; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.bldrs.*; import gplx.xowa.apps.apis.xowa.bldrs.imports.*;
public class Xoapi_page_rank implements GfoInvkAble {
public int Iteration_max() {return iteration_max;} private int iteration_max = 0;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_iteration_max)) return Int_.To_str(iteration_max);
else if (ctx.Match(k, Invk_iteration_max_)) iteration_max = m.ReadInt("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_iteration_max = "iteration_max" , Invk_iteration_max_ = "iteration_max_"
;
}

View File

@@ -40,7 +40,7 @@ public class Xoapi_font implements GfoInvkAble {
app.Gui_mgr().Win_cfg().Font().Size_(gui_font_size);
app.Cfg_mgr().Set_by_app("app.gui.win_opts.font.size", Float_.To_str(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
app.Gui_mgr().Browser_win().Page__reload(); // NOTE: force reload; needed if viewing home/wiki/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();

View File

@@ -40,7 +40,8 @@ public class Xoapi_find implements GfoInvkAble {
}
class Xog_find_box {
private Xoae_app app; private Xog_win_itm win; private GfuiTextBox find_box;
private String prv_find_text; private boolean dir_fwd = true, case_match = false, wrap_search = true;
private String prv_find_text = ""; // NOTE: must set to "", else will fail during Hide
private boolean dir_fwd = true, case_match = false, wrap_search = true;
public Xog_find_box(Xoae_app app) {
this.app = app;
this.win = app.Gui_mgr().Browser_win();
@@ -66,7 +67,7 @@ class Xog_find_box {
win.Usr_dlg().Prog_direct("Find direction changed to " + (fwd ? "forward" : "backward"));
}
public void Exec() {
prv_find_text = find_box.Text();
prv_find_text = find_box.Text();
Exec_find(prv_find_text, Bool_.Y);
}
private void Exec_find(String find, boolean highlight_matches) {

View File

@@ -18,9 +18,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apps.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.gui.*;
import gplx.gfui.*; import gplx.xowa.guis.views.*; import gplx.core.envs.*;
public class Xoapi_url implements GfoInvkAble {
public void Init_by_kit(Xoae_app app) {this.app = app;} private Xoae_app app;
private GfuiTextBox Url_box() {return app.Gui_mgr().Browser_win().Url_box();}
public void Focus() {this.Url_box().Focus_select_all();}
private Xoae_app app;
private Xoapi_url_searcher url_searcher;
public void Init_by_kit(Xoae_app app) {
this.app = app;
this.url_searcher = new Xoapi_url_searcher(app);
}
private GfuiComboBox Url_box() {return app.Gui_mgr().Browser_win().Url_box();}
public void Focus() {this.Url_box().Focus(); this.Url_box().Sel_(0, String_.Len(this.Url_box().Text()));}
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());}
@@ -28,15 +33,29 @@ public class Xoapi_url implements GfoInvkAble {
Xog_tab_itm tab = app.Gui_mgr().Browser_win().Active_tab(); if (tab == Xog_tab_itm_.Null) return;
this.Url_box().Text_(tab.Page().Url().To_str());
}
public void Type() {
url_searcher.Search();
}
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) {
if (urls_len == 1) { // 1 url; most cases
String url = urls[0];
this.Url_box().Text_(url);
gplx.core.threads.Thread_adp_.Sleep(1); // HACK: sleep 1 ms, else rapid keystrokes may cause last keystroke to not register; EX: typing "w:" may show just "w" instead of "w:"; DATE:2016-03-27
GfuiComboBox combo = this.Url_box();
String[] itms_ary = combo.DataSource_as_str_ary();
if ( itms_ary.length > 0 // results exist...
&& combo.List_visible()) { // and dropdown is visible; use selected-item
int sel_idx = combo.List_sel_idx(); // get selected item
if (sel_idx == -1) sel_idx = 0; // if nothing selected, default to 1st; allows typing first few characters and picking 1st item from list
String itms_sel = itms_ary[sel_idx];
// if (String_.Has(String_.Lower(itms_sel), String_.Lower(url))) // make sure itms_sel contains url; handles slow machines, where dropdown may not be updated yet
url = Xog_win_itm.Remove_redirect_if_exists(itms_sel);
}
combo.Text_(url);
app.Gui_mgr().Browser_win().Page__navigate_by_url_bar(url);
}
else {
@@ -54,9 +73,10 @@ public class Xoapi_url implements GfoInvkAble {
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 if (ctx.Match(k, Invk_restore)) this.Restore();
else if (ctx.Match(k, Invk_type)) this.Type();
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", Invk_restore = "restore";
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", Invk_restore = "restore", Invk_type = "type";
public static final String Invk_exec = "exec";
}

View File

@@ -0,0 +1,74 @@
/*
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.apps.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.gui.*;
import gplx.gfui.*;
import gplx.xowa.addons.searchs.*; import gplx.xowa.addons.searchs.searchers.*; import gplx.xowa.addons.searchs.searchers.cbks.*;
import gplx.xowa.apps.apis.xowa.addons.searchs.*;
import gplx.xowa.guis.views.*;
class Xoapi_url_searcher implements GfoEvObj {
private final Xoae_app app;
private final Xoapi_url_bar url_bar_api; private Srch_search_addon addon;
private final GfuiComboBox url_bar;
public Xoapi_url_searcher(Xoae_app app) { // called by Init_by_kit
this.app = app;
this.evMgr = GfoEvMgr.new_(this);
this.url_bar = app.Gui_mgr().Browser_win().Url_box();
this.url_bar_api = app.Api_root().Addon().Search().Url_bar();
GfoEvMgr_.SubSame_many(url_bar_api, this, Xoapi_url_bar.Evt__jump_len_changed, Xoapi_url_bar.Evt__visible_rows_changed, Xoapi_url_bar.Evt__ns_ids_changed);
url_bar.Items__jump_len_(url_bar_api.Jump_len());
url_bar.Items__visible_rows_(url_bar_api.Visible_rows());
}
public GfoEvMgr EvMgr() {return evMgr;} private final GfoEvMgr evMgr;
public void Search() {
if (!url_bar_api.Enabled()) return;
Xog_tab_itm active_tab = app.Gui_mgr().Browser_win().Tab_mgr().Active_tab(); if (active_tab == null) return;
Xow_wiki wiki = active_tab.Wiki();
String search_str = url_bar.Text();
url_bar.Text_fallback_(search_str);
// remove "en.wikipedia.org/wiki/"
// String url_bgn = wiki.Domain_str() + gplx.xowa.htmls.hrefs.Xoh_href_.Str__wiki;
// if (String_.Has_at_bgn(search_str, url_bgn))
// search_str = String_.Mid(search_str, String_.Len(url_bgn));
if (String_.Len_eq_0(search_str)) {
url_bar.Items__update(String_.Ary_empty);
return;
}
if (addon == null) {
addon = Srch_search_addon.Get(wiki);
}
else {
if (!Bry_.Eq(wiki.Domain_bry(), addon.Wiki_domain())) // NOTE: url_bar_api caches addon at wiki level; need to check if wiki has changed
addon = Srch_search_addon.Get(wiki);
}
if (addon.Db_mgr().Cfg().Version_id__needs_upgrade()) return; // exit early, else will flash "searching" message below; note that url-bar should not trigger upgrade;
url_bar.List_sel_idx_(0); // clear selected list item; EX: search "a" -> page down; sel is row #5 -> search "b" -> sel should not be #5; DATE:2016-03-24
if (!url_bar.List_visible()) url_bar.Items__size_to_fit(url_bar_api.Max_results()); // resize offscreen; handles 1st search when dropdown flashes briefly in middle of screen before being moved under bar; DATE:2016-03-24
Srch_search_qry qry = Srch_search_qry.New__url_bar(wiki, url_bar_api, Bry_.new_u8(search_str));
Srch_rslt_cbk__url_bar cbk = new Srch_rslt_cbk__url_bar(app, url_bar, url_bar_api);
Xoa_app_.Usr_dlg().Prog_one("", "", "searching (please wait): ~{0}", search_str);
addon.Search(qry, cbk);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Xoapi_url_bar.Evt__jump_len_changed)) {url_bar.Items__jump_len_(m.ReadInt("v"));}
else if (ctx.Match(k, Xoapi_url_bar.Evt__visible_rows_changed)) {url_bar.Items__visible_rows_(m.ReadInt("v"));}
else if (ctx.Match(k, Xoapi_url_bar.Evt__ns_ids_changed)) {if (addon != null) addon.Clear_rslts_cache();} // invalidate cache when ns changes; else ns_0 rslts will show up in ns_100; DATE:2016-03-24
return this;
}
}

View File

@@ -182,7 +182,7 @@ public class Xoapi_popups implements GfoInvkAble, GfoEvMgrOwner {
, Evt_html_fmtr_wiki_changed = "html_fmtr_wiki_changed"
, Evt_html_fmtr_next_sect_changed = "html_fmtr_next_sect_changed"
;
public static final byte[]
public static final byte[]
Dflt_xnde_ignore_ids = Bry_.new_a7("coordinates")
, Dflt_tmpl_keeplist = Bry_.new_a7("en.wikipedia.org|formatnum;age;age_in_days;age_in_years_and_days*;nts;number_table_sorting*;as_of;oldstyledatedy;gregorian_serial_date;currentminute;currentsecond;dmca;spaced_ndash;trim;month*;convert*;worldpop*;ipa*;lang*;nowrap*;h:*;mvar;math;vgy;audio;iso_639_name;transl;translate;linktext;zh;nihongo*;japanese_name;ko-hhrm;mp|\n")
, Dflt_html_fmtr_popup = Bry_.new_a7(String_.Concat_lines_nl_skip_last
@@ -204,7 +204,7 @@ public class Xoapi_popups implements GfoInvkAble, GfoEvMgrOwner {
, " <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/res/src/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/res/src/xowa/popups/imgs/show_all.png' ></a></span>"
, " <span><a href='/wiki/Special:XowaPopupHistory' title='~{<>msgs.get('api-xowa.html.modules.popups.history-tip');<>}'><img src='~{xowa_root_dir}bin/any/xowa/file/app.menu/history/show.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}bin/any/xowa/file/app.menu/tools/options.png'></a></span>"
, " <span><a href='xowa-cmd:xowa.api.gui.browser.tabs.new_link__at_dflt__focus_y(\"home/wiki/Options/Popups\");' title='~{<>msgs.get('api-xowa.nav.cfg.main-name');<>}'><img src='~{xowa_root_dir}bin/any/xowa/file/app.menu/tools/options.png'></a></span>" // HOME
, " </div>"
, "</div>"
))
@@ -212,13 +212,13 @@ public class Xoapi_popups implements GfoInvkAble, GfoEvMgrOwner {
, Dflt_html_fmtr_wiki = Bry_.new_a7("\n <span class='data_key'>~{<>msgs.get('api-xowa.html.modules.popups.msgs.wiki-name');<>}</span><span class='data_val'>~{wiki_val}</span>")
, Dflt_html_fmtr_next_sect = Bry_.new_a7("\n\n<span class='next_sect'>~{<>msgs.get('api-xowa.html.modules.popups.msgs.next_sect-name');<>}~{next_sect_val}</span>")
;
public static final String[]
public static final String[]
Dflt_html_fmtr_popup_keys = String_.Ary("content", "page_lang_ltr", "page_url", "page_title", "popup_id", "wiki_item", "page_size", "edit_time", "view_time_item", "xowa_root_dir")
, Dflt_html_fmtr_viewed_keys = String_.Ary("viewed_val")
, Dflt_html_fmtr_wiki_keys = String_.Ary("wiki_val")
, Dflt_html_fmtr_next_sect_keys = String_.Ary("next_sect_val")
;
public static final byte[]
public static final byte[]
Dflt_ns_allowed = Bry_.Empty
;
public static final int

View File

@@ -18,15 +18,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apps.apis.xowa.specials; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.domains.crts.*;
public class Xoapi_search implements GfoInvkAble, GfoEvMgrOwner {
private final Xow_domain_crt_kv_itm_mgr multi_wikis_mgr = new Xow_domain_crt_kv_itm_mgr(); private byte[] multi_wikis_bry = Dflt_multi_wikis_bry;
private final Xow_domain_crt_kv_itm_mgr multi_sorts_mgr = new Xow_domain_crt_kv_itm_mgr(); private byte[] multi_sorts_bry = Dflt_multi_sorts_bry;
private final Xow_domain_crt_kv_itm_mgr multi_wikis_mgr = new Xow_domain_crt_kv_itm_mgr(); private byte[] multi_wikis_bry = Dflt_multi_wikis_bry;
private final Xow_domain_crt_kv_itm_mgr multi_sorts_mgr = new Xow_domain_crt_kv_itm_mgr(); private byte[] multi_sorts_bry = Dflt_multi_sorts_bry;
public Xoapi_search() {
this.evMgr = GfoEvMgr.new_(this);
multi_wikis_mgr.Parse_as_itms(multi_wikis_bry);
multi_sorts_mgr.Parse_as_arys(multi_sorts_bry);
}
public GfoEvMgr EvMgr() {return evMgr;} private GfoEvMgr evMgr;
public int Results_per_page() {return results_per_page;} private int results_per_page = 20;
public int Results_per_page() {return results_per_page;} private int results_per_page = 100;
public boolean Async_db() {return async_db;} private boolean async_db = true;
public void Multi_wikis_bry_(byte[] v) {
if (!multi_wikis_mgr.Parse_as_itms(v)) return;
@@ -66,7 +66,7 @@ public class Xoapi_search implements GfoInvkAble, GfoEvMgrOwner {
Evt_multi_wikis_changed = "multi_wikis_changed"
, Evt_multi_sorts_changed = "multi_sorts_changed"
;
public static final byte[]
public static final byte[]
Dflt_multi_wikis_bry = Bry_.new_a7("<any>|<self>")
, Dflt_multi_sorts_bry = Bry_.new_a7("<any>|<self>,*.wikipedia,*.wikivoyage,*.wiktionary,*.wikisource,*.wikiquote,*.wikibooks,*.wikiversity,*.wikinews")
;

View File

@@ -35,5 +35,5 @@ public class Xoapi_startup_tabs_tid_ {
else if (String_.Eq(s, Key_custom)) return Tid_custom;
else throw Err_.new_unimplemented();
}
public static KeyVal[] Options__list = KeyVal_.Ary(KeyVal_.new_(Key_blank), KeyVal_.new_(Key_xowa), KeyVal_.new_(Key_previous), KeyVal_.new_(Key_custom));
public static Keyval[] Options__list = Keyval_.Ary(Keyval_.new_(Key_blank), Keyval_.new_(Key_xowa), Keyval_.new_(Key_previous), Keyval_.new_(Key_custom));
}

View File

@@ -23,10 +23,10 @@ public class Xoapi_cache implements GfoInvkAble {
private String Info() {
cache_mgr.Page_bgn();
Bry_bfr bfr = Bry_bfr.new_(255);
KeyVal[] ary = cache_mgr.Info();
Keyval[] ary = cache_mgr.Info();
int len = ary.length;
for (int i = 0; i < len; ++i) {
KeyVal kv = ary[i];
Keyval kv = ary[i];
bfr.Add_str_a7(kv.Key()).Add_str_a7(": ").Add_str_u8(kv.Val_to_str_or_empty()).Add_byte_nl();
}
return bfr.To_str_and_clear();