Permalink
Browse files

Initial commit.

  • Loading branch information...
0 parents commit fd8f08d602da83a2373bb98d8663c73907311205 @mridgers committed Mar 21, 2012
Showing with 149,938 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +134 −0 clink.bat
  3. +48 −0 clink.h
  4. +115 −0 clink.nsi
  5. +82 −0 clink_core.lua
  6. +287 −0 clink_dll.c
  7. +54 −0 clink_env.lua
  8. +149 −0 clink_exec.lua
  9. +17 −0 clink_inputrc
  10. +720 −0 clink_license.txt
  11. +202 −0 clink_loader.c
  12. +324 −0 clink_lua.c
  13. +22 −0 clink_pch.c
  14. +51 −0 clink_pch.h
  15. +480 −0 clink_rl.c
  16. +41 −0 clink_sandbox.c
  17. +86 −0 clink_util.c
  18. +114 −0 lua/Makefile
  19. +6 −0 lua/README
  20. +531 −0 lua/doc/contents.html
  21. BIN lua/doc/logo.gif
  22. +116 −0 lua/doc/lua.1
  23. +83 −0 lua/doc/lua.css
  24. +118 −0 lua/doc/luac.1
  25. +24 −0 lua/doc/manual.css
  26. +10,397 −0 lua/doc/manual.html
  27. BIN lua/doc/osi-certified-72x60.png
  28. +419 −0 lua/doc/readme.html
  29. +187 −0 lua/src/Makefile
  30. +1,281 −0 lua/src/lapi.c
  31. +24 −0 lua/src/lapi.h
  32. +957 −0 lua/src/lauxlib.c
  33. +212 −0 lua/src/lauxlib.h
  34. +458 −0 lua/src/lbaselib.c
  35. +209 −0 lua/src/lbitlib.c
  36. +882 −0 lua/src/lcode.c
  37. +83 −0 lua/src/lcode.h
  38. +154 −0 lua/src/lcorolib.c
  39. +52 −0 lua/src/lctype.c
  40. +95 −0 lua/src/lctype.h
  41. +391 −0 lua/src/ldblib.c
  42. +577 −0 lua/src/ldebug.c
  43. +34 −0 lua/src/ldebug.h
  44. +670 −0 lua/src/ldo.c
  45. +46 −0 lua/src/ldo.h
  46. +172 −0 lua/src/ldump.c
  47. +171 −0 lua/src/lfunc.c
  48. +34 −0 lua/src/lfunc.h
  49. +1,103 −0 lua/src/lgc.c
  50. +139 −0 lua/src/lgc.h
  51. +67 −0 lua/src/linit.c
  52. +657 −0 lua/src/liolib.c
  53. +516 −0 lua/src/llex.c
  54. +78 −0 lua/src/llex.h
  55. +302 −0 lua/src/llimits.h
  56. +283 −0 lua/src/lmathlib.c
  57. +115 −0 lua/src/lmem.c
  58. +50 −0 lua/src/lmem.h
  59. +714 −0 lua/src/loadlib.c
  60. +289 −0 lua/src/lobject.c
  61. +597 −0 lua/src/lobject.h
  62. +106 −0 lua/src/lopcodes.c
  63. +288 −0 lua/src/lopcodes.h
  64. +322 −0 lua/src/loslib.c
  65. +1,620 −0 lua/src/lparser.c
  66. +119 −0 lua/src/lparser.h
  67. +286 −0 lua/src/lstate.c
  68. +220 −0 lua/src/lstate.h
  69. +114 −0 lua/src/lstring.c
  70. +37 −0 lua/src/lstring.h
  71. +969 −0 lua/src/lstrlib.c
  72. +579 −0 lua/src/ltable.c
  73. +41 −0 lua/src/ltable.h
  74. +283 −0 lua/src/ltablib.c
  75. +77 −0 lua/src/ltm.c
  76. +57 −0 lua/src/ltm.h
  77. +501 −0 lua/src/lua.c
  78. +439 −0 lua/src/lua.h
  79. +9 −0 lua/src/lua.hpp
  80. +432 −0 lua/src/luac.c
  81. +529 −0 lua/src/luaconf.h
  82. +55 −0 lua/src/lualib.h
  83. +244 −0 lua/src/lundump.c
  84. +28 −0 lua/src/lundump.h
  85. +864 −0 lua/src/lvm.c
  86. +45 −0 lua/src/lvm.h
  87. +76 −0 lua/src/lzio.c
  88. +65 −0 lua/src/lzio.h
  89. +184 −0 premake4.lua
  90. +140 −0 readline/compat/config.h
  91. +174 −0 readline/compat/dirent.c
  92. +50 −0 readline/compat/dirent.h
  93. +141 −0 readline/compat/hooks.c
  94. +31 −0 readline/compat/hooks.h
  95. +116 −0 readline/compat/termcap.c
  96. +1,095 −0 readline/readline/CHANGELOG
  97. +1,238 −0 readline/readline/CHANGES
  98. +674 −0 readline/readline/COPYING
  99. +287 −0 readline/readline/INSTALL
  100. +155 −0 readline/readline/MANIFEST
  101. +556 −0 readline/readline/Makefile.in
  102. +19 −0 readline/readline/NEWS
  103. +187 −0 readline/readline/README
  104. +37 −0 readline/readline/USAGE
  105. +4,169 −0 readline/readline/aclocal.m4
  106. +54 −0 readline/readline/ansi_stdlib.h
  107. +2,392 −0 readline/readline/bind.c
  108. +270 −0 readline/readline/callback.c
  109. +164 −0 readline/readline/chardefs.h
  110. +113 −0 readline/readline/compat.c
  111. +2,660 −0 readline/readline/complete.c
  112. +270 −0 readline/readline/config.h.in
  113. +11,798 −0 readline/readline/configure
  114. +299 −0 readline/readline/configure.in
  115. +2,688 −0 readline/readline/display.c
  116. +256 −0 readline/readline/doc/Makefile.in
  117. +506 −0 readline/readline/doc/fdl.texi
  118. +493 −0 readline/readline/doc/history.0
  119. +672 −0 readline/readline/doc/history.3
  120. BIN readline/readline/doc/history.dvi
  121. +2,297 −0 readline/readline/doc/history.html
  122. +1,401 −0 readline/readline/doc/history.info
  123. BIN readline/readline/doc/history.pdf
  124. BIN readline/readline/doc/history.ps
  125. +99 −0 readline/readline/doc/history.texi
  126. BIN readline/readline/doc/history_3.ps
  127. +577 −0 readline/readline/doc/hstech.texi
  128. +471 −0 readline/readline/doc/hsuser.texi
  129. +992 −0 readline/readline/doc/readline.0
  130. +1,381 −0 readline/readline/doc/readline.3
  131. BIN readline/readline/doc/readline.dvi
  132. +7,007 −0 readline/readline/doc/readline.html
  133. +4,676 −0 readline/readline/doc/readline.info
  134. BIN readline/readline/doc/readline.pdf
  135. BIN readline/readline/doc/readline.ps
  136. BIN readline/readline/doc/readline_3.ps
  137. +97 −0 readline/readline/doc/rlman.texi
  138. +2,420 −0 readline/readline/doc/rltech.texi
  139. +2,037 −0 readline/readline/doc/rluser.texi
  140. BIN readline/readline/doc/rluserman.dvi
  141. +2,926 −0 readline/readline/doc/rluserman.html
  142. +1,875 −0 readline/readline/doc/rluserman.info
  143. BIN readline/readline/doc/rluserman.pdf
  144. BIN readline/readline/doc/rluserman.ps
  145. +83 −0 readline/readline/doc/rluserman.texi
  146. +658 −0 readline/readline/doc/texi2dvi
  147. +5,428 −0 readline/readline/doc/texi2html
  148. +9,250 −0 readline/readline/doc/texinfo.tex
  149. +10 −0 readline/readline/doc/version.texi
  150. +872 −0 readline/readline/emacs_keymap.c
  151. +81 −0 readline/readline/examples/Inputrc
  152. +143 −0 readline/readline/examples/Makefile.in
  153. +40 −0 readline/readline/examples/autoconf/BASH_CHECK_LIB_TERMCAP
  154. +118 −0 readline/readline/examples/autoconf/RL_LIB_READLINE_VERSION
  155. +76 −0 readline/readline/examples/autoconf/wi_LIB_READLINE
  156. +191 −0 readline/readline/examples/excallback.c
  157. +488 −0 readline/readline/examples/fileman.c
  158. +125 −0 readline/readline/examples/histexamp.c
  159. +111 −0 readline/readline/examples/manexamp.c
  160. +139 −0 readline/readline/examples/readlinebuf.h
  161. +374 −0 readline/readline/examples/rl-fgets.c
  162. +157 −0 readline/readline/examples/rl.c
  163. +179 −0 readline/readline/examples/rlcat.c
  164. +166 −0 readline/readline/examples/rlevent.c
  165. +37 −0 readline/readline/examples/rlfe/ChangeLog
  166. +184 −0 readline/readline/examples/rlfe/Makefile.in
  167. +78 −0 readline/readline/examples/rlfe/README
  168. +379 −0 readline/readline/examples/rlfe/config.h.in
  169. +6,655 −0 readline/readline/examples/rlfe/configure
  170. +440 −0 readline/readline/examples/rlfe/configure.in
  171. +40 −0 readline/readline/examples/rlfe/extern.h
  172. +529 −0 readline/readline/examples/rlfe/os.h
  173. +388 −0 readline/readline/examples/rlfe/pty.c
  174. +785 −0 readline/readline/examples/rlfe/rlfe.c
  175. +2 −0 readline/readline/examples/rlfe/screen.h
  176. +337 −0 readline/readline/examples/rlptytest.c
  177. +92 −0 readline/readline/examples/rltest.c
  178. +48 −0 readline/readline/examples/rlversion.c
  179. BIN readline/readline/examples/rlwrap-0.30.tar.gz
  180. +263 −0 readline/readline/funmap.c
  181. +1,660 −0 readline/readline/histexpand.c
  182. +552 −0 readline/readline/histfile.c
  183. +82 −0 readline/readline/histlib.h
  184. +519 −0 readline/readline/history.c
  185. +266 −0 readline/readline/history.h
  186. +194 −0 readline/readline/histsearch.c
  187. +596 −0 readline/readline/input.c
  188. +697 −0 readline/readline/isearch.c
  189. +162 −0 readline/readline/keymaps.c
  190. +97 −0 readline/readline/keymaps.h
  191. +694 −0 readline/readline/kill.c
  192. +271 −0 readline/readline/macro.c
  193. +375 −0 readline/readline/mbutil.c
  194. +655 −0 readline/readline/misc.c
  195. +252 −0 readline/readline/nls.c
  196. +173 −0 readline/readline/parens.c
  197. +3 −0 readline/readline/patchlevel
  198. +61 −0 readline/readline/posixdir.h
  199. +40 −0 readline/readline/posixjmp.h
  200. +47 −0 readline/readline/posixselect.h
  201. +142 −0 readline/readline/posixstat.h
  202. +1,257 −0 readline/readline/readline.c
  203. +893 −0 readline/readline/readline.h
  204. +61 −0 readline/readline/rlconf.h
  205. +162 −0 readline/readline/rldefs.h
  206. +154 −0 readline/readline/rlmbutil.h
  207. +506 −0 readline/readline/rlprivate.h
  208. +33 −0 readline/readline/rlshell.h
  209. +45 −0 readline/readline/rlstdc.h
  210. +975 −0 readline/readline/rltty.c
  211. +80 −0 readline/readline/rltty.h
  212. +93 −0 readline/readline/rltypedefs.h
  213. +58 −0 readline/readline/rlwinsize.h
  214. +41 −0 readline/readline/savestring.c
  215. +570 −0 readline/readline/search.c
  216. +208 −0 readline/readline/shell.c
  217. +462 −0 readline/readline/shlib/Makefile.in
  218. +671 −0 readline/readline/signals.c
  219. +1,529 −0 readline/readline/support/config.guess
  220. +547 −0 readline/readline/support/config.rpath
  221. +1,665 −0 readline/readline/support/config.sub
  222. +247 −0 readline/readline/support/install.sh
  223. +47 −0 readline/readline/support/mkdirs
  224. +120 −0 readline/readline/support/mkdist
  225. +111 −0 readline/readline/support/mkinstalldirs
  226. +205 −0 readline/readline/support/shlib-install
  227. +579 −0 readline/readline/support/shobj-conf
  228. +313 −0 readline/readline/support/wcwidth.c
  229. +58 −0 readline/readline/tcap.h
  230. +731 −0 readline/readline/terminal.c
  231. +1,702 −0 readline/readline/text.c
  232. +502 −0 readline/readline/tilde.c
  233. +80 −0 readline/readline/tilde.h
  234. +331 −0 readline/readline/undo.c
  235. +526 −0 readline/readline/util.c
  236. +876 −0 readline/readline/vi_keymap.c
  237. +2,071 −0 readline/readline/vi_mode.c
  238. +50 −0 readline/readline/xfree.c
  239. +79 −0 readline/readline/xmalloc.c
  240. +45 −0 readline/readline/xmalloc.h
