-
-
Save okey3m/58873 to your computer and use it in GitHub Desktop.
syntax-highlight for AutoHotkey
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ahk 高亮 | |
CmdUtils.CreateCommand({ | |
name: 'as', | |
homepage: 'http://forum.ahkbbs.cn/', | |
author: { name: 'okey3m', email: 'okey3m@qq.com'}, | |
license: 'MPL', | |
takes: {'code': noun_arb_text}, | |
description: unescape('给任意网页上的 AutoHotkey 代码语法高亮'), | |
help: unescape('选中网页上任意一段 AutoHotkey 代码, 在 Ubiquity 中输入 as 回车即可看到效果'), | |
preview: unescape('给任意网页上的 AutoHotkey 代码语法高亮'), | |
execute: function() { | |
var code = CmdUtils.getHtmlSelection() | |
if(!jQuery.trim(code)) | |
return | |
var patternFunc = /(\b)(autotrim|blockinput|break|click|clipwait|continue|control|controlclick|controlfocus|controlget|controlgetfocus|controlgetpos|controlgettext|controlmove|controlsend|controlsendraw|controlsettext|coordmode|critical|detecthiddentext|detecthiddenwindows|dllcall|drive|driveget|drivespacefree|edit|else|envadd|envdiv|envget|envmult|envset|envsub|envupdate|exit|exitapp|fileappend|filecopy|filecopydir|filecreatedir|filecreateshortcut|filegetsize|filegettime|filegetversion|filemove|filemovedir|fileread|filereadline|filerecycle|fileremovedir|fileselectfile|fileselectfolder|filesetattrib|filesettime|formattime|getkeystate|gosub|goto|groupactivate|groupadd|groupclose|groupdeactivate|gui|guicontrol|guicontrolget|hideautoitwin|hotkey|if|not|ifequal|ifnotequal|ifexist|ifnotexist|fileexist|ifgreater|ifgreaterorequal|ifinstring|ifstr|ifless|iflessorequal|ifmsgbox|ifwinactive|ifwinnotactive|ifwinexist|ifwinnotexist|imagesearch|inidelete|iniread|iniwrite|input|inputbox|keyhistory|keywait|leftclick|leftclickdrag|listhotkeys|listlines|listvars|loop|menu|mouseclick|mouseclickdrag|mousegetpos|mousemove|msgbox|onexit|onmessage|outputdebug|pause|pixelgetcolor|pixelsearch|postmessage|process|progress|random|regexmatch|regexreplace|regdelete|regread|regwrite|registercallback|reload|repeat|endrepeat|return|rightclick|rightclickdrag|run|runas|runwait|send|sendraw|sendinput|sendplay|sendmessage|sendmode|setbatchlines|setcapslockstate|setcontroldelay|setdefaultmousespeed|setformat|setkeydelay|setmousedelay|setnumlockstate|setscrolllockstate|setstorecapslockmode|settimer|settitlematchmode|setwindelay|setworkingdir|shutdown|sleep|sort|soundbeep|soundget|soundgetwavevolume|soundplay|soundset|soundsetwavevolume|splashimage|splashtexton|splashtextoff|splitpath|statusbargettext|statusbarwait|stringcasesense|stringgetpos|instr|stringleft|stringlen|strlen|stringlower|stringmid|substr|stringreplace|stringright|stringsplit|stringtrimleft|stringtrimright|stringupper|suspend|sysget|thread|tooltip|transform|traytip|urldownloadtofile|varsetcapacity|winactivate|winactivatebottom|winclose|wingetactivestats|wingetactivetitle|winget|wingetclass|wingetpos|wingettext|wingettitle|winhide|winkill|winmaximize|winmenuselectitem|winminimize|winminimizeall|winminimizeallundo|winmove|winrestore|winset|winsettitle|winshow|winwait|winwaitactive|winwaitclose|winwaitnotactive)/ig | |
var patternA = /(A_Space|A_Tab|A_WorkingDir|A_scriptDir|A_scriptName|A_scriptFullPath|A_LineNumber|A_LineFile|A_ThisFunc|A_ahkVersion|A_ahkPath|A_IsCompiled|A_ExitReason|A_YYYY|A_MM|A_DD|A_MMMM|A_MMM|A_DDDD|A_DDD|A_WDay|A_YDay|A_YWeek|A_Hour|A_Min|A_Sec|A_MSec|A_Now|A_NowUTC|A_TickCount|A_IsSuspended|A_Batchlines|A_TitleMatchMode|A_TitleMatchModeSpeed|A_DetectHiddenWindows|A_DetectHiddenText|A_AutoTrim|A_StringCaseSense|A_FormatInteger|A_FormatFloat|A_KeyDelay|A_WinDelay|A_ControlDelay|A_MouseDelay|A_DefaultMouseSpeed|A_IconHidden|A_IconTip|A_IconFile|A_IconNumber|A_TimeIdle|A_TimeIdlePhysical|A_Gui|A_GuiControl|A_GuiWidth|A_GuiHeight|A_GuiX|A_GuiY|A_GuiEvent|A_GuiControlEvent|A_EventInfo|A_ThisMenuItem|A_ThisMenuItemPos|A_ThisHotkey|A_PriorHotkey|A_TimeSinceThisHotkey|A_TimeSincePriorHotkey|A_EndChar|ComSpec|A_Temp|A_OSType|A_OSVersion|A_Language|A_ComputerName|A_UserName|A_WinDir|A_ProgramFiles|A_AppData|A_AppDataCommon|A_Desktop|A_DesktopCommon|A_StartMenu|A_StartMenuCommon|A_Programs|A_ProgramsCommon|A_Startup|A_StartupCommon|A_MyDocuments|A_IsAdmin|A_ScreenWidth|A_ScreenHeight|A_IPAddress|A_Cursor|A_CaretX|A_CaretY|Clipboard|ClipboardAll|ErrorLevel|A_LastError|A_Index|A_LoopFileName|A_LoopRegName|A_LoopReadLine|A_LoopField|ahk_class|ahk_group|ahk_id|ahk_pid)/ig | |
var patternSharp = /(#allowsamelinecomments|#clipboardtimeout|#commentflag|#errorstdout|#escapechar|#hotkeyinterval|#hotkeymodifiertimeout|#hotstring|#ifwinactive|#ifwinexist|#include|#installkeybdhook|#installmousehook|#keyhistory|#maxhotkeysperinterval|#maxmem|#maxthreads|#maxthreadsbuffer|#maxthreadsperhotkey|#noenv|#notrayicon|#persistent|#singleinstance|#usehook|#winactivateforce)/ig | |
code = code.replace(patternFunc, '<span style="font-weight: 700; color: #0B007E">$1$2</span>').replace(patternSharp, '<span style="font-weight: bold; color: #BB0000">$1</span>').replace(patternA, '<span style="color: #1922FE">$1</span>').replace(/(\W|^)(;.*)/g, '<span style="color: #7F7F36">$1$2</span>') | |
CmdUtils.setSelection('<div style="line-height: 1.5em">' + code + '</div>') | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment