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
2015-06-28 23:29:30 -04:00
parent bf44bcf3c6
commit d858b74d64
254 changed files with 2058 additions and 1191 deletions

View File

@@ -16,39 +16,7 @@ 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.gfui; import gplx.*;
class Mem_html extends GxwTextMemo_lang implements Gxw_html { public String Html_doc_html() {
return String_.Replace(this.TextVal(), "\r\n", "\n");
}
public String Html_doc_selected_get_sub_atr(String tag, String sub_tag, int sub_idx, String sub_atr) {return "";}
public String Html_doc_selected_get(String host, String page) {return "";}
public String Html_doc_selected_get_text_or_href() {return "";}
public String Html_doc_selected_get_href_or_text() {return "";}
public String Html_doc_selected_get_src_or_empty() {return "";}
public String Html_doc_selected_get_active_or_selection() {return "";}
public boolean Html_window_print_preview() {return false;}
public void Html_invk_src_(GfoEvObj v) {}
public String Html_elem_atr_get_str(String elem_id, String atr_key) {
if (String_.Eq(atr_key, Gfui_html.Atr_value)) return String_.Replace(this.TextVal(), "\r\n", "\n");
else throw Err_.unhandled(atr_key);
}
public Object Html_elem_atr_get_obj(String elem_id, String atr_key) {
if (String_.Eq(atr_key, Gfui_html.Atr_value)) return String_.Replace(this.TextVal(), "\r\n", "\n");
else throw Err_.unhandled(atr_key);
}
public boolean Html_elem_atr_get_bool(String elem_id, String atr_key) {
if (String_.Eq(atr_key, Gfui_html.Atr_value)) return Bool_.parse_(String_.Replace(this.TextVal(), "\r\n", "\n"));
else throw Err_.unhandled(atr_key);
}
public boolean Html_elem_atr_set(String elem_id, String atr_key, String v) {
if (String_.Eq(atr_key, Gfui_html.Atr_value)) this.TextVal_set(v);
else throw Err_.unhandled(atr_key);
return true;
}
public boolean Html_elem_atr_set_append(String elem_id, String atr_key, String append) {
if (String_.Eq(atr_key, Gfui_html.Atr_value)) this.TextVal_set(this.TextVal() + append);
else throw Err_.unhandled(atr_key);
return true;
}
class Mem_html extends GxwTextMemo_lang implements Gxw_html { public void Html_invk_src_(GfoEvObj v) {}
public void Html_doc_html_load_by_mem(String s) {
// this.Core().ForeColor_set(plainText ? ColorAdp_.Black : ColorAdp_.Gray);
s = String_.Replace(s, "\r", "");
@@ -62,22 +30,6 @@ class Mem_html extends GxwTextMemo_lang implements Gxw_html { public String Htm
}
public byte Html_doc_html_load_tid() {return html_doc_html_load_tid;} private byte html_doc_html_load_tid;
public void Html_doc_html_load_tid_(byte v) {html_doc_html_load_tid = v;}
public String Html_active_atr_get_str(String atrKey, String or) { // NOTE: fuzzy way of finding current href; EX: <a href="a">b</a>
String txt = this.TextVal();
int pos = this.SelBgn();
String rv = ExtractAtr(atrKey, txt, pos);
return rv == null ? or : rv;
}
public void Html_doc_body_focus() {}
public void Html_doc_selection_focus_toggle() {}
public String Html_window_vpos() {return "";}
public boolean Html_window_vpos_(String v) {return true;}
public boolean Html_elem_focus(String v) {return true;}
public boolean Html_elem_img_update(String elem_id, String elem_src, int elem_width, int elem_height) {return true;}
public boolean Html_elem_delete(String elem_id) {return true;}
public boolean Html_elem_replace_html(String id, String html) {return true;}
public boolean Html_elem_append_above(String id, String html) {return true;}
public boolean Html_gallery_packed_exec() {return true;}
public String Html_js_eval_script(String script) {return "";}
String ExtractAtr(String key, String txt, int pos) {
int key_pos = String_.FindBwd(txt, key, pos); if (key_pos == String_.Find_none) return null;
@@ -86,45 +38,11 @@ class Mem_html extends GxwTextMemo_lang implements Gxw_html { public String Htm
if (!Int_.Between(pos, q0, q1)) return null; // current pos is not between nearest quotes
return String_.Mid(txt, q0 + 1, q1);
}
public boolean Html_doc_find(String elem_id, String find, boolean dir_fwd, boolean case_match, boolean wrap_find, boolean highlight_matches) {
// String txt = this.TextVal();
// int pos = this.SelBgn();
// int bgn = String_.FindFwd(txt, find, pos); if (bgn == String_.Find_none) return false;
// if (bgn == pos) {
// bgn = String_.FindFwd(txt, find, pos + 1);
// if (bgn == String_.Find_none) {
// bgn = String_.FindFwd(txt, find, 0);
// if (bgn == String_.Find_none) return false;
// }
// }
// this.SelBgn_set(bgn);
// this.SelLen_set(String_.Len(find));
// this.ScrollTillSelectionStartIsFirstLine();
txtFindMgr.Text_(this.TextVal());
int cur = this.SelBgn();
int[] ary = txtFindMgr.FindByUi(find, this.SelBgn(), this.SelLen(), false);
if (ary[0] != cur) {
this.SelBgn_set(ary[0]);
this.SelLen_set(ary[1]);
this.ScrollTillCaretIsVisible();
}
else {
ary = txtFindMgr.FindByUi(find, this.SelBgn() + 1, 0, false);
if (ary[0] != 0) {
this.SelBgn_set(ary[0]);
this.SelLen_set(ary[1]);
this.ScrollTillCaretIsVisible();
// this.ScrollTillSelectionStartIsFirstLine();
}
}
return true;
}
public boolean Html_elem_scroll_into_view(String id) {return false;}
public void Html_js_enabled_(boolean v) {}
public void Html_js_eval_proc(String proc, String... args) {}
public String Html_js_eval_proc_as_str(String proc, Object... args) {return "not implemented by mem_html";}
public boolean Html_js_eval_proc_as_bool(String proc, Object... args) {return false;}
public void Html_js_cbks_add(String js_func_name, GfoInvkAble invk) {}
public void Html_dispose() {}
private TxtFindMgr txtFindMgr = new TxtFindMgr();
public Mem_html() {
this.ctor_MsTextBoxMultiline_();
}

View File

@@ -64,7 +64,6 @@ public class Swt_kit implements Gfui_kit {
public void Kit_sync_cmd_add(Swt_gui_cmd cmd) {synchronized (thread_lock) {sync_cmd_list.Add(cmd);}}
public void Kit_sync_cmd_del(Swt_gui_cmd cmd) {synchronized (thread_lock) {sync_cmd_list.Del(cmd);}}
public GfoInvkAbleCmd Kit_term_cbk() {return term_cbk;} public void Kit_term_cbk_(GfoInvkAbleCmd v) {this.term_cbk = v;} private GfoInvkAbleCmd term_cbk = GfoInvkAbleCmd.Null;
public Gfui_html_cfg Html_cfg() {return html_cfg;} private final Gfui_html_cfg html_cfg = new Gfui_html_cfg();
public void Kit_init(Gfo_usr_dlg gui_wtr) {
this.gui_wtr = gui_wtr;
this.msg_wkr_stop = new Swt_msg_wkr_stop(this, gui_wtr);
@@ -231,12 +230,11 @@ public class Swt_kit implements Gfui_kit {
Cfg_set(type, Swt_kit.Cfg_Html_BrowserType, Cfg_Html_BrowserType_parse(val));
}
}
else if (String_.Eq(k, Invk_HtmlBox)) {return html_cfg;}
else if (String_.Eq(k, Invk_ask_file)) return this.New_dlg_file(Gfui_kit_.File_dlg_type_open, m.Args_getAt(0).Val_to_str_or_empty()).Ask();
else if (String_.Eq(k, Invk_shell_close)) shell.close();
return this;
}
public static final String Invk_Cfg_add = "Cfg_add", Invk_HtmlBox = "HtmlBox", Invk_ask_file = "ask_file"; // private or public?
public static final String Invk_Cfg_add = "Cfg_add", Invk_ask_file = "ask_file"; // private or public?
public static final String Invk_shell_close = "shell_close"; // public
public static final Swt_kit _ = new Swt_kit(); private Swt_kit() {} // singleton b/c of following line "In particular, some platforms which SWT supports will not allow more than one active display" (http://help.eclipse.org/indigo/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/Display.html)
public static final String Cfg_Html_BrowserType = "BrowserType";