@@ -0,0 +1,3 @@
+.build
+tags
+*.swp
@@ -0,0 +1,134 @@
+::
+:: Copyright (c) 2012 Martin Ridgers
+::
+::
+:: Permission is hereby granted, free of charge, to any person obtaining a copy
+:: of this software and associated documentation files (the "Software"), to deal
+:: in the Software without restriction, including without limitation the rights
+:: to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+:: copies of the Software, and to permit persons to whom the Software is
+:: furnished to do so, subject to the following conditions:
+::
+:: The above copyright notice and this permission notice shall be included in
+:: all copies or substantial portions of the Software.
+::
+:: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+:: IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+:: FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+:: AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+:: LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+:: OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+:: SOFTWARE.
+::
+
+@echo off
+setlocal
+
+:: If the .bat is run without any arguments, then start a cmd.exe instance.
+::
+if "%1"=="" (
+ start "" cmd.exe /k "%~s0 inject && title clink"
+ goto :eof
+)
+
+:: Injects clink into the parent cmd.exe process
+::
+if /i "%1"=="inject" (
+ pushd %~dps0
+ if "%PROCESSOR_ARCHITECTURE%"=="x86" (
+ %~n0_x86.exe
+ ) else (
+ %~n0_x64.exe
+ )
+ popd
+ goto :eof
+)
+
+:: Add registry keys to inject clink everytime cmd.exe is started.
+::
+if /i "%1"=="install" (
+ :: attempt to break-out to native OS version of cmd.exe if need be
+ if not "%PROCESSOR_ARCHITEW6432%"=="" (
+ %windir%\sysnative\cmd.exe /c "%~s0 install"
+ ) else (
+ call :install "HKLM\Software\Microsoft\Command Processor"
+ if not "%PROCESSOR_ARCHITECTURE%"=="x86" (
+ call :install "HKLM\Software\Wow6432Node\Microsoft\Command Processor"
+ )
+ )
+ goto :eof
+)
+
+:: Delete the registry keys added by 'install'
+::
+if /i "%1"=="uninstall" (
+ if not "%PROCESSOR_ARCHITEW6432%"=="" (
+ %windir%\sysnative\cmd.exe /c "%~s0 uninstall"
+ ) else (
+ call :uninstall "HKLM\Software\Microsoft\Command Processor"
+ if not "%PROCESSOR_ARCHITECTURE%"=="x86" (
+ call :uninstall "HKLM\Software\Wow6432Node\Microsoft\Command Processor"
+ )
+ )
+ goto :eof
+)
+
+goto :eof
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+:: installs clink's autorun
+::
+:install
+ :: Check for an existing install
+ call :get_reg_key AutoRunPreFpgClink
+ if not "%ret%"=="" (
+ goto :eof
+ )
+
+ set autorun=%~s0 inject
+ call :get_reg_key %1 AutoRun
+ if not "%ret%"=="" (
+ set autorun=%~s0 inject ^&^& %ret:&=^&%
+ )
+ call :set_reg_key %1 AutoRunPreFpgClink "%ret%"
+ call :set_reg_key %1 AutoRun "%autorun%"
+exit /b 0
+
+:: uninstalls clink's autorun.
+::
+:uninstall
+ call :get_reg_key %1 AutoRunPreFpgClink
+ if "%ret%"=="" (
+ call :del_reg_key %1 AutoRun
+ ) else (
+ call :set_reg_key %1 AutoRun "%ret%"
+ )
+ call :del_reg_key %1 AutoRunPreFpgClink
+exit /b 0
+
+:: returns a registry key in the 'ret' environment variable
+::
+:get_reg_key
+ set ret=""
+ reg query %1 /v %2 1>nul 2>nul
+ if %errorlevel%==0 (
+ for /f "tokens=2* delims= " %%d in ('reg query %1 /v %2') do (
+ set ret="%%e"
+ )
+ )
+
+ set ret=%ret:&=^&%
+ set ret=%ret:~1,-1%
+exit /b 0
+
+:: Sets the registry key (REG_SZ type only!)
+::
+:set_reg_key
+ reg add %1 /v %2 /t REG_SZ /d "%~3" /f
+exit /b 0
+
+:: Deletes a registry key
+::
+:del_reg_key
+ reg delete %1 /v %2 /f
+exit /b 0
@@ -0,0 +1,48 @@
+/* Copyright (c) 2012 Martin Ridgers
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef CLINK_H
+#define CLINK_H
+
+#undef CLINK_API
+#if defined(CLINK_DLL_BUILD)
+# define CLINK_API __declspec(dllexport)
+#else
+# define CLINK_API __declspec(dllimport)
+#endif
+
+#define PROTOTYPE(x) void x( \
+ const wchar_t* prompt, \
+ wchar_t* result, \
+ unsigned result_size \
+);
+
+PROTOTYPE(CLINK_API call_readline)
+typedef PROTOTYPE((*call_readline_t))
+
+#undef PROTOTYPE
+
+#define AS_STR(x) AS_STR_IMPL(x)
+#define AS_STR_IMPL(x) #x
+
+#define CLINK_DLL_NAME "clink_dll_" AS_STR(PLATFORM) ".dll"
+
+#endif // CLINK_H
@@ -0,0 +1,115 @@
+;
+; Copyright (c) 2012 Martin Ridgers
+;
+;
+; Permission is hereby granted, free of charge, to any person obtaining a copy
+; of this software and associated documentation files (the "Software"), to deal
+; in the Software without restriction, including without limitation the rights
+; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+; copies of the Software, and to permit persons to whom the Software is
+; furnished to do so, subject to the following conditions:
+;
+; The above copyright notice and this permission notice shall be included in
+; all copies or substantial portions of the Software.
+;
+; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+; SOFTWARE.
+;
+
+;-------------------------------------------------------------------------------
+Name clink
+InstallDir "$PROGRAMFILES\clink"
+OutFile "${CLINK_SOURCE}_setup.exe"
+SetCompressor lzma
+LicenseData clink_license.txt
+LicenseForceSelection off
+RequestExecutionLevel admin
+XPStyle on
+
+;-------------------------------------------------------------------------------
+!if 0
+ !include "MUI2.nsh"
+
+ !define MUI_ABORTWARNING
+
+ ;!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt"
+ !insertmacro MUI_PAGE_COMPONENTS
+ !insertmacro MUI_PAGE_DIRECTORY
+ !insertmacro MUI_PAGE_INSTFILES
+
+ !insertmacro MUI_UNPAGE_CONFIRM
+ !insertmacro MUI_UNPAGE_INSTFILES
+
+ !insertmacro MUI_LANGUAGE "English"
+!else
+ Page license
+ Page directory
+ Page components
+ Page instfiles
+
+ UninstPage uninstConfirm
+ UninstPage components
+ UninstPage instfiles
+!endif
+
+;-------------------------------------------------------------------------------
+Section "!Application files"
+ SectionIn RO
+ SetShellVarContext all
+
+ ; Installs the main files.
+ CreateDirectory $INSTDIR
+ SetOutPath $INSTDIR
+ File ${CLINK_SOURCE}\*.dll
+ File ${CLINK_SOURCE}\*.lua
+ File ${CLINK_SOURCE}\clink_x*.exe
+ File ${CLINK_SOURCE}\*.bat
+ File ${CLINK_SOURCE}\*_inputrc
+
+ ; Create a start-menu shortcut
+ CreateDirectory "$SMPROGRAMS\clink"
+ CreateShortcut "$SMPROGRAMS\clink\clink.lnk" "$INSTDIR\clink.bat" "" "cmd.exe" 0 SW_SHOWMINIMIZED
+
+ ; Create an uninstaller and a shortcut to it.
+ WriteUninstaller "$INSTDIR\clink_uninstall.exe"
+ CreateShortcut "$SMPROGRAMS\clink\Uninstall clink.lnk" "$INSTDIR\clink_uninstall.exe"
+
+ ; Add to "add/remove programs"/"programs and features"
+ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Product" "DisplayName" "clink"
+ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Product" "UninstallString" "$INSTDIR\clink_uninstall.exe"
+ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Product" "Publisher" "Martin Ridgers"
+SectionEnd
+
+;-------------------------------------------------------------------------------
+Section "Autorun when cmd.exe starts"
+ SetShellVarContext all
+ ExecWait '"$INSTDIR\clink.bat" install'
+SectionEnd
+
+
+
+;-------------------------------------------------------------------------------
+Section "!un.Application files"
+ SetShellVarContext all
+
+ ExecWait '"$INSTDIR\clink.bat" uninstall'
+
+ RMDir /r $INSTDIR
+ RMDir /r $SMPROGRAMS\clink
+
+ DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Product" "DisplayName"
+ DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Product" "UninstallString"
+ DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Product" "Publisher"
+SectionEnd
+
+;-------------------------------------------------------------------------------
+Section "un.User scripts and history"
+ SetShellVarContext current
+
+ RMDIR /r $APPDATA\clink
+SectionEnd
@@ -0,0 +1,82 @@
+--[[
+ Copyright (c) 2012 Martin Ridgers
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+]]--
+
+--------------------------------------------------------------------------------
+clink = {}
+clink.matches = {}
+clink.generators = {}
+
+--------------------------------------------------------------------------------
+function clink.compute_lcd(text, list)
+ if #list < 2 then
+ return
+ end
+
+ local early_out = #text
+ local lcd = list[1]
+ for i = 2, #list, 1 do
+ for j = 1, #lcd, 1 do
+ if lcd:sub(1, j):lower() ~= list[i]:sub(1, j):lower() then
+ lcd = lcd:sub(1, j - 1)
+ break
+ end
+ end
+
+ if #lcd <= early_out then
+ break
+ end
+ end
+
+ return lcd
+end
+
+--------------------------------------------------------------------------------
+function clink.generate_matches(text, first, last)
+ clink.matches = {}
+ for _, generator in ipairs(clink.generators) do
+ if generator.f(text, first, last) then
+ if #clink.matches > 1 then
+ local lcd = clink.compute_lcd(text, clink.matches)
+ table.insert(clink.matches, 1, lcd)
+ end
+
+ return true
+ end
+ end
+
+ return false
+end
+
+--------------------------------------------------------------------------------
+function clink.add_match(match)
+ table.insert(clink.matches, match)
+end
+
+--------------------------------------------------------------------------------
+function clink.register_match_generator(func, priority)
+ if priority == nil then
+ priority = 999
+ end
+
+ table.insert(clink.generators, {f=func, p=priority})
+ table.sort(clink.generators, function(a, b) return a["p"] < b["p"] end)
+end
Oops, something went wrong.

0 comments on commit fd8f08d

Please sign in to comment.