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-08-30 22:57:59 -04:00
parent ed911e3de5
commit 5fc4eb41ec
579 changed files with 2460 additions and 1564 deletions

View File

@@ -34,11 +34,11 @@ class IptKeyChain implements IptArg {
}
key = sb.To_str();
}
public static IptKeyChain parse_(String raw) {
public static IptKeyChain parse(String raw) {
String[] itms = String_.Split(raw, ",");
IptArg[] rv = new IptArg[itms.length];
for (int i = 0; i < rv.length; i++)
rv[i] = IptArg_.parse_(String_.Trim(itms[i]));
rv[i] = IptArg_.parse(String_.Trim(itms[i]));
return new IptKeyChain(rv);
}
}

View File

@@ -20,7 +20,7 @@ public class IptArg_ {
public static final IptArg[] Ary_empty = new IptArg[0];
public static final IptArg Null = null;
public static final String Wildcard_key = "wildcard";
public static IptArg Wildcard = new IptKey(Int_.MaxValue, Wildcard_key);
public static IptArg Wildcard = new IptKey(Int_.Max_value, Wildcard_key);
public static boolean Is_null_or_none(IptArg arg) {return arg == Null || arg == IptKey_.None;}
public static IptArg[] Ary(IptArg... v) {return v;}
public static IptArg[] parse_ary_or_empty(String v) {
@@ -35,28 +35,28 @@ public class IptArg_ {
int args_len = args.length; if (args_len == 0) return Ary_empty;
IptArg[] rv = new IptArg[args_len];
for (int i = 0; i < args_len; i++)
rv[i] = parse_(String_.Trim(args[i]));
rv[i] = parse(String_.Trim(args[i]));
return rv;
}
public static IptArg parse_chain_(String raw) {return IptKeyChain.parse_(raw);}
public static IptArg parse_chain_(String raw) {return IptKeyChain.parse(raw);}
public static IptArg parse_or_none_(String raw) {
try {
return String_.Eq(raw, String_.Empty)
? IptKey_.None
: parse_(raw);
: parse(raw);
}
catch (Exception exc) { // as an "or" proc, handle errors; note that it may accept raw values from cfg files, so invalid input is possible; DATE:2014-06-04
Err_.Noop(exc);
return IptKey_.None;
}
}
public static IptArg parse_(String raw) {
if (String_.Has(raw, ",")) return IptKeyChain.parse_(raw);
public static IptArg parse(String raw) {
if (String_.Has(raw, ",")) return IptKeyChain.parse(raw);
String bgn = String_.GetStrBefore(raw, ".");
if (String_.Eq(bgn, "wheel")) return IptMouseWheel_.parse_(raw);
else if (String_.Eq(bgn, "mouse")) return IptMouseBtn_.parse_(raw);
else if (String_.Eq(bgn, "key")) return IptKey_.parse_(raw);
else return IptMacro._.parse_(raw);
if (String_.Eq(bgn, "wheel")) return IptMouseWheel_.parse(raw);
else if (String_.Eq(bgn, "mouse")) return IptMouseBtn_.parse(raw);
else if (String_.Eq(bgn, "key")) return IptKey_.parse(raw);
else return IptMacro._.parse(raw);
}
// NOTE: the following two methods should theoretically be interface methods, but since they are only used by two procs, they will be handled with if/else
@gplx.Internal protected static IptEventType EventType_default(IptArg arg) {
@@ -98,7 +98,7 @@ class IptMacro {
Reg("mod", "as", IptKey_.add_(IptKey_.Alt, IptKey_.Shift));
Reg("mod", "cas", IptKey_.add_(IptKey_.Ctrl, IptKey_.Alt, IptKey_.Shift));
}
public IptArg parse_(String raw) {
public IptArg parse(String raw) {
if (regy == null) Init();
String[] plusAry = String_.Split(raw, "+");
String[] dotAry = String_.Split(plusAry[0], ".");
@@ -108,7 +108,7 @@ class IptMacro {
IptKey rv = (IptKey)list.Get_by(end);
if (rv == null) throw parse_err(raw, "arg not found").Args_add("arg", end);
for (int i = 1; i < plusAry.length; i++) {
rv = rv.Add((IptKey)IptKey_.parse_(plusAry[i]));
rv = rv.Add((IptKey)IptKey_.parse(plusAry[i]));
}
return rv;
}

View File

@@ -19,7 +19,7 @@ package gplx.gfui; import gplx.*;
public class IptBnd_chkBox implements InjectAble, GfoEvObj {
public GfoEvMgr EvMgr() {if (evMgr == null) evMgr = GfoEvMgr.new_(this); return evMgr;} GfoEvMgr evMgr;
public void Inject(Object owner) {
chkBox = GfuiChkBox_.cast_(owner);
chkBox = GfuiChkBox_.cast(owner);
GfoEvMgr_.Sub(chkBox, "Check_end", this, setCmd);
GfoEvMgr_.SubSame(fwd, setEvt, this);
}
@@ -36,7 +36,7 @@ public class IptBnd_chkBox implements InjectAble, GfoEvObj {
GfoEvObj fwd; GfoInvkAble invkAble; String setCmd, setEvt, msgArg; GfuiChkBox chkBox;
public static IptBnd_chkBox new_(GfoEvObj src, String setCmd, String setEvt, String msgArg) {
IptBnd_chkBox rv = new IptBnd_chkBox();
rv.fwd = src; rv.invkAble = GfoInvkAble_.cast_(src); rv.setCmd = setCmd; rv.setEvt = setEvt; rv.msgArg = msgArg;
rv.fwd = src; rv.invkAble = GfoInvkAble_.cast(src); rv.setCmd = setCmd; rv.setEvt = setEvt; rv.msgArg = msgArg;
return rv;
}
}

View File

@@ -19,7 +19,7 @@ package gplx.gfui; import gplx.*;
public class IptBnd_txt_cmd implements InjectAble, GfoInvkAble, GfoEvObj {
public GfoEvMgr EvMgr() {if (evMgr == null) evMgr = GfoEvMgr.new_(this); return evMgr;} GfoEvMgr evMgr;
public void Inject(Object owner) {
txtBox = GfuiTextBox_.cast_(owner);
txtBox = GfuiTextBox_.cast(owner);
txtBox.TextAlignH_center_();
IptBnd_.cmd_to_(IptCfg_.Null, txtBox, this, TxtBox_exec, IptKey_.Enter);
GfoEvMgr_.SubSame(fwd, setEvt, this);
@@ -36,7 +36,7 @@ public class IptBnd_txt_cmd implements InjectAble, GfoInvkAble, GfoEvObj {
GfuiTextBox txtBox; GfoInvkAble src; GfoEvObj fwd; String setCmd, setEvt; ClassXtn cls;
public static IptBnd_txt_cmd new_(GfoEvObj fwd, String setCmd, String setEvt, ClassXtn cls) {
IptBnd_txt_cmd rv = new IptBnd_txt_cmd();
rv.fwd = fwd; rv.src = GfoInvkAble_.cast_(fwd);
rv.fwd = fwd; rv.src = GfoInvkAble_.cast(fwd);
rv.setCmd = setCmd; rv.setEvt = setEvt; rv.cls = cls;
return rv;
}

View File

@@ -29,7 +29,7 @@ public class IptBnd_txt_range implements InjectAble, GfoInvkAble, GfoEvObj {
return this;
} KeyVal[] list = null;
public void Inject(Object owner) {
txtBox = GfuiTextBox_.cast_(owner);
txtBox = GfuiTextBox_.cast(owner);
txtBox.TextAlignH_center_();
IptBnd_.cmd_to_(IptCfg_.Null, txtBox, this, Invk_dec, IptKey_.Down, IptMouseWheel_.Down);
IptBnd_.cmd_to_(IptCfg_.Null, txtBox, this, Invk_inc, IptKey_.Up, IptMouseWheel_.Up);
@@ -52,14 +52,14 @@ public class IptBnd_txt_range implements InjectAble, GfoInvkAble, GfoEvObj {
WhenEvtCmd(list[newVal].Key_as_obj());
}
Object UpdateCmd() {
int idx = Int_.MinValue;
int idx = Int_.Min_value;
String find = txtBox.Text();
for (int i = 0; i < list.length; i++) { // try to find .Text in list.Vals
if (String_.Eq(find, (String)list[i].Val())) idx = i;
}
if (idx == Int_.MinValue) { // try to find .Text in list.Keys
int key = Int_.parse_or_(txtBox.Text(), Int_.MinValue); if (key == Int_.MinValue) return GfoInvkAble_.Rv_unhandled;
idx = GetByKey(key); if (idx == Int_.MinValue) return GfoInvkAble_.Rv_unhandled;
if (idx == Int_.Min_value) { // try to find .Text in list.Keys
int key = Int_.parse_or(txtBox.Text(), Int_.Min_value); if (key == Int_.Min_value) return GfoInvkAble_.Rv_unhandled;
idx = GetByKey(key); if (idx == Int_.Min_value) return GfoInvkAble_.Rv_unhandled;
}
ExecCmd(setCmd, idx);
return GfoInvkAble_.Rv_handled;
@@ -71,7 +71,7 @@ public class IptBnd_txt_range implements InjectAble, GfoInvkAble, GfoEvObj {
WhenEvtCmd(curId);
}
void WhenEvtCmd(Object id) {
int idx = GetByKey(id); if (idx == Int_.MinValue) return;
int idx = GetByKey(id); if (idx == Int_.Min_value) return;
previewIdx = idx;
txtBox.Text_(list[idx].Val_to_str_or_empty());
}
@@ -84,7 +84,7 @@ public class IptBnd_txt_range implements InjectAble, GfoInvkAble, GfoEvObj {
for (int i = 0; i < list.length; i++) {
if (Object_.Eq(find, list[i].Key_as_obj())) return i;
}
return Int_.MinValue;
return Int_.Min_value;
}
public static IptBnd_txt_range new_(GfoEvObj propSrc) {
IptBnd_txt_range rv = new IptBnd_txt_range();

View File

@@ -19,7 +19,7 @@ package gplx.gfui; import gplx.*;
public class IptBnd_upDownRange implements InjectAble, GfoInvkAble, GfoEvObj {
public GfoEvMgr EvMgr() {if (evMgr == null) evMgr = GfoEvMgr.new_(this); return evMgr;} GfoEvMgr evMgr;
public void Inject(Object owner) {
txtBox = GfuiTextBox_.cast_(owner);
txtBox = GfuiTextBox_.cast(owner);
txtBox.TextAlignH_center_();
if (bndCfg == null) bndCfg = IptCfg_.new_("gplx.gfui.IptBnd_upDownRange");
IptBnd_.cmd_to_(bndCfg, txtBox, this, Invk_TxtBox_dec, IptKey_.Down, IptMouseWheel_.Down);
@@ -32,7 +32,7 @@ public class IptBnd_upDownRange implements InjectAble, GfoInvkAble, GfoEvObj {
else if (ctx.Match(k, Invk_TxtBox_inc)) ExecCmd(cmd, curVal + 1);
else if (ctx.Match(k, Invk_TxtBox_exec)) {
Object valObj = IntClassXtn._.ParseOrNull(txtBox.Text()); if (valObj == null) throw Err_.new_wo_type("invalid int", "text", txtBox.Text());
ExecCmd(doIt, Int_.cast_(valObj));
ExecCmd(doIt, Int_.cast(valObj));
}
else if (ctx.Match(k, evt)) WhenEvt(ctx, m);
else return GfoInvkAble_.Rv_unhandled;
@@ -51,7 +51,7 @@ public class IptBnd_upDownRange implements InjectAble, GfoInvkAble, GfoEvObj {
public static IptBnd_upDownRange new_(GfoEvObj fwd, String cmd, String evt, String arg) {return exec_(fwd, cmd, evt, cmd, arg);}
public static IptBnd_upDownRange exec_(GfoEvObj fwd, String cmd, String evt, String doIt, String arg) {
IptBnd_upDownRange rv = new IptBnd_upDownRange();
rv.fwd = fwd; rv.src = GfoInvkAble_.cast_(fwd);
rv.fwd = fwd; rv.src = GfoInvkAble_.cast(fwd);
rv.cmd = cmd; rv.evt = evt; rv.doIt = doIt; rv.arg = arg;
return rv;
}

View File

@@ -55,7 +55,7 @@ public class IptCfg_tst {
box.tst_SendKey(IptKey_.A, 0);
}
@Test public void Chained() {
cfg.run_GetOrDflt(box, key, IptKeyChain.parse_("key.ctrl+key.a,key.b"));
cfg.run_GetOrDflt(box, key, IptKeyChain.parse("key.ctrl+key.a,key.b"));
cfg.run_Set(key, IptKey_.A);
box.tst_SendKey(IptKey_.A, 1);
}

View File

@@ -36,7 +36,7 @@ public class IptEventData {
}
public static IptEventData as_(Object obj) {return obj instanceof IptEventData ? (IptEventData)obj : null;}
public static IptEventData cast_(Object obj) {try {return (IptEventData)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, IptEventData.class, obj);}}
public static IptEventData cast(Object obj) {try {return (IptEventData)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, IptEventData.class, obj);}}
@gplx.Internal protected static IptEventData new_(GfuiElem sender, IptEventType eventType, IptArg eventArg, IptEvtDataKey keyData, IptEvtDataMouse mouseData) {return new_(sender, eventType, eventArg, keyData, IptEvtDataKeyHeld.Null, mouseData);}
@gplx.Internal protected static IptEventData new_(GfuiElem sender, IptEventType eventType, IptArg eventArg, IptEvtDataKey keyData, IptEvtDataKeyHeld keyPressData, IptEvtDataMouse mouseData) {
IptEventData rv = new IptEventData();
@@ -45,5 +45,5 @@ public class IptEventData {
rv.keyData = keyData; rv.keyPressData = keyPressData; rv.mouseData = mouseData;
return rv;
} IptEventData() {}
public static IptEventData ctx_(GfsCtx ctx, GfoMsg m) {return IptEventData.cast_(m.CastObj("iptData"));}
public static IptEventData ctx_(GfsCtx ctx, GfoMsg m) {return IptEventData.cast(m.CastObj("iptData"));}
}

View File

@@ -21,7 +21,7 @@ public class IptEvtDataKey {
public boolean Handled() {return handled;} public void Handled_set(boolean v) {handled = v;} private boolean handled;
public static IptEvtDataKey as_(Object obj) {return obj instanceof IptEvtDataKey ? (IptEvtDataKey)obj : null;}
public static IptEvtDataKey cast_(Object obj) {try {return (IptEvtDataKey)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, IptEvtDataKey.class, obj);}}
public static IptEvtDataKey cast(Object obj) {try {return (IptEvtDataKey)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, IptEvtDataKey.class, obj);}}
@gplx.Internal protected static final IptEvtDataKey Null = new_(IptKey_.None);
@gplx.Internal protected static IptEvtDataKey test_(IptKey keyArg) {return new_(keyArg);}
@gplx.Internal protected static IptEvtDataKey int_(int val) {

View File

@@ -21,7 +21,7 @@ public class IptEvtDataKeyHeld {
public boolean Handled() {return handled;} public void Handled_set(boolean v) {handled = v;} private boolean handled;
public static IptEvtDataKeyHeld as_(Object obj) {return obj instanceof IptEvtDataKeyHeld ? (IptEvtDataKeyHeld)obj : null;}
public static IptEvtDataKeyHeld cast_(Object obj) {try {return (IptEvtDataKeyHeld)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, IptEvtDataKeyHeld.class, obj);}}
public static IptEvtDataKeyHeld cast(Object obj) {try {return (IptEvtDataKeyHeld)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, IptEvtDataKeyHeld.class, obj);}}
@gplx.Internal protected static final IptEvtDataKeyHeld Null = char_((char)0);
@gplx.Internal protected static IptEvtDataKeyHeld char_(char c) {
IptEvtDataKeyHeld rv = new IptEvtDataKeyHeld();

View File

@@ -22,7 +22,7 @@ public class IptEvtDataMouse {
public PointAdp Pos() {return location;} PointAdp location;
public static IptEvtDataMouse as_(Object obj) {return obj instanceof IptEvtDataMouse ? (IptEvtDataMouse)obj : null;}
public static IptEvtDataMouse cast_(Object obj) {try {return (IptEvtDataMouse)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, IptEvtDataMouse.class, obj);}}
public static IptEvtDataMouse cast(Object obj) {try {return (IptEvtDataMouse)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, IptEvtDataMouse.class, obj);}}
@gplx.Internal protected static final IptEvtDataMouse Null = IptEvtDataMouse.new_(IptMouseBtn_.None, IptMouseWheel_.None, 0, 0);
public static IptEvtDataMouse new_(IptMouseBtn button, IptMouseWheel wheel, int x, int y) {
IptEvtDataMouse rv = new IptEvtDataMouse();

View File

@@ -23,7 +23,7 @@ public class IptKey_ {
public static IptKey[] Ary(IptKey... ary) {return ary;}
public static final IptKey[] Ary_empty = new IptKey[0];
public static IptKey as_(Object obj) {return obj instanceof IptKey ? (IptKey)obj : null;}
public static IptKey cast_(Object obj) {try {return (IptKey)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, IptKey.class, obj);}}
public static IptKey cast(Object obj) {try {return (IptKey)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, IptKey.class, obj);}}
public static IptKey add_(IptKey... ary) {
if (ary.length == 0) return IptKey_.None;
int newVal = ary[0].Val();
@@ -35,10 +35,10 @@ public class IptKey_ {
IptKey rv = (IptKey)enm_mgr.Get(val);
return (rv == null) ? new_(val, "key_" + Int_.Xto_str(val)) : rv;
}
public static IptKey parse_(String raw) {return get_or_new_(enm_mgr.GetVal(raw));}
public static IptKey parse(String raw) {return get_or_new_(enm_mgr.GetVal(raw));}
public static IptKey rdr_or_(DataRdr rdr, String key, IptKey or) {
String val = rdr.ReadStrOr(key, ""); // NOTE: "" cannot be null, b/c nullRdr returns String.empty
return (String_.Eq(val, "")) ? or : parse_(val);
return (String_.Eq(val, "")) ? or : parse(val);
}
public static List_adp printableKeys2_(IptKey[] add, IptKey[] del) {
List_adp list = List_adp_.new_();

View File

@@ -25,7 +25,7 @@ public class IptKey__tst {
@Test public void To_str__numeric() {
fxt.Test_to_str(16777296, "key.#16777296");
}
@Test public void parse_() {
@Test public void parse() {
fxt.Test_parse("key.#10", 10);
}
}
@@ -34,6 +34,6 @@ class IptKey__fxt {
Tfds.Eq(expd, IptKey_.To_str(keycode));
}
public void Test_parse(String raw, int keycode) {
Tfds.Eq(keycode, IptKey_.parse_(raw).Val());
Tfds.Eq(keycode, IptKey_.parse(raw).Val());
}
}

View File

@@ -33,7 +33,7 @@ public class IptMouseBtn_ {
, X1 = new IptMouseBtn(Tid_x1 , "mouse.x1")
, X2 = new IptMouseBtn(Tid_x2 , "mouse.x2")
;
public static IptMouseBtn parse_(String raw) {
public static IptMouseBtn parse(String raw) {
if (String_.Eq(raw, None.Key())) return None;
else if (String_.Eq(raw, Left.Key())) return Left;
else if (String_.Eq(raw, Right.Key())) return Right;

View File

@@ -21,14 +21,14 @@ public class IptMouseWheel_ {
None = new IptMouseWheel("wheel.none")
, Up = new IptMouseWheel("wheel.up")
, Down = new IptMouseWheel("wheel.down");
public static IptMouseWheel parse_(String raw) {
public static IptMouseWheel parse(String raw) {
if (String_.Eq(raw, None.Key())) return None;
else if (String_.Eq(raw, Up.Key())) return Up;
else if (String_.Eq(raw, Down.Key())) return Down;
else throw Err_.new_parse_type(IptMouseWheel.class, raw);
}
@gplx.Internal protected static IptMouseWheel api_(Object obj) {
int delta = Int_.cast_(obj);
int delta = Int_.cast(obj);
if (delta > 0) return Up;
else if (delta < 0) return Down;
else return None;