opt: use my code completion implement instead CodeMirror's
This commit is contained in:
@@ -1,306 +0,0 @@
|
||||
function autoJsGlobalScope(){
|
||||
function FUNCTION(url){
|
||||
var f = function(){};
|
||||
f.__url__ = url;
|
||||
return f;
|
||||
}
|
||||
function VARIABLE(url){
|
||||
return {
|
||||
__url__: url
|
||||
}
|
||||
}
|
||||
var app = {
|
||||
"uninstall": FUNCTION("app.html#app_app_uninstall_packagename"),
|
||||
"viewFile": FUNCTION("app.html#app_app_viewfile_path"),
|
||||
"editFile": FUNCTION("app.html#app_app_editfile_path"),
|
||||
"openUrl": FUNCTION("app.html#app_app_openurl_url"),
|
||||
"launchPackage": FUNCTION("app.html#app_app_takephoto_path"),
|
||||
"launch": FUNCTION("globals.html#globals_launchpackage_packagename"),
|
||||
"launchApp": FUNCTION("globals.html#globals_launchapp_appname"),
|
||||
"getPackageName": FUNCTION("globals.html#globals_getpackagename_appname"),
|
||||
"openAppSetting": FUNCTION("globals.html#globals_getappname_packagename"),
|
||||
__url__: "app.html"
|
||||
};
|
||||
var automator = {
|
||||
"click": FUNCTION("widgets-based-automation.html#widgets_based_automation_click_text_i"),
|
||||
"longClick": FUNCTION("widgets-based-automation.html#widgets_based_automation_longclick_text_i"),
|
||||
"press": FUNCTION(),
|
||||
"swipe": FUNCTION(),
|
||||
"gesture": FUNCTION(),
|
||||
"gestures": FUNCTION(),
|
||||
"gestureAsync": FUNCTION(),
|
||||
"gesturesAsync": FUNCTION(),
|
||||
"scrollDown": FUNCTION("widgets-based-automation.html#widgets_based_automation_scrollup_i"),
|
||||
"scrollUp": FUNCTION("widgets-based-automation.html#widgets_based_automation_scrollup_i"),
|
||||
"input": FUNCTION("widgets-based-automation.html#widgets_based_automation_input_i_text"),
|
||||
"setText": FUNCTION("widgets-based-automation.html#widgets_based_automation_settext_i_text"),
|
||||
__url__: "widgets-based-automation.html"
|
||||
};
|
||||
var console = {
|
||||
"show": FUNCTION("console.html#console_console_show"),
|
||||
"hide": FUNCTION(),
|
||||
"clear": FUNCTION("console.html#console_console_clear"),
|
||||
"verbose": FUNCTION("console.html#console_console_verbose_data_args"),
|
||||
"info": FUNCTION("console.html#console_console_info_data_args"),
|
||||
"log": FUNCTION("console.html#console_console_log_data_args"),
|
||||
"warn": FUNCTION("console.html#console_console_warn_data_args"),
|
||||
"error": FUNCTION("console.html#console_console_error_data_args"),
|
||||
"assert": FUNCTION("console.html#console_console_assert_value_message"),
|
||||
__url__: "console.html"
|
||||
};
|
||||
var dialogs = {
|
||||
"select": FUNCTION(),
|
||||
"singleChoice": FUNCTION(),
|
||||
"multiChoice": FUNCTION(),
|
||||
"rawInput": FUNCTION(),
|
||||
"input": FUNCTION(),
|
||||
"alert": FUNCTION(),
|
||||
"confirm": FUNCTION(),
|
||||
"prompt": FUNCTION()
|
||||
};
|
||||
var images = {
|
||||
"saveImage": FUNCTION("images.html#images_images_saveimage_image_path"),
|
||||
"pixel": FUNCTION("images.html#images_images_pixel_image_x_y"),
|
||||
"read": FUNCTION(),
|
||||
"requestScreenCapture": FUNCTION("images.html#images_requestscreencapture_width_height"),
|
||||
"captureScreen": FUNCTION("images.html#images_capturescreen"),
|
||||
"findColor": FUNCTION("images.html#images_images_findcolor_image_color_options"),
|
||||
"findColorInRegion": FUNCTION("images.html#images_images_findcolorinregion_img_color_x_y_width_height_threads_algorithm_threshold"),
|
||||
"findColorEquals": FUNCTION("images.html#images_images_findcolorequals_img_color_x_y_width_height_threads"),
|
||||
__url__: "images.html"
|
||||
};
|
||||
var colors = {
|
||||
"red": FUNCTION("images.html#images_colors_red_color"),
|
||||
"green": FUNCTION("images.html#images_colors_green_color"),
|
||||
"blue": FUNCTION("images.html#images_colors_blue_color"),
|
||||
"alpha": FUNCTION("images.html#images_colors_alpha_color"),
|
||||
"toString": FUNCTION("images.html#images_colors_tostring_color"),
|
||||
"rgb": FUNCTION("images.html#images_colors_rgb_red_green_blue"),
|
||||
"argb": FUNCTION("images.html#images_colors_argb_alpha_red_green_blue"),
|
||||
__url__: "images.html#images_colors"
|
||||
};
|
||||
var events = {
|
||||
"emitter": FUNCTION("events.html#events_events_emitter"),
|
||||
"observeKey": FUNCTION("events.html#events_events_observekey"),
|
||||
"observeTouch": FUNCTION("events.html#events_events_observetouch"),
|
||||
"observeNotification": FUNCTION("events.html#events_obversenotification"),
|
||||
"onKeyDown": FUNCTION("events.html#events_events_onkeydown_keyname_listener"),
|
||||
"onKeyUp": FUNCTION("events.html#events_events_onkeyup_keyname_listener"),
|
||||
"onceKeyDown": FUNCTION("events.html#events_events_oncekeydown_keyname_listener"),
|
||||
"onceKeyUp": FUNCTION("events.html#events_events_oncekeyup_keyname_listener"),
|
||||
"onToast": FUNCTION("events.html#events_toast"),
|
||||
"onNotification": FUNCTION("events.html#events_notification"),
|
||||
"removeAllKeyDownListeners": FUNCTION("events.html#events_events_removeallkeydownlisteners_keyname"),
|
||||
"removeAllKeyUpListeners": FUNCTION("events.html#events_events_removeallkeyuplisteners_keyname"),
|
||||
"onTouch": FUNCTION("events.html#events_events_ontouch_listener"),
|
||||
"removeAllTouchListeners": FUNCTION("events.html#events_events_removealltouchlisteners"),
|
||||
"getTouchEventTimeout": FUNCTION("events.html#events_events_gettoucheventtimeout"),
|
||||
"setTouchEventTimeout": FUNCTION("events.html#events_events_settoucheventtimeout_timeout"),
|
||||
"on": FUNCTION("events.html#events_eventemitter_on_eventname_listener"),
|
||||
"once": FUNCTION("events.html#events_eventemitter_once_eventname_listener"),
|
||||
"emit": FUNCTION("events.html#events_eventemitter_emit_eventname_args"),
|
||||
"getListeners": FUNCTION(),
|
||||
"addListener": FUNCTION("events.html#events_eventemitter_addlistener_eventname_listener"),
|
||||
"eventNames": FUNCTION("events.html#events_eventemitter_eventnames"),
|
||||
"listenerCount": FUNCTION("events.html#events_eventemitter_listenercount_eventname"),
|
||||
"listeners": FUNCTION("events.html#events_eventemitter_listeners_eventname"),
|
||||
"prependListener": FUNCTION("events.html#events_eventemitter_prependlistener_eventname_listener"),
|
||||
"prependOnceListener": FUNCTION("events.html#events_eventemitter_prependoncelistener_eventname_listener"),
|
||||
"removeAllListeners": FUNCTION("events.html#events_eventemitter_removealllisteners_eventname"),
|
||||
"removeListener": FUNCTION("events.html#events_eventemitter_removelistener_eventname_listener"),
|
||||
"setMaxListeners": FUNCTION("events.html#events_eventemitter_setmaxlisteners_n"),
|
||||
"getMaxListeners": FUNCTION("events.html#events_eventemitter_getmaxlisteners"),
|
||||
"defaultMaxListeners": FUNCTION("events.html#events_eventemitter_defaultmaxlisteners"),
|
||||
__url__: "events.html"
|
||||
};
|
||||
var files = {
|
||||
"open": FUNCTION(),
|
||||
"isFile": FUNCTION("files.html#files_files_isfile_path"),
|
||||
"isDir": FUNCTION("files.html#files_files_isdir_path"),
|
||||
"isEmptyDir": FUNCTION("files.html#files_files_isemptydir_path"),
|
||||
"join": FUNCTION("files.html#files_files_join_parent_child"),
|
||||
"create": FUNCTION("files.html#files_files_create_path"),
|
||||
"createIfNotExists": FUNCTION("files.html#files_files_createifnotexists_path"),
|
||||
"exists": FUNCTION("files.html#files_files_exists_path"),
|
||||
"ensureDir": FUNCTION("files.html#files_files_ensuredir_path"),
|
||||
"read": FUNCTION("files.html#files_files_read_path_encoding_utf_8"),
|
||||
"write": FUNCTION("files.html#files_files_write_path_text_encoding_utf_8"),
|
||||
"copy": FUNCTION("files.html#files_files_copy_frompath_topath"),
|
||||
"move": FUNCTION("files.html#files_files_move_frompath_topath"),
|
||||
"rename": FUNCTION("files.html#files_files_rename_path_newname"),
|
||||
"renameWithoutExtension": FUNCTION("files.html#files_files_renamewithoutextension_path_newname"),
|
||||
"getName": FUNCTION("files.html#files_files_getname_path"),
|
||||
"getExtension": FUNCTION("files.html#files_files_getextension_path"),
|
||||
"getNameWithoutExtension": FUNCTION("files.html#files_files_getnamewithoutextension_path"),
|
||||
"remove": FUNCTION("files.html#files_files_remove_path"),
|
||||
"removeDir": FUNCTION("files.html#files_files_removedir_path"),
|
||||
"getSdcardPath": FUNCTION("files.html#files_files_getsdcardpath"),
|
||||
"listDir": FUNCTION("files.html#files_files_listdir_path_filter"),
|
||||
__url__: "files.html"
|
||||
};
|
||||
var timers = {
|
||||
"setTimeout": FUNCTION("timers.html#timers_settimeout_callback_delay_args"),
|
||||
"clearTimeout": FUNCTION("timers.html#timers_cleartimeout_id"),
|
||||
"setInterval": FUNCTION("timers.html#timers_setinterval_callback_delay_args"),
|
||||
"clearInterval": FUNCTION("timers.html#timers_clearinterval_id"),
|
||||
"setImmediate": FUNCTION("timers.html#timers_setimmediate_callback_args"),
|
||||
"clearImmediate": FUNCTION("timers.html#timers_clearimmediate_id")
|
||||
};
|
||||
var globals = {
|
||||
"app": app,
|
||||
"automator": automator,
|
||||
"console": console,
|
||||
"dialogs": dialogs,
|
||||
"events": events,
|
||||
"images": images,
|
||||
"files": files,
|
||||
"timers": timers,
|
||||
"ui": {},
|
||||
|
||||
"click": FUNCTION(),
|
||||
"longClick": FUNCTION(),
|
||||
"press": FUNCTION(),
|
||||
"swipe": FUNCTION(),
|
||||
"gesture": FUNCTION(),
|
||||
"gestures": FUNCTION(),
|
||||
"gestureAsync": FUNCTION(),
|
||||
"gesturesAsync": FUNCTION(),
|
||||
"scrollDown": FUNCTION(),
|
||||
"scrollUp": FUNCTION(),
|
||||
"input": FUNCTION(),
|
||||
"setText": FUNCTION(),
|
||||
|
||||
"print": FUNCTION(),
|
||||
"log": FUNCTION(),
|
||||
"err": FUNCTION(),
|
||||
"openConsole": FUNCTION(),
|
||||
"clearConsole": FUNCTION(),
|
||||
|
||||
"rawInput": FUNCTION(),
|
||||
"input": FUNCTION(),
|
||||
"alert": FUNCTION(),
|
||||
"confirm": FUNCTION(),
|
||||
"prompt": FUNCTION(),
|
||||
|
||||
"requestScreenCapture": FUNCTION(),
|
||||
"captureScreen": FUNCTION(),
|
||||
"findColor": FUNCTION(),
|
||||
"findColorInRegion": FUNCTION(),
|
||||
"findColorEquals": FUNCTION(),
|
||||
|
||||
"open": FUNCTION(),
|
||||
|
||||
"id": FUNCTION(),
|
||||
"idContains": FUNCTION(),
|
||||
"idStartsWith": FUNCTION(),
|
||||
"idEndsWith": FUNCTION(),
|
||||
"idMatches": FUNCTION(),
|
||||
"text": FUNCTION(),
|
||||
"textContains": FUNCTION(),
|
||||
"textStartsWith": FUNCTION(),
|
||||
"textEndsWith": FUNCTION(),
|
||||
"textMatches": FUNCTION(),
|
||||
"desc": FUNCTION(),
|
||||
"descContains": FUNCTION(),
|
||||
"descStartsWith": FUNCTION(),
|
||||
"descEndsWith": FUNCTION(),
|
||||
"descMatches": FUNCTION(),
|
||||
"className": FUNCTION(),
|
||||
"classNameContains": FUNCTION(),
|
||||
"classNameStartsWith": FUNCTION(),
|
||||
"classNameEndsWith": FUNCTION(),
|
||||
"classNameMatches": FUNCTION(),
|
||||
"packageName": FUNCTION(),
|
||||
"packageNameContains": FUNCTION(),
|
||||
"packageNameStartsWith": FUNCTION(),
|
||||
"packageNameEndsWith": FUNCTION(),
|
||||
"packageNameMatches": FUNCTION(),
|
||||
"bounds": FUNCTION(),
|
||||
"boundsInside": FUNCTION(),
|
||||
"boundsContains": FUNCTION(),
|
||||
"drawingOrder": FUNCTION(),
|
||||
"checkable": FUNCTION(),
|
||||
"checked": FUNCTION(),
|
||||
"focusable": FUNCTION(),
|
||||
"focused": FUNCTION(),
|
||||
"visibleToUser": FUNCTION(),
|
||||
"accessibilityFocused": FUNCTION(),
|
||||
"selected": FUNCTION(),
|
||||
"clickable": FUNCTION(),
|
||||
"longClickable": FUNCTION(),
|
||||
"enabled": FUNCTION(),
|
||||
"password": FUNCTION(),
|
||||
"scrollable": FUNCTION(),
|
||||
"editable": FUNCTION(),
|
||||
"contentInvalid": FUNCTION(),
|
||||
"contextClickable": FUNCTION(),
|
||||
"multiLine": FUNCTION(),
|
||||
"dismissable": FUNCTION(),
|
||||
"checkable": FUNCTION(),
|
||||
"checked": FUNCTION(),
|
||||
"focusable": FUNCTION(),
|
||||
"focused": FUNCTION(),
|
||||
"visibleToUser": FUNCTION(),
|
||||
"accessibilityFocused": FUNCTION(),
|
||||
"selected": FUNCTION(),
|
||||
"clickable": FUNCTION(),
|
||||
"longClickable": FUNCTION(),
|
||||
"enabled": FUNCTION(),
|
||||
"password": FUNCTION(),
|
||||
"scrollable": FUNCTION(),
|
||||
"editable": FUNCTION(),
|
||||
"contentInvalid": FUNCTION(),
|
||||
"contextClickable": FUNCTION(),
|
||||
"multiLine": FUNCTION(),
|
||||
"dismissable": FUNCTION(),
|
||||
|
||||
"SetScreenMetrics": FUNCTION(),
|
||||
"Tap": FUNCTION(),
|
||||
"Swipe": FUNCTION(),
|
||||
"Screencap": FUNCTION(),
|
||||
"KeyCode": FUNCTION(),
|
||||
"Home": FUNCTION(),
|
||||
"Back": FUNCTION(),
|
||||
"Power": FUNCTION(),
|
||||
"Up": FUNCTION(),
|
||||
"Down": FUNCTION(),
|
||||
"Left": FUNCTION(),
|
||||
"Right": FUNCTION(),
|
||||
"OK": FUNCTION(),
|
||||
"VolumeUp": FUNCTION(),
|
||||
"VolumeDown": FUNCTION(),
|
||||
"Menu": FUNCTION(),
|
||||
"Camera": FUNCTION(),
|
||||
"Text": FUNCTION(),
|
||||
|
||||
"loop": FUNCTION(),
|
||||
"setTimeout": FUNCTION(),
|
||||
"clearTimeout": FUNCTION(),
|
||||
"setInterval": FUNCTION(),
|
||||
"clearInterval": FUNCTION(),
|
||||
"setImmediate": FUNCTION(),
|
||||
"clearImmediate": FUNCTION(),
|
||||
|
||||
"newInjectableWebClient": FUNCTION(),
|
||||
"newInjectableWebView": FUNCTION(),
|
||||
|
||||
"toast": FUNCTION(),
|
||||
"toastLog": FUNCTION(),
|
||||
"sleep": FUNCTION(),
|
||||
"isStopped": FUNCTION(),
|
||||
"notStopped": FUNCTION(),
|
||||
"exit": FUNCTION(),
|
||||
"setClip": FUNCTION(),
|
||||
"getClip": FUNCTION(),
|
||||
"currentPackage": FUNCTION(),
|
||||
"currentActivity": FUNCTION(),
|
||||
"waitForActivity": FUNCTION(),
|
||||
"waitForPackage": FUNCTION(),
|
||||
"setScreenMetrics": FUNCTION(),
|
||||
|
||||
"context": {},
|
||||
"activity": {}
|
||||
};
|
||||
return globals;
|
||||
}
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
var Pos = CodeMirror.Pos;
|
||||
|
||||
function forEach(arr, f) {
|
||||
for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
|
||||
}
|
||||
|
||||
function arrayContains(arr, item) {
|
||||
if (!Array.prototype.indexOf) {
|
||||
var i = arr.length;
|
||||
while (i--) {
|
||||
if (arr[i] === item) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return arr.indexOf(item) != -1;
|
||||
}
|
||||
|
||||
function scriptHint(editor, keywords, getToken, options) {
|
||||
// Find the token at the cursor
|
||||
var cur = editor.getCursor(), token = getToken(editor, cur);
|
||||
if (/\b(?:string|comment)\b/.test(token.type)) return;
|
||||
token.state = CodeMirror.innerMode(editor.getMode(), token.state).state;
|
||||
|
||||
// If it's not a 'word-style' token, ignore the token.
|
||||
if (!/^[\w$_]*$/.test(token.string)) {
|
||||
token = {start: cur.ch, end: cur.ch, string: "", state: token.state,
|
||||
type: token.string == "." ? "property" : null};
|
||||
} else if (token.end > cur.ch) {
|
||||
token.end = cur.ch;
|
||||
token.string = token.string.slice(0, cur.ch - token.start);
|
||||
}
|
||||
|
||||
var tprop = token;
|
||||
// If it is a property, find out what it is a property of.
|
||||
while (tprop.type == "property") {
|
||||
tprop = getToken(editor, Pos(cur.line, tprop.start));
|
||||
if (tprop.string != ".") return;
|
||||
tprop = getToken(editor, Pos(cur.line, tprop.start));
|
||||
if (!context) var context = [];
|
||||
context.push(tprop);
|
||||
}
|
||||
var c = getCompletions(token, context, keywords, options);
|
||||
return {list: c.list,
|
||||
urls: c.urls,
|
||||
from: Pos(cur.line, token.start),
|
||||
to: Pos(cur.line, token.end)};
|
||||
}
|
||||
|
||||
function javascriptHint(editor, options) {
|
||||
return scriptHint(editor, javascriptKeywords,
|
||||
function (e, cur) {return e.getTokenAt(cur);},
|
||||
options);
|
||||
};
|
||||
CodeMirror.registerHelper("hint", "javascript", javascriptHint);
|
||||
|
||||
function getCoffeeScriptToken(editor, cur) {
|
||||
// This getToken, it is for coffeescript, imitates the behavior of
|
||||
// getTokenAt method in javascript.js, that is, returning "property"
|
||||
// type and treat "." as indepenent token.
|
||||
var token = editor.getTokenAt(cur);
|
||||
if (cur.ch == token.start + 1 && token.string.charAt(0) == '.') {
|
||||
token.end = token.start;
|
||||
token.string = '.';
|
||||
token.type = "property";
|
||||
}
|
||||
else if (/^\.[\w$_]*$/.test(token.string)) {
|
||||
token.type = "property";
|
||||
token.start++;
|
||||
token.string = token.string.replace(/\./, '');
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
function coffeescriptHint(editor, options) {
|
||||
return scriptHint(editor, coffeescriptKeywords, getCoffeeScriptToken, options);
|
||||
}
|
||||
CodeMirror.registerHelper("hint", "coffeescript", coffeescriptHint);
|
||||
|
||||
var stringProps = ("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight " +
|
||||
"toUpperCase toLowerCase split concat match replace search").split(" ");
|
||||
var arrayProps = ("length concat join splice push pop shift unshift slice reverse sort indexOf " +
|
||||
"lastIndexOf every some filter forEach map reduce reduceRight ").split(" ");
|
||||
var funcProps = "prototype apply call bind".split(" ");
|
||||
var javascriptKeywords = ("break case catch continue debugger default delete do else false finally for function " +
|
||||
"if in instanceof new null return switch throw true try typeof var void while with").split(" ");
|
||||
var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
|
||||
"if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");
|
||||
|
||||
function forAllProps(obj, callback) {
|
||||
for (var name in obj) {
|
||||
var value = obj[name];
|
||||
callback(name, value.__url__);
|
||||
}
|
||||
return;
|
||||
//unreachable
|
||||
if (!Object.getOwnPropertyNames || !Object.getPrototypeOf) {
|
||||
for (var name in obj) callback(name)
|
||||
} else {
|
||||
for (var o = obj; o; o = Object.getPrototypeOf(o))
|
||||
Object.getOwnPropertyNames(o).forEach(callback)
|
||||
}
|
||||
}
|
||||
|
||||
function getCompletions(token, context, keywords, options) {
|
||||
var found = [], start = token.string, global = options && options.globalScope || window;
|
||||
var urls = [];
|
||||
function maybeAdd(str, url) {
|
||||
if (str.lastIndexOf(start, 0) == 0 && !arrayContains(found, str)) {
|
||||
found.push(str);
|
||||
urls.push(url);
|
||||
}
|
||||
}
|
||||
function gatherCompletions(obj) {
|
||||
if (typeof obj == "string") forEach(stringProps, maybeAdd);
|
||||
else if (obj instanceof Array) forEach(arrayProps, maybeAdd);
|
||||
else if (obj instanceof Function) forEach(funcProps, maybeAdd);
|
||||
forAllProps(obj, maybeAdd)
|
||||
}
|
||||
|
||||
if (context && context.length) {
|
||||
// If this is a property, see if it belongs to some object we can
|
||||
// find in the current environment.
|
||||
var obj = context.pop(), base;
|
||||
if (obj.type && obj.type.indexOf("variable") === 0) {
|
||||
if (options && options.additionalContext)
|
||||
base = options.additionalContext[obj.string];
|
||||
if (!options || options.useGlobalScope !== false)
|
||||
base = base || global[obj.string];
|
||||
} else if (obj.type == "string") {
|
||||
base = "";
|
||||
} else if (obj.type == "atom") {
|
||||
base = 1;
|
||||
} else if (obj.type == "function") {
|
||||
if (global.jQuery != null && (obj.string == '$' || obj.string == 'jQuery') &&
|
||||
(typeof global.jQuery == 'function'))
|
||||
base = global.jQuery();
|
||||
else if (global._ != null && (obj.string == '_') && (typeof global._ == 'function'))
|
||||
base = global._();
|
||||
}
|
||||
while (base != null && context.length)
|
||||
base = base[context.pop().string];
|
||||
if (base != null) gatherCompletions(base);
|
||||
} else {
|
||||
// If not, just look in the global object and any local scope
|
||||
// (reading into JS mode internals to get at the local and global variables)
|
||||
for (var v = token.state.localVars; v; v = v.next) maybeAdd(v.name);
|
||||
for (var v = token.state.globalVars; v; v = v.next) maybeAdd(v.name);
|
||||
if (!options || options.useGlobalScope !== false)
|
||||
gatherCompletions(global);
|
||||
forEach(keywords, maybeAdd);
|
||||
}
|
||||
return {
|
||||
list: found,
|
||||
urls: urls
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
@@ -28,13 +28,6 @@
|
||||
<script src="codemirror/addon/fold/indent-fold.js"></script>
|
||||
<script src="codemirror/addon/fold/comment-fold.js"></script>
|
||||
|
||||
|
||||
<!-- 代码补全 -->
|
||||
<link rel="stylesheet" href="codemirror/addon/hint/show-hint.css">
|
||||
<script src="codemirror/addon/autojs/autojs-hint.js"></script>
|
||||
<script src="codemirror/addon/hint/anyword-hint.js"></script>
|
||||
<script src="codemirror/addon/hint/show-hint.js"></script>
|
||||
|
||||
<!-- 代码格式化 -->
|
||||
<script type="text/javascript" src="beautify/beautify.min.js"></script>
|
||||
|
||||
@@ -43,7 +36,6 @@
|
||||
<script type="text/javascript" src="codemirror/addon/search/searchcursor.js"></script>
|
||||
|
||||
<!-- Auto.js -->
|
||||
<script type="text/javascript" src="codemirror/addon/autojs/autojs-global-scope.js"></script>
|
||||
<script type="text/javascript" src="codemirror/addon/autojs/autojs.js"></script>
|
||||
|
||||
<head>
|
||||
|
||||
@@ -1,56 +1,4 @@
|
||||
var ExcludedIntelliSenseTriggerKeys =
|
||||
{
|
||||
"8": "backspace",
|
||||
"9": "tab",
|
||||
"13": "enter",
|
||||
"16": "shift",
|
||||
"17": "ctrl",
|
||||
"18": "alt",
|
||||
"19": "pause",
|
||||
"20": "capslock",
|
||||
"27": "escape",
|
||||
"32": "space",
|
||||
"33": "pageup",
|
||||
"34": "pagedown",
|
||||
"35": "end",
|
||||
"36": "home",
|
||||
"37": "left",
|
||||
"38": "up",
|
||||
"39": "right",
|
||||
"40": "down",
|
||||
"45": "insert",
|
||||
"46": "delete",
|
||||
"91": "left window key",
|
||||
"92": "right window key",
|
||||
"93": "select",
|
||||
"107": "add",
|
||||
"109": "subtract",
|
||||
"110": "decimal point",
|
||||
"111": "divide",
|
||||
"112": "f1",
|
||||
"113": "f2",
|
||||
"114": "f3",
|
||||
"115": "f4",
|
||||
"116": "f5",
|
||||
"117": "f6",
|
||||
"118": "f7",
|
||||
"119": "f8",
|
||||
"120": "f9",
|
||||
"121": "f10",
|
||||
"122": "f11",
|
||||
"123": "f12",
|
||||
"144": "numlock",
|
||||
"145": "scrolllock",
|
||||
"186": "semicolon",
|
||||
"187": "equalsign",
|
||||
"188": "comma",
|
||||
"189": "dash",
|
||||
"190": "period",
|
||||
"191": "slash",
|
||||
"192": "graveaccent",
|
||||
"220": "backslash",
|
||||
"222": "quote"
|
||||
};
|
||||
|
||||
var editor = CodeMirror(document.body, {
|
||||
lineNumbers: true, // 显示行数
|
||||
indentUnit: 4, // 缩进单位为4
|
||||
@@ -63,26 +11,16 @@ var editor = CodeMirror(document.body, {
|
||||
theme: 'neo' // 使用neo主题
|
||||
});
|
||||
editor.setOption("fullScreen", true);
|
||||
editor.setOption("hintOptions", {
|
||||
completeSingle: false,
|
||||
globalScope: autoJsGlobalScope()
|
||||
});
|
||||
var id = null;
|
||||
editor.on("keyup", function(editor, event)
|
||||
{
|
||||
if (!ExcludedIntelliSenseTriggerKeys[(event.keyCode || event.which).toString()] )
|
||||
{
|
||||
if(id != null){
|
||||
clearTimeout(id);
|
||||
}
|
||||
id = setTimeout(function(){
|
||||
editor.showHint({
|
||||
completeSingle: false
|
||||
})
|
||||
}, 100);
|
||||
|
||||
editor.setCursor({line: 0, ch: 0});
|
||||
editor.on('change', function(){
|
||||
var c = editor.getCursor();
|
||||
if(typeof(__bridge__) != 'undefined'){
|
||||
__bridge__.onKeyUp(editor.getLine(c.line), c.ch);
|
||||
}else{
|
||||
console.log(editor.getLine(c.line), c.ch);
|
||||
}
|
||||
});
|
||||
editor.setCursor({line: 0, ch: 0});
|
||||
|
||||
window.onload = function(){
|
||||
autojs(editor);
|
||||
|
||||
Reference in New Issue
Block a user