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

Gui: Fix Read / Edit / HTML not working by keyboard shortcuts / in personal wikis [#392]

This commit is contained in:
gnosygnu
2019-03-20 08:33:30 -04:00
parent ab4cbbd3c1
commit 71232e4402
27 changed files with 100 additions and 76 deletions

View File

@@ -50,7 +50,7 @@ class Xog_find_box {
public void Hide() {
app.Gui_mgr().Layout().Find_close();
Xog_tab_itm tab = win.Tab_mgr().Active_tab(); if (tab == Xog_tab_itm_.Null) return;
if (tab.View_mode() == Xopg_page_.Tid_read) // do not fire find("") for edit / html, else focus issues; DATE:2015-06-10
if (tab.View_mode() == Xopg_view_mode_.Tid__read) // do not fire find("") for edit / html, else focus issues; DATE:2015-06-10
Exec_find(prv_find_text, Bool_.N);
}
public void Show_by_paste() {
@@ -72,7 +72,7 @@ class Xog_find_box {
private void Exec_find(String find, boolean highlight_matches) {
Xog_tab_itm tab = win.Tab_mgr().Active_tab(); if (tab == Xog_tab_itm_.Null) return;
find = String_.Replace(find, "\\", "\\\\"); // NOTE: backslashes are always literal, never escape codes; EX: "C:\new" "\n" means "\n", not (byte)10; DATE:2015-08-17
boolean find_in_hdoc = tab.View_mode() == Xopg_page_.Tid_read;
boolean find_in_hdoc = tab.View_mode() == Xopg_view_mode_.Tid__read;
if (find_in_hdoc)
tab.Html_box().Html_js_eval_proc_as_str(Xog_js_procs.Win__find_in_hdoc , find, dir_fwd, case_match, wrap_search, highlight_matches);
else

View File

@@ -23,7 +23,7 @@ public class Xoapi_html_box implements Gfo_invk {
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() != Xopg_page_.Tid_read) // if edit / html, place focus in edit box
if (tab.View_mode() != Xopg_view_mode_.Tid__read) // if edit / html, place focus in edit box
html_box.Html_js_eval_proc_as_str(Xog_js_procs.Doc__elem_focus, Xog_html_itm.Elem_id__xowa_edit_data_box);
}
public void Selection_focus() {

View File

@@ -22,14 +22,14 @@ public class Xoapi_edit implements Gfo_invk {
win = app.Gui_mgr().Browser_win();
}
private boolean Active_tab_is_null() {return win.Tab_mgr().Active_tab_is_null();}
private boolean Active_tab_is_edit() {return !win.Tab_mgr().Active_tab_is_null() && win.Tab_mgr().Active_tab().View_mode() == Xopg_page_.Tid_edit;}
private boolean Active_tab_is_edit() {return !win.Tab_mgr().Active_tab_is_null() && win.Tab_mgr().Active_tab().View_mode() == Xopg_view_mode_.Tid__edit;}
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; Gfo_invk_.Invk_by_key(win.Win_box().Kit().Clipboard(), Gfui_clipboard_.Invk_select_all);}
public void Save() {if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Save(win.Active_tab(), false);}
public void Save_draft() {if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Save(win.Active_tab(), true);}
public void Preview() {if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Preview(win.Active_tab());}
public void Dbg_tmpl() {if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Debug(win, Xopg_page_.Tid_edit);}
public void Dbg_html() {if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Debug(win, Xopg_page_.Tid_html);}
public void Dbg_tmpl() {if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Debug(win, Xopg_view_mode_.Tid__edit);}
public void Dbg_html() {if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Debug(win, Xopg_view_mode_.Tid__html);}
public void Focus_edit_box(){if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Focus(win, Xog_html_itm.Elem_id__xowa_edit_data_box);}
public void Exec() {
}

View File

@@ -23,9 +23,9 @@ public class Xoapi_view implements Gfo_invk {
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(Xopg_page_.Tid_read);}
public void Mode_edit() {Mode(Xopg_page_.Tid_edit);}
public void Mode_html() {Mode(Xopg_page_.Tid_html);}
public void Mode_read() {Mode(Xopg_view_mode_.Tid__read);}
public void Mode_edit() {Mode(Xopg_view_mode_.Tid__edit);}
public void Mode_html() {Mode(Xopg_view_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();}

View File

@@ -67,11 +67,11 @@ class Http_url_parser {
Gfo_qarg_mgr qarg_mgr = new Gfo_qarg_mgr().Init(url_obj.Qargs());
byte[] action_val = qarg_mgr.Read_bry_or("action", Bry_.Empty);
if (Bry_.Eq(action_val, Xoa_url_.Qarg__action__read))
this.action = Xopg_page_.Tid_read;
this.action = Xopg_view_mode_.Tid__read;
else if (Bry_.Eq(action_val, Xoa_url_.Qarg__action__edit))
this.action = Xopg_page_.Tid_edit;
this.action = Xopg_view_mode_.Tid__edit;
else if (Bry_.Eq(action_val, Xoa_url_.Qarg__action__html))
this.action = Xopg_page_.Tid_html;
this.action = Xopg_view_mode_.Tid__html;
else if (Bry_.Eq(action_val, Qarg__action__popup)) {
this.popup = true;
this.popup_id = qarg_mgr.Read_str_or_null(Bry_.new_a7("popup_id"));

View File

@@ -33,10 +33,10 @@ public class Http_url_parser_tst {
fxt.Test__parse("/en.wikipedia.org/wiki/Page_1/A/B/C", fxt.Make().Wiki_("en.wikipedia.org").Page_("Page_1/A/B/C"));
// action=edit
fxt.Test__parse("/en.wikipedia.org/wiki/Page_1?action=edit", fxt.Make().Wiki_("en.wikipedia.org").Page_("Page_1").Action_(Xopg_page_.Tid_edit));
fxt.Test__parse("/en.wikipedia.org/wiki/Page_1?action=edit", fxt.Make().Wiki_("en.wikipedia.org").Page_("Page_1").Action_(Xopg_view_mode_.Tid__edit));
// action=html
fxt.Test__parse("/en.wikipedia.org/wiki/Page_1?action=html", fxt.Make().Wiki_("en.wikipedia.org").Page_("Page_1").Action_(Xopg_page_.Tid_html));
fxt.Test__parse("/en.wikipedia.org/wiki/Page_1?action=html", fxt.Make().Wiki_("en.wikipedia.org").Page_("Page_1").Action_(Xopg_view_mode_.Tid__html));
// action=popup
fxt.Test__parse("/en.wikipedia.org/wiki/Page_1?action=popup", fxt.Make().Wiki_("en.wikipedia.org").Page_("Page_1").Popup_(true));