Skip to content

Commit

Permalink
Use SublimeLauncher.exe as the notepad.exe debugger
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Cherng <jfcherng@gmail.com>
  • Loading branch information
jfcherng committed Aug 20, 2019
1 parent bf8f2cb commit 7c7022d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 19 deletions.
1 change: 1 addition & 0 deletions Compile-Sublime-Text-Portable-Tool.bat
Expand Up @@ -31,6 +31,7 @@ ECHO Version: %VERSION%
/include "icon_associated_st.ico" ^
/include "icon_executable_st.ico" ^
/include "icon_menu_st.ico" ^
/include "SublimeLauncher.exe" ^
/include "rcedit.exe" ^
/icon "%ICON%" ^
/productname "%INPUT_BASENAME%" ^
Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -22,6 +22,7 @@ To compile this project, you need the following things.
- [Bat To Exe Converter](http://www.f2ko.de/en/b2e.php) (Freeware)
- [electron/rcedit](https://github.com/electron/rcedit) (MIT license)
- [ripgrep](https://github.com/BurntSushi/ripgrep) (Unlicense license)
- [Sublime-Notepad-Replacement](https://github.com/grumpydev/Sublime-Notepad-Replacement) (No license)

To compile, just run

Expand Down
22 changes: 3 additions & 19 deletions src/Sublime-Text-Portable-Tool.bat
Expand Up @@ -7,9 +7,7 @@ SET VERSION=v1.4.0
SET FILE_ICON_MENU=icon_menu_st.ico
SET FILE_ICON_ASSOCIATED=icon_associated_st.ico
SET FILE_ICON_EXECUTABLE=icon_executable_st.ico

:: used as a proxy to subl.exe for hijacking notepad.exe?
IF /I [%1] == ["C:\Windows\system32\NOTEPAD.EXE"] GOTO debuggerProxy
SET FILE_SUBLIME_LAUNCHER=SublimeLauncher.exe


:menu
Expand Down Expand Up @@ -49,6 +47,7 @@ FOR %%f IN (
"%FILE_ICON_ASSOCIATED%"
"%FILE_ICON_EXECUTABLE%"
"%FILE_ICON_MENU%"
"%FILE_SUBLIME_LAUNCHER%"
) DO (
IF NOT EXIST "%%f" copy "%b2eincfilepath%\%%f" . >NUL
)
Expand Down Expand Up @@ -152,7 +151,7 @@ GOTO begin

:set_sublime_default_editor
:: set self-executable to be the proxy (Debugger)
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /v "Debugger" /t REG_SZ /d "%CD%\%~nx0" /f
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /v "Debugger" /t REG_SZ /d "\"%CD%\SublimeLauncher.exe\" -z" /f
ECHO.
ECHO Done: set Sublime Text as the default text editor
ECHO.
Expand All @@ -176,18 +175,3 @@ ECHO.
ECHO Done: change the icon of sublime_text.exe
ECHO.
GOTO begin


:debuggerProxy
SET _tail=%*
:: get everything after %1 as _tail
CALL SET _tail=%%_tail:*%1=%%
:: the first char must be an extra space so remove it
SET _tail=%_tail:~1%

ECHO Used as notepad.exe debugger...
ECHO.
ECHO %_tail%
ECHO.
"%~dp0\sublime_text.exe" "%_tail%"
EXIT
Binary file added src/SublimeLauncher.exe
Binary file not shown.

0 comments on commit 7c7022d

Please sign in to comment.