├── .github └── workflows │ └── winget-submission.yml ├── .gitignore ├── .luacheckrc ├── CHANGES ├── CHANGES.older.md ├── LICENSE ├── LUANOTES.md ├── README.md ├── TODO.md ├── _default_inputrc ├── _default_settings ├── bld.cmd ├── bldall.cmd ├── clink ├── app │ ├── resources │ │ ├── clink.ico │ │ ├── clink_blue.ico │ │ ├── clink_cyan.ico │ │ ├── clink_gold.ico │ │ ├── clink_gray.ico │ │ ├── clink_green.ico │ │ ├── clink_orange.ico │ │ ├── clink_purple.ico │ │ ├── clink_red.ico │ │ └── hue_shiifts.txt │ ├── scripts │ │ ├── _manifest.lua │ │ ├── cmd.lua │ │ ├── commands.lua │ │ ├── config.lua │ │ ├── dir.lua │ │ ├── env.lua │ │ ├── exec.lua │ │ ├── git.lua │ │ ├── loader_config.lua │ │ ├── lua_scripts.cpp │ │ ├── prompt.lua │ │ ├── self.lua │ │ ├── set.lua │ │ ├── suggest.lua │ │ └── update.lua │ ├── src │ │ ├── dll │ │ │ ├── dll.cpp │ │ │ ├── dll.h │ │ │ └── main.cpp │ │ ├── host │ │ │ ├── host.cpp │ │ │ ├── host.h │ │ │ ├── host_cmd.cpp │ │ │ ├── host_cmd.h │ │ │ ├── host_lua.cpp │ │ │ └── host_lua.h │ │ ├── loader │ │ │ ├── autorun.cpp │ │ │ ├── clink.bat │ │ │ ├── clink.lua │ │ │ ├── config.cpp │ │ │ ├── draw_test.cpp │ │ │ ├── history.cpp │ │ │ ├── info.cpp │ │ │ ├── inject.cpp │ │ │ ├── input_echo.cpp │ │ │ ├── installscripts.cpp │ │ │ ├── interpreter.cpp │ │ │ ├── interpreter_lua_c.h │ │ │ ├── loader.cpp │ │ │ ├── loader.h │ │ │ ├── main.cpp │ │ │ ├── set.cpp │ │ │ ├── testbed.cpp │ │ │ └── update.cpp │ │ ├── manifest.rc │ │ ├── pch.cpp │ │ ├── pch.h │ │ ├── utils │ │ │ ├── app_context.cpp │ │ │ ├── app_context.h │ │ │ ├── hook_setter.cpp │ │ │ ├── hook_setter.h │ │ │ ├── invalid_parameter.cpp │ │ │ ├── reset_stdio.cpp │ │ │ ├── reset_stdio.h │ │ │ ├── seh_scope.cpp │ │ │ ├── seh_scope.h │ │ │ ├── usage.cpp │ │ │ └── usage.h │ │ ├── version.h │ │ └── version.rc │ ├── test │ │ ├── coroutines.cpp │ │ ├── dir.cpp │ │ ├── doskey.cpp │ │ ├── env_vars.cpp │ │ ├── exec.cpp │ │ ├── history.cpp │ │ ├── redir.cpp │ │ └── set.cpp │ └── themes │ │ ├── 4-bit Enhanced Defaults.clinktheme │ │ ├── Antares.clinkprompt │ │ ├── Clink Dark.clinktheme │ │ ├── Clink Light.clinktheme │ │ ├── Dracula.clinktheme │ │ ├── Enhanced Defaults.clinktheme │ │ ├── Headline.clinkprompt │ │ ├── Plain.clinktheme │ │ ├── Solarized Dark.clinktheme │ │ ├── Solarized Light.clinktheme │ │ ├── Tomorrow Night Blue.clinktheme │ │ ├── Tomorrow Night Bright.clinktheme │ │ ├── Tomorrow Night Eighties.clinktheme │ │ ├── Tomorrow Night.clinktheme │ │ ├── Tomorrow.clinktheme │ │ ├── agnoster.clinkprompt │ │ ├── bureau.clinkprompt │ │ ├── darkblood.clinkprompt │ │ ├── jonathan.clinkprompt │ │ ├── oh-my-posh.clinkprompt │ │ └── pure.clinkprompt ├── core │ ├── include │ │ └── core │ │ │ ├── array.h │ │ │ ├── assert_improved.h │ │ │ ├── auto_free_str.h │ │ │ ├── base.h │ │ │ ├── bldopts.h │ │ │ ├── callstack.h │ │ │ ├── cwd_restorer.h │ │ │ ├── debugheap.h │ │ │ ├── embedded_scripts.h │ │ │ ├── globber.h │ │ │ ├── linear_allocator.h │ │ │ ├── log.h │ │ │ ├── match_wild.h │ │ │ ├── object.h │ │ │ ├── os.h │ │ │ ├── path.h │ │ │ ├── settings.h │ │ │ ├── singleton.h │ │ │ ├── str.h │ │ │ ├── str_compare.h │ │ │ ├── str_hash.h │ │ │ ├── str_iter.h │ │ │ ├── str_map.h │ │ │ ├── str_tokeniser.h │ │ │ ├── str_transform.h │ │ │ └── str_unordered_set.h │ ├── src │ │ ├── auto_free_str.cpp │ │ ├── callstack.cpp │ │ ├── debugheap.cpp │ │ ├── globber.cpp │ │ ├── linear_allocator.cpp │ │ ├── log.cpp │ │ ├── os.cpp │ │ ├── path.cpp │ │ ├── pch.cpp │ │ ├── pch.h │ │ ├── settings.cpp │ │ ├── str.cpp │ │ ├── str_compare.cpp │ │ ├── str_convert.cpp │ │ ├── str_iter.cpp │ │ ├── str_tokeniser.cpp │ │ └── str_transform.cpp │ ├── test │ │ ├── linear_allocator.cpp │ │ ├── match_wild.cpp │ │ ├── path.cpp │ │ ├── settings.cpp │ │ ├── str.cpp │ │ ├── str_compare.cpp │ │ ├── str_convert.cpp │ │ ├── str_iter.cpp │ │ ├── str_tokeniser.cpp │ │ └── wstr.cpp │ └── warning.h ├── lib │ ├── include │ │ └── lib │ │ │ ├── alias_cache.h │ │ │ ├── clink_ctrlevent.h │ │ │ ├── clink_rl_signal.h │ │ │ ├── cmd_tokenisers.h │ │ │ ├── display_matches.h │ │ │ ├── display_readline.h │ │ │ ├── doskey.h │ │ │ ├── editor_module.h │ │ │ ├── ellipsify.h │ │ │ ├── errfile_reader.h │ │ │ ├── hinter.h │ │ │ ├── history_db.h │ │ │ ├── history_timeformatter.h │ │ │ ├── host_callbacks.h │ │ │ ├── input_params.h │ │ │ ├── intercept.h │ │ │ ├── line_buffer.h │ │ │ ├── line_editor.h │ │ │ ├── line_editor_integration.h │ │ │ ├── line_state.h │ │ │ ├── match_colors.h │ │ │ ├── match_generator.h │ │ │ ├── matches.h │ │ │ ├── matches_lookaside.h │ │ │ ├── pager.h │ │ │ ├── popup.h │ │ │ ├── reclassify.h │ │ │ ├── recognizer.h │ │ │ ├── rl_integration.h │ │ │ ├── scroll_car.h │ │ │ ├── slash_translation.h │ │ │ ├── sticky_search.h │ │ │ ├── suggestions.h │ │ │ ├── wakeup_chars.h │ │ │ ├── word_classifications.h │ │ │ ├── word_classifier.h │ │ │ └── word_collector.h │ ├── src │ │ ├── alias_cache.cpp │ │ ├── bind_resolver.cpp │ │ ├── bind_resolver.h │ │ ├── binder.cpp │ │ ├── binder.h │ │ ├── clink_ctrlevent.cpp │ │ ├── clink_rl_signal.cpp │ │ ├── cmd_tokenisers.cpp │ │ ├── column_widths.cpp │ │ ├── column_widths.h │ │ ├── display_matches.cpp │ │ ├── display_readline.cpp │ │ ├── doskey.cpp │ │ ├── ellipsify.cpp │ │ ├── errfile_reader.cpp │ │ ├── history_db.cpp │ │ ├── history_timeformatter.cpp │ │ ├── input_dispatcher.h │ │ ├── input_params.cpp │ │ ├── intercept.cpp │ │ ├── line_editor_impl.cpp │ │ ├── line_editor_impl.h │ │ ├── line_editor_integration.cpp │ │ ├── line_state.cpp │ │ ├── match_adapter.cpp │ │ ├── match_adapter.h │ │ ├── match_colors.cpp │ │ ├── match_pipeline.cpp │ │ ├── match_pipeline.h │ │ ├── matches_impl.cpp │ │ ├── matches_impl.h │ │ ├── matches_lookaside.cpp │ │ ├── pager_impl.cpp │ │ ├── pager_impl.h │ │ ├── pch.cpp │ │ ├── pch.h │ │ ├── recognizer.cpp │ │ ├── rl │ │ │ ├── rl_buffer.cpp │ │ │ ├── rl_buffer.h │ │ │ ├── rl_commands.cpp │ │ │ ├── rl_commands.h │ │ │ ├── rl_help.cpp │ │ │ ├── rl_integration.cpp │ │ │ ├── rl_module.cpp │ │ │ └── rl_module.h │ │ ├── scroll_car.cpp │ │ ├── scroll_helper.cpp │ │ ├── scroll_helper.h │ │ ├── selectcomplete_impl.cpp │ │ ├── selectcomplete_impl.h │ │ ├── slash_translation.cpp │ │ ├── sticky_search.cpp │ │ ├── suggestions.cpp │ │ ├── textlist_impl.cpp │ │ ├── textlist_impl.h │ │ ├── wakeup_chars.cpp │ │ ├── word_classifications.cpp │ │ └── word_collector.cpp │ └── test │ │ ├── abbrev.cpp │ │ ├── binder.cpp │ │ ├── editor.cpp │ │ ├── ellipsify.cpp │ │ ├── file.cpp │ │ ├── matchcolors.cpp │ │ ├── matchtype.cpp │ │ ├── quotes.cpp │ │ ├── slash_translation.cpp │ │ └── word_collection.cpp ├── lua │ ├── include │ │ └── lua │ │ │ ├── lua_hinter.h │ │ │ ├── lua_input_idle.h │ │ │ ├── lua_match_generator.h │ │ │ ├── lua_script_loader.h │ │ │ ├── lua_state.h │ │ │ ├── lua_task_manager.h │ │ │ ├── lua_word_classifications.h │ │ │ ├── lua_word_classifier.h │ │ │ ├── prompt.h │ │ │ └── suggest.h │ ├── scripts │ │ ├── _manifest.lua │ │ ├── arguments.lua │ │ ├── classifier.lua │ │ ├── console.lua │ │ ├── core.lua │ │ ├── coroutines.lua │ │ ├── debugger.lua │ │ ├── error.lua │ │ ├── events.lua │ │ ├── generator.lua │ │ ├── hinter.lua │ │ └── lua_scripts.cpp │ ├── src │ │ ├── async_lua_task.cpp │ │ ├── async_lua_task.h │ │ ├── clink_api.cpp │ │ ├── command_link_dialog.cpp │ │ ├── command_link_dialog.h │ │ ├── console_api.cpp │ │ ├── io_api.cpp │ │ ├── line_state_lua.cpp │ │ ├── line_state_lua.h │ │ ├── line_states_lua.cpp │ │ ├── line_states_lua.h │ │ ├── log_api.cpp │ │ ├── lua_bindable.h │ │ ├── lua_editor_tester.cpp │ │ ├── lua_editor_tester.h │ │ ├── lua_exec.cpp │ │ ├── lua_hinter.cpp │ │ ├── lua_input_idle.cpp │ │ ├── lua_match_generator.cpp │ │ ├── lua_script_loader.cpp │ │ ├── lua_state.cpp │ │ ├── lua_word_classifications.cpp │ │ ├── lua_word_classifier.cpp │ │ ├── match_builder_lua.cpp │ │ ├── match_builder_lua.h │ │ ├── matches_lua.cpp │ │ ├── matches_lua.h │ │ ├── os_api.cpp │ │ ├── path_api.cpp │ │ ├── pch.cpp │ │ ├── pch.h │ │ ├── prompt.cpp │ │ ├── rl_api.cpp │ │ ├── rl_buffer_lua.cpp │ │ ├── rl_buffer_lua.h │ │ ├── settings_api.cpp │ │ ├── string_api.cpp │ │ ├── suggest.cpp │ │ ├── unicode_api.cpp │ │ ├── yield.cpp │ │ └── yield.h │ └── test │ │ ├── args.cpp │ │ ├── args2.cpp │ │ ├── classify.cpp │ │ ├── complete.cpp │ │ ├── globmatch.cpp │ │ ├── io.cpp │ │ └── merge.cpp ├── process │ ├── include │ │ └── process │ │ │ ├── pe.h │ │ │ ├── process.h │ │ │ └── vm.h │ ├── src │ │ ├── pch.cpp │ │ ├── pch.h │ │ ├── pe.cpp │ │ ├── process.cpp │ │ └── vm.cpp │ └── test │ │ └── hook.cpp ├── terminal │ ├── include │ │ └── terminal │ │ │ ├── attributes.h │ │ │ ├── ecma48_iter.h │ │ │ ├── ecma48_wrapper.h │ │ │ ├── find_line.h │ │ │ ├── input_idle.h │ │ │ ├── key_tester.h │ │ │ ├── printer.h │ │ │ ├── screen_buffer.h │ │ │ ├── scroll.h │ │ │ ├── terminal.h │ │ │ ├── terminal_helpers.h │ │ │ ├── terminal_in.h │ │ │ ├── terminal_out.h │ │ │ └── wcwidth.h │ ├── src │ │ ├── attributes.cpp │ │ ├── cielab.cpp │ │ ├── cielab.h │ │ ├── ecma48_iter.cpp │ │ ├── ecma48_terminal_out.cpp │ │ ├── ecma48_terminal_out.h │ │ ├── ecma48_wrapper.cpp │ │ ├── emoji-fe0f.txt │ │ ├── emoji-filter.txt │ │ ├── emoji-mono.txt │ │ ├── emoji-test.i │ │ ├── emoji-test.txt │ │ ├── find_line.cpp │ │ ├── pch.cpp │ │ ├── pch.h │ │ ├── printer.cpp │ │ ├── scroll.cpp │ │ ├── termcap.cpp │ │ ├── terminal.cpp │ │ ├── terminal_helpers.cpp │ │ ├── wcwidth.cpp │ │ ├── wcwidth_iter.cpp │ │ ├── win_screen_buffer.cpp │ │ ├── win_screen_buffer.h │ │ ├── win_terminal_in.cpp │ │ └── win_terminal_in.h │ └── test │ │ ├── attributes.cpp │ │ ├── ecma48.cpp │ │ └── wcwidth_iter.cpp └── test │ └── src │ ├── clatch.cpp │ ├── clatch.h │ ├── env_fixture.cpp │ ├── env_fixture.h │ ├── fs_fixture.cpp │ ├── fs_fixture.h │ ├── line_editor_tester.cpp │ ├── line_editor_tester.h │ ├── main.cpp │ ├── pch.cpp │ └── pch.h ├── complete └── test.clinkcomplete ├── detours ├── creatwth.cpp ├── detours.cpp ├── detours.h ├── detver.h ├── disasm.cpp ├── disolarm.cpp ├── disolarm64.cpp ├── disolia64.cpp ├── disolx64.cpp ├── disolx86.cpp ├── image.cpp ├── modules.cpp └── uimports.cpp ├── docs ├── api_v049.md ├── atom-one-light.css ├── clink.css ├── clink.html ├── clink.md ├── clink_v049.md ├── credits.md ├── examples │ ├── Sample.clinkprompt │ ├── ex_async_prompt.lua │ ├── ex_classify_envvar.lua │ ├── ex_classify_samp.lua │ ├── ex_findline.lua │ ├── ex_findprompt.lua │ ├── ex_findstr.lua │ ├── ex_fzf.lua │ ├── ex_generate.lua │ ├── ex_hinter.lua │ ├── ex_prompt.lua │ ├── ex_right_prompt.lua │ ├── ex_suggest.lua │ ├── ex_surround_prompt.lua │ └── ex_transient_prompt.lua ├── experimental.css ├── github.css ├── googlecode.css ├── highlight.pack.js └── premake5.lua ├── embed.lua ├── findhighbit.lua ├── getopt ├── getopt.c ├── getopt.h └── getopt.patch ├── installer ├── clink.nsi ├── license.rtf ├── modern_mediumdesc.exe └── premake5.lua ├── lua ├── Makefile ├── README ├── doc │ ├── contents.html │ ├── logo.gif │ ├── lua.1 │ ├── lua.css │ ├── luac.1 │ ├── manual.css │ ├── manual.html │ ├── osi-certified-72x60.png │ └── readme.html └── src │ ├── Makefile │ ├── lapi.c │ ├── lapi.h │ ├── lauxlib.c │ ├── lauxlib.h │ ├── lbaselib.c │ ├── lbitlib.c │ ├── lcode.c │ ├── lcode.h │ ├── lcorolib.c │ ├── lctype.c │ ├── lctype.h │ ├── ldblib.c │ ├── ldebug.c │ ├── ldebug.h │ ├── ldo.c │ ├── ldo.h │ ├── ldump.c │ ├── lfunc.c │ ├── lfunc.h │ ├── lgc.c │ ├── lgc.h │ ├── linit.c │ ├── liolib.c │ ├── llex.c │ ├── llex.h │ ├── llimits.h │ ├── lmathlib.c │ ├── lmem.c │ ├── lmem.h │ ├── loadlib.c │ ├── lobject.c │ ├── lobject.h │ ├── lopcodes.c │ ├── lopcodes.h │ ├── loslib.c │ ├── lparser.c │ ├── lparser.h │ ├── lstate.c │ ├── lstate.h │ ├── lstring.c │ ├── lstring.h │ ├── lstrlib.c │ ├── ltable.c │ ├── ltable.h │ ├── ltablib.c │ ├── ltm.c │ ├── ltm.h │ ├── lua.c │ ├── lua.h │ ├── lua.hpp │ ├── luac.c │ ├── luaconf.h │ ├── lualib.h │ ├── lundump.c │ ├── lundump.h │ ├── lvm.c │ ├── lvm.h │ ├── lzio.c │ └── lzio.h ├── mm.cmd ├── premake5.lua ├── readline ├── compat │ ├── config.h │ ├── dirent.c │ ├── dirent.h │ ├── fnmatch.c │ ├── fnmatch.h │ ├── hooks.c │ └── hooks.h ├── readline.patch └── readline │ ├── CHANGELOG │ ├── CHANGES │ ├── COPYING │ ├── INSTALL │ ├── MANIFEST │ ├── Makefile.in │ ├── NEWS │ ├── README │ ├── USAGE │ ├── aclocal.m4 │ ├── ansi_stdlib.h │ ├── bind.c │ ├── callback.c │ ├── chardefs.h │ ├── colors.c │ ├── colors.h │ ├── compat.c │ ├── complete.c │ ├── config.h.in │ ├── configure │ ├── configure.ac │ ├── display.c │ ├── doc │ ├── Makefile.in │ ├── fdl.texi │ ├── history.0 │ ├── history.3 │ ├── history.dvi │ ├── history.html │ ├── history.info │ ├── history.pdf │ ├── history.ps │ ├── history.texi │ ├── history_3.ps │ ├── hstech.texi │ ├── hsuser.texi │ ├── readline.0 │ ├── readline.3 │ ├── readline.dvi │ ├── readline.html │ ├── readline.info │ ├── readline.pdf │ ├── readline.ps │ ├── readline_3.ps │ ├── rlman.texi │ ├── rltech.texi │ ├── rluser.texi │ ├── rluserman.dvi │ ├── rluserman.html │ ├── rluserman.info │ ├── rluserman.pdf │ ├── rluserman.ps │ ├── rluserman.texi │ ├── texi2dvi │ ├── texi2html │ ├── texinfo.tex │ └── version.texi │ ├── emacs_keymap.c │ ├── examples │ ├── Inputrc │ ├── Makefile.in │ ├── autoconf │ │ ├── BASH_CHECK_LIB_TERMCAP │ │ ├── RL_LIB_READLINE_VERSION │ │ └── wi_LIB_READLINE │ ├── excallback.c │ ├── fileman.c │ ├── hist_erasedups.c │ ├── hist_purgecmd.c │ ├── histexamp.c │ ├── manexamp.c │ ├── readlinebuf.h │ ├── rl-callbacktest.c │ ├── rl-fgets.c │ ├── rl-test-timeout │ ├── rl-timeout.c │ ├── rl.c │ ├── rlbasic.c │ ├── rlcat.c │ ├── rlevent.c │ ├── rlfe │ │ ├── ChangeLog │ │ ├── Makefile.in │ │ ├── README │ │ ├── config.h.in │ │ ├── configure │ │ ├── configure.in │ │ ├── extern.h │ │ ├── os.h │ │ ├── pty.c │ │ ├── rlfe.c │ │ └── screen.h │ ├── rlkeymaps.c │ ├── rlptytest.c │ ├── rltest.c │ ├── rlversion.c │ └── rlwrap-0.30.tar.gz │ ├── funmap.c │ ├── gettimeofday.c │ ├── histexpand.c │ ├── histfile.c │ ├── histlib.h │ ├── history.c │ ├── history.h │ ├── history.pc.in │ ├── histsearch.c │ ├── input.c │ ├── isearch.c │ ├── keymaps.c │ ├── keymaps.h │ ├── kill.c │ ├── m4 │ └── codeset.m4 │ ├── macro.c │ ├── mbutil.c │ ├── misc.c │ ├── nls.c │ ├── parens.c │ ├── parse-colors.c │ ├── parse-colors.h │ ├── patchlevel │ ├── posixdir.h │ ├── posixjmp.h │ ├── posixselect.h │ ├── posixstat.h │ ├── posixtime.h │ ├── readline.c │ ├── readline.h │ ├── readline.pc.in │ ├── rlconf.h │ ├── rldefs.h │ ├── rlmbutil.h │ ├── rlprivate.h │ ├── rlshell.h │ ├── rlstdc.h │ ├── rltty.c │ ├── rltty.h │ ├── rltypedefs.h │ ├── rlwinsize.h │ ├── savestring.c │ ├── search.c │ ├── shell.c │ ├── shlib │ └── Makefile.in │ ├── signals.c │ ├── support │ ├── config.guess │ ├── config.rpath │ ├── config.sub │ ├── install.sh │ ├── mkdirs │ ├── mkdist │ ├── mkinstalldirs │ ├── shlib-install │ ├── shobj-conf │ └── wcwidth.c │ ├── tcap.h │ ├── terminal.c │ ├── text.c │ ├── tilde.c │ ├── tilde.h │ ├── undo.c │ ├── util.c │ ├── vi_keymap.c │ ├── vi_mode.c │ ├── xfree.c │ ├── xmalloc.c │ └── xmalloc.h ├── run.cmd ├── test.cmd └── wildmatch ├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── LICENSE ├── Makefile ├── README.md ├── examples └── wildmatch-cxx.cpp ├── tests ├── .gitignore ├── CMakeLists.txt ├── pch.cpp ├── pch.h ├── sharness.sh ├── t3070-wildmatch.i ├── t3070-wildmatch.sh ├── test-wildmatch.c ├── test-wildmatch.cpp └── test-wildmatch.h └── wildmatch ├── CMakeLists.txt ├── wildmatch.c ├── wildmatch.cpp ├── wildmatch.h └── wildmatch.hpp /.github/workflows/winget-submission.yml: -------------------------------------------------------------------------------- 1 | name: Submit Clink release to winget-pkgs 2 | # based off of https://github.com/microsoft/PowerToys/blob/main/.github/workflows/package-submissions.yml 3 | # ... based off of https://github.com/nushell/nushell/blob/main/.github/workflows/winget-submission.yml 4 | 5 | on: 6 | workflow_dispatch: 7 | release: 8 | types: [published] 9 | 10 | jobs: 11 | 12 | winget: 13 | name: Publish winget package 14 | runs-on: windows-latest 15 | steps: 16 | - name: Submit package to winget-pkgs 17 | run: | 18 | 19 | $wingetPackage = "chrisant996.Clink" 20 | $gitToken = "${{ secrets.WINGET_PAT }}" 21 | 22 | $targetRelease = Invoke-RestMethod -uri "https://api.github.com/repos/chrisant996/clink/releases/latest" 23 | 24 | $installerUrl = $targetRelease | Select -ExpandProperty assets -First 1 | Where-Object -Property name -match 'clink.*.exe' | Select -ExpandProperty browser_download_url 25 | $ver = $targetRelease.tag_name.Trim("v") 26 | 27 | # getting latest wingetcreate file 28 | iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe 29 | .\wingetcreate.exe update $wingetPackage -s -v $ver -u "$installerUrl|x86" "$installerUrl|x64" -t $gitToken 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .build 2 | tags 3 | *.swp 4 | *.exe 5 | *.log 6 | *.patch 7 | -------------------------------------------------------------------------------- /.luacheckrc: -------------------------------------------------------------------------------- 1 | return { 2 | exclude_files = { 3 | ".install", 4 | ".lua", 5 | ".luarocks", 6 | "modules/JSON.lua", 7 | "lua_modules" 8 | }, 9 | files = { 10 | spec = { std = "+busted" }, 11 | }, 12 | globals = { 13 | "_co_error_handler", 14 | "_error_handler", 15 | "_error_handler_ret", 16 | "clink", 17 | "CLINK_EXE", 18 | "console", 19 | "coroutine.override_isgenerator", 20 | "coroutine.override_isprompt", 21 | "coroutine.override_src", 22 | "git", 23 | "io", 24 | "log", 25 | "NONL", 26 | "os", 27 | "path", 28 | "pause", 29 | "rl", 30 | "rl_state", 31 | "settings", 32 | "string", 33 | "unicode", 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /LUANOTES.md: -------------------------------------------------------------------------------- 1 | # Lua Notes 2 | 3 | ## Performance 4 | 5 | ### Implicit boolean vs equality comparison (100,000,000 iterations). 6 | - `if mode then` -> 1.23 sec. 7 | - `if mode == true then` -> 1.42 sec. 8 | - `if mode == "one" then` -> 1.44 sec. 9 | 10 | ### True vs false branch path (100,000,000 iterations). 11 | - `if x then` **false** branch 0.2 sec **faster** than true branch. 12 | - `not` is insignificant; negligible difference between `if x then` vs `if not x then` when following the same branch path. 13 | 14 | ### Cache table value in local var (100,000,000 iterations). 15 | - `x = x + t.longer_name.pinky` unconditional -> 2.0 sec. 16 | - `x = x + t.longer_name.pinky` true branch path w/no else block -> 2.4 sec. 17 | - `x = x + t.longer_name.pinky` true branch path w/an else block -> 2.7 sec. 18 | - `x = x + t.longer_name.pinky` false branch path -> 2.5 sec. 19 | - `x = x + cached` unconditional -> 0.68 sec. 20 | - `x = x + cached` true branch path w/no else block -> 0.98 sec. 21 | - `x = x + cached` true branch path w/an else block -> 1.24 sec. 22 | - `x = x + cached` false branch path -> 1.18 sec. 23 | 24 | -------------------------------------------------------------------------------- /_default_inputrc: -------------------------------------------------------------------------------- 1 | # When this file is named "default_inputrc" and is in the binaries 2 | # directory or profile directory, it provides enhanced default settings. 3 | 4 | # Override the built-in Readline defaults with ones that provide a more 5 | # enhanced Clink experience. 6 | 7 | set colored-completion-prefix on 8 | set colored-stats on 9 | set mark-symlinked-directories on 10 | set completion-auto-query-items on 11 | set history-point-at-end-of-anchored-search on 12 | set search-ignore-case on 13 | 14 | -------------------------------------------------------------------------------- /_default_settings: -------------------------------------------------------------------------------- 1 | # When this file is named "default_settings" and is in the binaries 2 | # directory or profile directory, it provides enhanced default settings. 3 | 4 | # Override built-in default settings with ones that provide a more 5 | # enhanced Clink experience. 6 | 7 | clink.default_bindings = windows 8 | cmd.ctrld_exits = False 9 | color.arginfo = sgr 38;5;172 10 | color.argmatcher = sgr 1;38;5;40 11 | color.cmd = bold 12 | color.cmdredir = sgr 38;5;172 13 | color.cmdsep = sgr 38;5;135 14 | color.comment_row = sgr 38;5;87;48;5;18 15 | color.description = sgr 38;5;39 16 | color.doskey = sgr 1;38;5;75 17 | color.executable = sgr 1;38;5;33 18 | color.filtered = bold 19 | color.flag = sgr 38;5;117 20 | color.hidden = sgr 38;5;160 21 | color.histexpand = sgr 97;48;5;55 22 | color.horizscroll = sgr 38;5;16;48;5;30 23 | color.input = sgr 38;5;214 24 | color.readonly = sgr 38;5;28 25 | color.selection = sgr 38;5;16;48;5;179 26 | color.unrecognized = sgr 38;5;203 27 | history.max_lines = 25000 28 | history.time_stamp = show 29 | match.expand_envvars = True 30 | match.substring = True 31 | 32 | -------------------------------------------------------------------------------- /clink/app/resources/clink.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisant996/clink/d8a218ad53457119ef4e4dd370bed22f63ec458e/clink/app/resources/clink.ico -------------------------------------------------------------------------------- /clink/app/resources/clink_blue.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisant996/clink/d8a218ad53457119ef4e4dd370bed22f63ec458e/clink/app/resources/clink_blue.ico -------------------------------------------------------------------------------- /clink/app/resources/clink_cyan.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisant996/clink/d8a218ad53457119ef4e4dd370bed22f63ec458e/clink/app/resources/clink_cyan.ico -------------------------------------------------------------------------------- /clink/app/resources/clink_gold.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisant996/clink/d8a218ad53457119ef4e4dd370bed22f63ec458e/clink/app/resources/clink_gold.ico -------------------------------------------------------------------------------- /clink/app/resources/clink_gray.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisant996/clink/d8a218ad53457119ef4e4dd370bed22f63ec458e/clink/app/resources/clink_gray.ico -------------------------------------------------------------------------------- /clink/app/resources/clink_green.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisant996/clink/d8a218ad53457119ef4e4dd370bed22f63ec458e/clink/app/resources/clink_green.ico -------------------------------------------------------------------------------- /clink/app/resources/clink_orange.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisant996/clink/d8a218ad53457119ef4e4dd370bed22f63ec458e/clink/app/resources/clink_orange.ico -------------------------------------------------------------------------------- /clink/app/resources/clink_purple.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisant996/clink/d8a218ad53457119ef4e4dd370bed22f63ec458e/clink/app/resources/clink_purple.ico -------------------------------------------------------------------------------- /clink/app/resources/clink_red.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisant996/clink/d8a218ad53457119ef4e4dd370bed22f63ec458e/clink/app/resources/clink_red.ico -------------------------------------------------------------------------------- /clink/app/resources/hue_shiifts.txt: -------------------------------------------------------------------------------- 1 | These are the hue shifts that were applied to produce color variation icons. 2 | 3 | HUE SAT BRI 4 | 5 | CLINK_BLUE.ICO: 6 | 7 | clink_red.ico +166 0 0 8 | clink_green.ico -110 0 0 9 | clink_cyan.ico -15 0 +20 10 | clink_orange.ico -156 0 0 11 | 12 | CLINK_GOLD.ICO: 13 | 14 | clink_purple.ico -120 0 0 15 | clink_gray.ico 0 -100 -5 16 | -------------------------------------------------------------------------------- /clink/app/scripts/_manifest.lua: -------------------------------------------------------------------------------- 1 | return { 2 | name = "app", 3 | files = { 4 | "cmd.lua", 5 | "commands.lua", 6 | "config.lua", 7 | "dir.lua", 8 | "env.lua", 9 | "exec.lua", 10 | "git.lua", 11 | "loader_config.lua", 12 | "prompt.lua", 13 | "self.lua", 14 | "set.lua", 15 | "suggest.lua", 16 | "update.lua", 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /clink/app/scripts/set.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2012 Martin Ridgers 2 | -- License: http://opensource.org/licenses/MIT 3 | 4 | -------------------------------------------------------------------------------- 5 | -- NOTE: If you add any settings here update set.cpp to load (lua, app, set). 6 | 7 | -------------------------------------------------------------------------------- 8 | local set_generator = clink.generator(41) 9 | 10 | -------------------------------------------------------------------------------- 11 | function set_generator:generate(line_state, match_builder) -- luacheck: no unused 12 | if line_state:getwordcount() ~= 2 then 13 | return false 14 | end 15 | 16 | if line_state:getword(1) ~= "set" then 17 | return false 18 | end 19 | 20 | match_builder:addmatches(os.getenvnames(), "word") 21 | match_builder:setappendcharacter("=") 22 | return true 23 | end 24 | -------------------------------------------------------------------------------- /clink/app/src/dll/dll.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include "utils/app_context.h" 7 | 8 | INT_PTR WINAPI initialise_clink(const app_context::desc&); 9 | -------------------------------------------------------------------------------- /clink/app/src/dll/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include 5 | 6 | //------------------------------------------------------------------------------ 7 | // This function exists purely to make sure it gets exported from the DLL. 8 | __declspec(dllexport) int32_t loader_main_thunk() 9 | { 10 | extern int32_t loader_main_impl(); 11 | return loader_main_impl(); 12 | } 13 | -------------------------------------------------------------------------------- /clink/app/src/loader/clink.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem -- Copyright (c) 2012 Martin Ridgers 3 | rem -- Portions Copyright (c) 2020-2025 Christopher Antos 4 | rem -- License: http://opensource.org/licenses/MIT 5 | 6 | setlocal enableextensions 7 | set clink_profile_arg= 8 | set clink_quiet_arg= 9 | 10 | rem -- Mimic cmd.exe's behaviour when starting from the start menu. 11 | if /i "%~1"=="startmenu" ( 12 | cd /d "%userprofile%" 13 | shift 14 | ) 15 | 16 | rem -- Check for the --profile option. 17 | if /i "%~1"=="--profile" ( 18 | set clink_profile_arg=--profile "%~2" 19 | shift 20 | shift 21 | ) 22 | 23 | rem -- Check for the --quiet option. 24 | if /i "%~1"=="--quiet" ( 25 | set clink_quiet_arg= --quiet 26 | shift 27 | ) 28 | 29 | rem -- If the .bat is run without any arguments, then start a cmd.exe instance. 30 | if _%1==_ ( 31 | call :launch 32 | goto :end 33 | ) 34 | 35 | rem -- Test for autorun. 36 | if defined CLINK_NOAUTORUN if /i "%~1"=="inject" if /i "%~2"=="--autorun" goto :end 37 | 38 | rem -- Forward to appropriate loader, and endlocal before inject tags the prompt. 39 | if /i "%processor_architecture%"=="x86" ( 40 | endlocal 41 | "%~dp0\clink_x86.exe" %* 42 | ) else if /i "%processor_architecture%"=="arm64" ( 43 | endlocal 44 | "%~dp0\clink_arm64.exe" %* 45 | ) else if /i "%processor_architecture%"=="amd64" ( 46 | if defined processor_architew6432 ( 47 | endlocal 48 | "%~dp0\clink_x86.exe" %* 49 | ) else ( 50 | endlocal 51 | "%~dp0\clink_x64.exe" %* 52 | ) 53 | ) 54 | 55 | goto :end 56 | 57 | :launch 58 | setlocal enableextensions 59 | set WT_PROFILE_ID= 60 | set WT_SESSION= 61 | start "Clink" cmd.exe /s /k ""%~dpnx0" inject %clink_profile_arg%%clink_quiet_arg%" 62 | endlocal 63 | 64 | :end 65 | -------------------------------------------------------------------------------- /clink/app/src/loader/clink.lua: -------------------------------------------------------------------------------- 1 | -- This file is intentionally blank. 2 | -- 3 | -- The old clink.lua file is no longer used, and this blank file ensures if a 4 | -- new clink version is copied over an old clink version, it won't accidentally 5 | -- use an obsolete leftover clink.lua file. 6 | -------------------------------------------------------------------------------- /clink/app/src/loader/loader.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | class str_base; 7 | 8 | void get_profile_path(const char* in, str_base& out); 9 | -------------------------------------------------------------------------------- /clink/app/src/manifest.rc: -------------------------------------------------------------------------------- 1 | // Manifest; command_link_dialog.cpp needs this for visual theme support. 2 | 1 24 "clink_manifest.xml" 3 | -------------------------------------------------------------------------------- /clink/app/src/pch.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include "pch.h" 5 | -------------------------------------------------------------------------------- /clink/app/src/pch.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #if defined(__MINGW32__) || defined(__MINGW64__) 14 | # include 15 | #endif 16 | 17 | #include 18 | #include 19 | #include 20 | // Some code 21 | #ifdef _MSC_VER 22 | # pragma warning(push) 23 | # pragma warning(disable : 4091) 24 | #endif 25 | #include 26 | #if !(defined(__MINGW32__) || defined(__MINGW64__)) 27 | # include 28 | #endif 29 | #ifdef _MSC_VER 30 | # pragma warning(pop) 31 | #endif 32 | 33 | #include 34 | 35 | #define CLINK_DLL "clink_dll_" AS_STR(ARCHITECTURE_NAME) ".dll" 36 | #define CLINK_EXE "clink_" AS_STR(ARCHITECTURE_NAME) ".exe" 37 | -------------------------------------------------------------------------------- /clink/app/src/utils/invalid_parameter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include "pch.h" 5 | 6 | #include 7 | 8 | #include 9 | 10 | static void __cdecl do_nothing(wchar_t const*, wchar_t const*, wchar_t const*, unsigned int, uintptr_t) 11 | { 12 | } 13 | 14 | //------------------------------------------------------------------------------ 15 | // The C runtime _popen() function has a bug (issue clink#727) where it tries 16 | // to double-close a file handle upon failure. But also many Lua APIs pass 17 | // input parameters directly through to various C runtime functions, expecting 18 | // the C runtime to do parameter validation and return a failure message which 19 | // Lua can then print to the terminal. But the default behavior for the C 20 | // runtime changed and now forces a Watson report (crashes the process). 21 | // That's not an appropriate response in Clink or other programs which host 22 | // the Lua engine, so we need to set an invalid parameter handle that does 23 | // nothing, so that the C runtime continues gracefully (returning an error) 24 | // instead of forcibly terminating the process. 25 | void install_crt_invalid_parameter_handler() 26 | { 27 | _set_invalid_parameter_handler(do_nothing); 28 | } 29 | -------------------------------------------------------------------------------- /clink/app/src/utils/reset_stdio.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | //------------------------------------------------------------------------------ 5 | void reset_stdio_handles(); 6 | -------------------------------------------------------------------------------- /clink/app/src/utils/seh_scope.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | //------------------------------------------------------------------------------ 7 | class seh_scope 8 | { 9 | public: 10 | seh_scope(); 11 | ~seh_scope(); 12 | }; 13 | 14 | //------------------------------------------------------------------------------ 15 | void install_exception_filter(); 16 | -------------------------------------------------------------------------------- /clink/app/src/utils/usage.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | extern void maybe_print_logo(); 7 | extern void puts_clink_header(); 8 | extern void puts_help(const char* const* help_pairs, const char* const* other_pairs=nullptr, int32 padding=4); 9 | -------------------------------------------------------------------------------- /clink/app/src/version.rc: -------------------------------------------------------------------------------- 1 | #include "version.h" 2 | 3 | 1 VERSIONINFO 4 | FILEVERSION CLINK_VERSION_MAJOR, CLINK_VERSION_MINOR, CLINK_VERSION_PATCH 5 | PRODUCTVERSION CLINK_VERSION_MAJOR, CLINK_VERSION_MINOR, CLINK_VERSION_PATCH 6 | { 7 | BLOCK "StringFileInfo" { 8 | BLOCK "040904b0" { 9 | VALUE "CompanyName", "Martin Ridgers, Christopher Antos" 10 | VALUE "ProductName", "Clink" 11 | VALUE "FileDescription", "Clink" 12 | VALUE "InternalName", "Clink" 13 | VALUE "ProductVersion", CLINK_VERSION_STR 14 | VALUE "FileVersion", CLINK_VERSION_STR 15 | VALUE "LegalCopyright", CLINK_COPYRIGHT_STR 16 | } 17 | } 18 | BLOCK "VarFileInfo" { 19 | VALUE "Translation", 0x0409, 1200 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /clink/app/themes/4-bit Enhanced Defaults.clinktheme: -------------------------------------------------------------------------------- 1 | # Name: 4-bit Enhanced Defaults 2 | 3 | [set] 4 | color.arg = bold 5 | color.arginfo = yellow 6 | color.argmatcher = bold bright green 7 | color.cmd = bold 8 | color.cmdredir = yellow 9 | color.cmdsep = magenta 10 | color.comment_row = bright cyan on blue 11 | color.common_match_prefix = 12 | color.description = cyan 13 | color.doskey = bold bright cyan 14 | color.executable = bold bright blue 15 | color.filtered = bold 16 | color.flag = cyan 17 | color.hidden = red 18 | color.histexpand = bright white on magenta 19 | color.horizscroll = black on green 20 | color.input = bright yellow 21 | color.interact = bold 22 | color.message = default 23 | color.modmark = 24 | color.popup = 25 | color.popup_border = 26 | color.popup_desc = 27 | color.popup_footer = 28 | color.popup_header = 29 | color.popup_select = 30 | color.popup_selectdesc = 31 | color.prompt = 32 | color.readonly = green 33 | color.selected_completion = sgr 7 34 | color.selection = black on bright yellow 35 | color.suggestion = 36 | color.unexpected = default 37 | color.unrecognized = bright red 38 | -------------------------------------------------------------------------------- /clink/app/themes/Clink Dark.clinktheme: -------------------------------------------------------------------------------- 1 | [set] 2 | color.arg=bold 3 | color.arginfo=sgr 38;5;172;4 4 | color.argmatcher=sgr 1;38;5;40 5 | color.cmd=bold 6 | color.cmdredir=sgr 38;5;172 7 | color.cmdsep=sgr 38;5;135 8 | color.comment_row=sgr 38;5;87;48;5;18 9 | color.common_match_prefix=bright magenta 10 | color.description=sgr 38;5;39 11 | color.doskey=sgr 1;38;5;75 12 | color.executable=sgr 1;38;5;33 13 | color.filtered=bold 14 | color.flag=sgr 38;5;117 15 | color.hidden=sgr 38;5;160 16 | color.histexpand=sgr 97;48;5;55 17 | color.horizscroll=sgr 38;5;16;48;5;30 18 | color.input=sgr 38;5;222 19 | color.interact=bold 20 | color.message=sgr 0;97;48;2;0;102;0 21 | color.modmark=bright cyan 22 | color.popup= 23 | color.popup_border= 24 | color.popup_desc= 25 | color.popup_footer= 26 | color.popup_header= 27 | color.popup_select= 28 | color.popup_selectdesc= 29 | color.prompt= 30 | color.readonly= 31 | color.selected_completion=sgr 38;5;16;48;5;254 32 | color.selection=sgr 38;5;16;48;5;179 33 | color.suggestion=sgr 38;5;239 34 | color.unexpected=default 35 | color.unrecognized=sgr 38;5;203 36 | -------------------------------------------------------------------------------- /clink/app/themes/Clink Light.clinktheme: -------------------------------------------------------------------------------- 1 | [preferred] 2 | background=#ffffff 3 | foreground=#808080 4 | 5 | [set] 6 | color.arg=black 7 | color.arginfo=sgr 38;5;172;4 8 | color.argmatcher=#40d000 9 | color.cmd=black 10 | color.cmdredir=sgr 38;5;172 11 | color.cmdsep=sgr 38;5;93 12 | # color.command_substitution=sgr 97;48;5;165 13 | color.comment_row=sgr 38;5;27;48;5;153 14 | color.common_match_prefix=sgr 38;5;135 15 | color.description=sgr 38;5;32 16 | color.doskey=sgr 1;38;5;75 17 | # color.envvars=sgr 1;38;5;45 18 | color.executable=sgr 1;38;5;33 19 | color.filtered=black 20 | color.flag=sgr 38;5;39 21 | color.hidden=sgr 38;5;160 22 | color.histexpand=sgr 97;48;5;55 23 | color.horizscroll=sgr 38;5;16;48;5;30 24 | color.input=sgr 38;5;94 25 | color.interact=black 26 | color.message=sgr 0;38;5;254;48;2;0;102;0 27 | color.modmark=bright cyan 28 | color.popup=#222222 on #d3d3dd 29 | color.popup_border= 30 | color.popup_desc=#8094a8 on #d4d4dd 31 | color.popup_footer= 32 | color.popup_header= 33 | color.popup_select= 34 | color.popup_selectdesc= 35 | color.prompt=brblack 36 | color.readonly= 37 | color.selected_completion=sgr 38;5;15;48;5;242 38 | color.selection=sgr 38;5;16;48;5;179 39 | color.suggestion=sgr 38;5;251 40 | color.unexpected=sgr 38;5;219 41 | color.unrecognized=sgr 38;5;203 42 | -------------------------------------------------------------------------------- /clink/app/themes/Dracula.clinktheme: -------------------------------------------------------------------------------- 1 | # Name: Dracula 2 | 3 | # Adapted from https://github.com/dracula/fish 4 | # MIT License 5 | 6 | # Dracula Color Palette 7 | # 8 | # Foreground: f8f8f2 9 | # Selection: 44475a 10 | # Comment: 6272a4 11 | # Red: ff5555 12 | # Orange: ffb86c 13 | # Yellow: f1fa8c 14 | # Green: 50fa7b 15 | # Purple: bd93f9 16 | # Cyan: 8be9fd 17 | # Pink: ff79c6 18 | 19 | [set] 20 | color.arg=#bd93f9 21 | color.arginfo=italic #bd93f9 22 | color.argmatcher=#50fa7b 23 | color.cmd=#ff79c6 24 | color.cmdredir=#f8f8f2 25 | color.cmdsep=#ffb86c 26 | color.comment_row=#6272a4 27 | color.common_match_prefix=#8be9fd 28 | color.description=#6272a4 29 | color.doskey=#8be9fd 30 | color.envvars=#50fa7b 31 | color.escapetilde=#50fa7b 32 | color.executable=#8be9fd 33 | color.filtered=#f8f8f2 34 | color.flag=#ffb86c 35 | color.hidden=#6272a4 36 | color.histexpand=#50fa7b 37 | color.horizscroll=reverse 38 | color.input=#f8f8f2 39 | color.interact=bold 40 | color.message=#6272a4 41 | color.modmark=#bd93f9 42 | color.popup=#f8f8f2 on #292a35 43 | color.popup_border=#6272a4 on #292a35 44 | color.popup_desc=#8be9fd on #292a35 45 | color.popup_footer=#f8f8f2 on #292a35 46 | color.popup_header=#ffb86c on #292a35 47 | color.popup_select=#f8f8f2 on #44475a 48 | color.popup_selectdesc=#8be9fd on #44475a 49 | color.prompt=#f8f8f2 50 | color.readonly=#bd93f9 51 | color.selected_completion=#f8f8f2 on #44475a 52 | color.selection=default on #44475a 53 | color.suggestion=#6272a4 54 | color.unexpected=#ff5555 55 | color.unrecognized=#ff5555 56 | -------------------------------------------------------------------------------- /clink/app/themes/Enhanced Defaults.clinktheme: -------------------------------------------------------------------------------- 1 | # Name: Enhanced Defaults 2 | 3 | [set] 4 | color.arg = bold 5 | color.arginfo = sgr 38;5;172 6 | color.argmatcher = sgr 1;38;5;40 7 | color.cmd = bold 8 | color.cmdredir = sgr 38;5;172 9 | color.cmdsep = sgr 38;5;135 10 | color.comment_row = sgr 38;5;87;48;5;18 11 | color.common_match_prefix = 12 | color.description = sgr 38;5;39 13 | color.doskey = sgr 1;38;5;75 14 | color.executable = sgr 1;38;5;33 15 | color.filtered = bold 16 | color.flag = sgr 38;5;117 17 | color.hidden = sgr 38;5;160 18 | color.histexpand = sgr 97;48;5;55 19 | color.horizscroll = sgr 38;5;16;48;5;30 20 | color.input = sgr 38;5;214 21 | color.interact = bold 22 | color.message = default 23 | color.modmark = 24 | color.popup = 25 | color.popup_border = 26 | color.popup_desc = 27 | color.popup_footer = 28 | color.popup_header = 29 | color.popup_select = 30 | color.popup_selectdesc = 31 | color.prompt = 32 | color.readonly = sgr 38;5;28 33 | color.selected_completion = sgr 7 34 | color.selection = sgr 38;5;16;48;5;179 35 | color.suggestion = 36 | color.unexpected = default 37 | color.unrecognized = sgr 38;5;203 38 | -------------------------------------------------------------------------------- /clink/app/themes/Plain.clinktheme: -------------------------------------------------------------------------------- 1 | # Name: Plain 2 | 3 | [set] 4 | color.arg=bold 5 | color.arginfo=italic 6 | color.argmatcher=bold 7 | color.cmd=bold 8 | color.cmdredir=bold 9 | color.cmdsep=bold 10 | color.comment_row=bright white on bright black 11 | color.common_match_prefix=bold underline 12 | color.description= 13 | color.doskey=bold 14 | color.envvars=bold 15 | color.escapetilde=bold 16 | color.executable=bold 17 | color.filtered=bold 18 | color.flag= 19 | color.hidden= 20 | color.histexpand=reverse 21 | color.horizscroll=reverse 22 | color.input=default 23 | color.interact=bold 24 | color.message=reverse 25 | color.modmark= 26 | color.popup=#cccccc on #222222 27 | color.popup_border= 28 | color.popup_desc=default on #222222 29 | color.popup_footer= 30 | color.popup_header= 31 | color.popup_select= 32 | color.popup_selectdesc= 33 | color.prompt=bold 34 | color.readonly= 35 | color.selected_completion=reverse 36 | color.selection=white bold on bright black 37 | color.suggestion=#666666 38 | color.unexpected= 39 | color.unrecognized= 40 | -------------------------------------------------------------------------------- /clink/app/themes/Tomorrow Night Blue.clinktheme: -------------------------------------------------------------------------------- 1 | [preferred] 2 | background=#002451 3 | foreground=#ffffff 4 | 5 | [set] 6 | color.arg=#bbdaff 7 | color.arginfo=#ffc58f 8 | color.argmatcher=#9ec400 9 | color.cmd=#ebbbff 10 | color.cmdredir=#ffc58f 11 | color.cmdsep=#ffc58f 12 | color.comment_row=#bbdaff on #00346e 13 | color.common_match_prefix=#b777e0 14 | color.description=#d1f1a9 15 | color.doskey=#99ffff 16 | color.envvars=#54ced6 on #00346e 17 | color.escapetilde=#54ced6 on #00346e 18 | color.executable=#bbdaff 19 | color.filtered=#efefef 20 | color.flag=#ffeead 21 | # color.hidden= 22 | color.histexpand=#b777e0 on #00346e 23 | color.horizscroll=reverse 24 | color.input=#ffffff 25 | color.interact=#efefef 26 | color.message=#99ffff on #00346e 27 | color.modmark=#54ced6 28 | color.popup=#ffffff on #00346e 29 | color.popup_border=#4c7099 on #00346e 30 | color.popup_desc=#bbdaff on #00346e 31 | color.popup_footer=#7285b7 on #00346e 32 | color.popup_header=#ffeead on #00346e 33 | color.popup_select=#ffffff on #003f8e 34 | color.popup_selectdesc=#bbdaff on #003f8e 35 | # color.prompt= 36 | # color.readonly= 37 | color.selected_completion=#ffffff on #003f8e 38 | color.selection=#ffffff on #003f8e 39 | color.suggestion=#4c6585 40 | color.unexpected=#b2bdca 41 | color.unrecognized=#ff9da4 42 | -------------------------------------------------------------------------------- /clink/app/themes/Tomorrow Night Bright.clinktheme: -------------------------------------------------------------------------------- 1 | [preferred] 2 | background=#000000 3 | foreground=#eaeaea 4 | 5 | [set] 6 | color.arg=#7aa6da 7 | color.arginfo=#e78c45 8 | color.argmatcher=#9ec400 9 | color.cmd=#c397d8 10 | color.cmdredir=#e78c45 11 | color.cmdsep=#e78c45 12 | color.comment_row=#7aa6da on #2a2a2a 13 | color.common_match_prefix=#b777e0 14 | color.description=#b9ca4a 15 | color.doskey=#70c0b1 16 | color.envvars=#54ced6 on #2a2a2a 17 | color.escapetilde=#54ced6 on #2a2a2a 18 | color.executable=#7aa6da 19 | color.filtered=#efefef 20 | color.flag=#e7c547 21 | # color.hidden= 22 | color.histexpand=#b777e0 on #2a2a2a 23 | color.horizscroll=reverse 24 | color.input=#eaeaea 25 | color.interact=#efefef 26 | color.message=#70c0b1 on #2a2a2a 27 | color.modmark=#54ced6 28 | color.popup=#eaeaea on #2a2a2a 29 | color.popup_border=#636363 on #2a2a2a 30 | color.popup_desc=#7aa6da on #2a2a2a 31 | color.popup_footer=#969896 on #2a2a2a 32 | color.popup_header=#e7c547 on #2a2a2a 33 | color.popup_select=#eaeaea on #424242 34 | color.popup_selectdesc=#7aa6da on #424242 35 | # color.prompt= 36 | # color.readonly= 37 | color.selected_completion=#eaeaea on #424242 38 | color.selection=#eaeaea on #424242 39 | color.suggestion=#464646 40 | color.unexpected=#a3a3a3 41 | color.unrecognized=#d54e53 42 | -------------------------------------------------------------------------------- /clink/app/themes/Tomorrow Night Eighties.clinktheme: -------------------------------------------------------------------------------- 1 | [preferred] 2 | background=#2d2d2d 3 | foreground=#cccccc 4 | 5 | [set] 6 | color.arg=#6699cc 7 | color.arginfo=#f99157 8 | color.argmatcher=#9ec400 9 | color.cmd=#cc99cc 10 | color.cmdredir=#f99157 11 | color.cmdsep=#f99157 12 | color.comment_row=#6699cc on #393939 13 | color.common_match_prefix=#b777e0 14 | color.description=#99cc99 15 | color.doskey=#66cccc 16 | color.envvars=#54ced6 on #393939 17 | color.escapetilde=#54ced6 on #393939 18 | color.executable=#6699cc 19 | color.filtered=#efefef 20 | color.flag=#ffcc66 21 | # color.hidden= 22 | color.histexpand=#b777e0 on #393939 23 | color.horizscroll=reverse 24 | color.input=#cccccc 25 | color.interact=#efefef 26 | color.message=#66cccc on #393939 27 | color.modmark=#54ced6 28 | color.popup=#cccccc on #393939 29 | color.popup_border=#656565 on #393939 30 | color.popup_desc=#6699cc on #393939 31 | color.popup_footer=#999999 on #393939 32 | color.popup_header=#ffcc66 on #393939 33 | color.popup_select=#cccccc on #515151 34 | color.popup_selectdesc=#6699cc on #515151 35 | # color.prompt= 36 | # color.readonly= 37 | color.selected_completion=#cccccc on #515151 38 | color.selection=#cccccc on #515151 39 | color.suggestion=#5c5c5c 40 | color.unexpected=#9c9c9c 41 | color.unrecognized=#f2777a 42 | -------------------------------------------------------------------------------- /clink/app/themes/Tomorrow Night.clinktheme: -------------------------------------------------------------------------------- 1 | [preferred] 2 | background=#1d1f21 3 | foreground=#c5c8c6 4 | 5 | [set] 6 | color.arg=#81a2be 7 | color.arginfo=#de935f 8 | color.argmatcher=#9ec400 9 | color.cmd=#b294bb 10 | color.cmdredir=#de935f 11 | color.cmdsep=#de935f 12 | color.comment_row=#81a2be on #282a2e 13 | color.common_match_prefix=#b777e0 14 | color.description=#b5bd68 15 | color.doskey=#8abeb7 16 | color.envvars=#54ced6 on #282a2e 17 | color.escapetilde=#54ced6 on #282a2e 18 | color.executable=#81a2be 19 | color.filtered=#efefef 20 | color.flag=#f0c674 21 | # color.hidden= 22 | color.histexpand=#b777e0 on #282a2e 23 | color.horizscroll=reverse 24 | color.input=#c5c8c6 25 | color.interact=#efefef 26 | color.message=#8abeb7 on #282a2e 27 | color.modmark=#54ced6 28 | color.popup=#c5c8c6 on #282a2e 29 | color.popup_border=#57595b on #282a2e 30 | color.popup_desc=#81a2be on #282a2e 31 | color.popup_footer=#969896 on #282a2e 32 | color.popup_header=#f0c674 on #282a2e 33 | color.popup_select=#c5c8c6 on #373b41 34 | color.popup_selectdesc=#81a2be on #373b41 35 | # color.prompt= 36 | # color.readonly= 37 | color.selected_completion=#c5c8c6 on #373b41 38 | color.selection=#c5c8c6 on #373b41 39 | color.suggestion=#4f5152 40 | color.unexpected=#929594 41 | color.unrecognized=#cc6666 42 | -------------------------------------------------------------------------------- /clink/app/themes/Tomorrow.clinktheme: -------------------------------------------------------------------------------- 1 | [preferred] 2 | background=#ffffff 3 | foreground=#4d4d4c 4 | 5 | [set] 6 | color.arg=#4271ae 7 | color.arginfo=#f5871f 8 | color.argmatcher=#9ec400 9 | color.cmd=#8959a8 10 | color.cmdredir=#f5871f 11 | color.cmdsep=#f5871f 12 | color.comment_row=#4271ae on #efefef 13 | color.common_match_prefix=#b777e0 14 | color.description=#718c00 15 | color.doskey=#3e999f 16 | color.envvars=#54ced6 on #efefef 17 | color.escapetilde=#54ced6 on #efefef 18 | color.executable=#4271ae 19 | color.filtered=#222222 20 | color.flag=#eab700 21 | # color.hidden= 22 | color.histexpand=#b777e0 on #efefef 23 | color.horizscroll=reverse 24 | color.input=#4d4d4c 25 | color.interact=#222222 26 | color.message=#3e999f on #efefef 27 | color.modmark=#54ced6 28 | color.popup=#4d4d4c on #efefef 29 | color.popup_border=#bebebe on #efefef 30 | color.popup_desc=#4271ae on #efefef 31 | color.popup_footer=#8e908c on #efefef 32 | color.popup_header=#eab700 on #efefef 33 | color.popup_select=#4d4d4c on #d6d6d6 34 | color.popup_selectdesc=#4271ae on #d6d6d6 35 | # color.prompt= 36 | # color.readonly= 37 | color.selected_completion=#4d4d4c on #d6d6d6 38 | color.selection=#4d4d4c on #d6d6d6 39 | color.suggestion=#c9c9c9 40 | color.unexpected=#828281 41 | color.unrecognized=#c82829 42 | -------------------------------------------------------------------------------- /clink/core/include/core/assert_improved.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #ifdef DEBUG 7 | 8 | #define assert0(expr, fmt) ((void)(!!(expr) || (dbgassertf(__FILE__, __LINE__, fmt), 0))) 9 | #define assert1(expr, fmt, a) ((void)(!!(expr) || (dbgassertf(__FILE__, __LINE__, fmt, a), 0))) 10 | #define assert2(expr, fmt, a, b) ((void)(!!(expr) || (dbgassertf(__FILE__, __LINE__, fmt, a, b), 0))) 11 | #define assert3(expr, fmt, a, b, c) ((void)(!!(expr) || (dbgassertf(__FILE__, __LINE__, fmt, a, b, c), 0))) 12 | #define assert4(expr, fmt, a, b, c, d) ((void)(!!(expr) || (dbgassertf(__FILE__, __LINE__, fmt, a, b, c, d), 0))) 13 | #define assert5(expr, fmt, a, b, c, d, e) ((void)(!!(expr) || (dbgassertf(__FILE__, __LINE__, fmt, a, b, c, d, e), 0))) 14 | #define assert6(expr, fmt, a, b, c, d, e, f) ((void)(!!(expr) || (dbgassertf(__FILE__, __LINE__, fmt, a, b, c, d, e, f), 0))) 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | void dbgassertf(const char* file, unsigned line, const char* fmt, ...); 21 | void dbgtracef(const char* fmt, ...); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | 27 | #else // !DEBUG 28 | 29 | #define assert0(expr, fmt) ((void)0) 30 | #define assert1(expr, fmt, a) ((void)0) 31 | #define assert2(expr, fmt, a, b) ((void)0) 32 | #define assert3(expr, fmt, a, b, c) ((void)0) 33 | #define assert4(expr, fmt, a, b, c, d) ((void)0) 34 | #define assert5(expr, fmt, a, b, c, d, e) ((void)0) 35 | #define assert6(expr, fmt, a, b, c, d, e, f) ((void)0) 36 | 37 | #endif // !DEBUG 38 | -------------------------------------------------------------------------------- /clink/core/include/core/auto_free_str.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020-2022 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | //------------------------------------------------------------------------------ 7 | class auto_free_str 8 | { 9 | public: 10 | auto_free_str() = default; 11 | auto_free_str(const char* s, int32 len) { set(s, len); } 12 | auto_free_str(auto_free_str&& other) : m_ptr(other.m_ptr) { other.m_ptr = nullptr; } 13 | ~auto_free_str(); 14 | 15 | auto_free_str& operator=(const char* s) { set(s); return *this; } 16 | auto_free_str& operator=(auto_free_str&& other); 17 | void set(const char* s, int32 len = -1); 18 | const char* get() const { return m_ptr; } 19 | 20 | private: 21 | char* m_ptr = nullptr; 22 | }; 23 | -------------------------------------------------------------------------------- /clink/core/include/core/callstack.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #ifdef _MSC_VER 7 | 8 | #define MAX_ADDRESS_LEN (2 + 16) 9 | #define MAX_MODULE_LEN (24) 10 | #define MAX_SYMBOL_LEN (256) 11 | 12 | // MODULE "! " SYMBOL " + " 0xOFFSET "\r\n" or " / " 13 | #define MAX_FRAME_LEN (MAX_MODULE_LEN + 2 + MAX_SYMBOL_LEN + 3 + MAX_ADDRESS_LEN + 3) 14 | 15 | #define DEFAULT_CALLSTACK_LEN (MAX_FRAME_LEN * 20) 16 | 17 | #ifdef __cplusplus 18 | #define CALLSTACK_EXTERN_C extern "C" 19 | #endif 20 | 21 | // Formats buffer (capacity is size of buffer) with up to total_frames, skipping 22 | // the first skip_frames. The frames are delimited with newlines. 23 | CALLSTACK_EXTERN_C size_t format_callstack(int32 skip_frames, int32 total_frames, char* buffer, size_t capacity, int32 newlines); 24 | 25 | // Copies stack frame pointers. They can can formatted later with 26 | // format_frames(). 27 | CALLSTACK_EXTERN_C int32 get_callstack_frames(int32 skip_frames, int32 total_frames, void** frames, DWORD* hash); 28 | 29 | // Formats buffer (capacity is size of buffer) with up to total_frames. The 30 | // frames are delimited with slashes or newlines. 31 | CALLSTACK_EXTERN_C size_t format_frames(int32 total_frames, void* const* frames, DWORD hash, char* buffer, size_t capacity, int32 newlines); 32 | 33 | #endif // _MSC_VER -------------------------------------------------------------------------------- /clink/core/include/core/cwd_restorer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include "str.h" 7 | 8 | //------------------------------------------------------------------------------ 9 | namespace os 10 | { 11 | 12 | struct cwd_restorer 13 | { 14 | cwd_restorer(); 15 | ~cwd_restorer(); 16 | str_moveable m_path; 17 | }; 18 | 19 | }; // namespace os 20 | -------------------------------------------------------------------------------- /clink/core/include/core/embedded_scripts.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include // for #define ARCHITECTURE 7 | 8 | //------------------------------------------------------------------------------ 9 | #if defined(CLINK_FINAL) 10 | #define CLINK_USE_EMBEDDED_SCRIPTS 11 | #else 12 | //#define CLINK_USE_EMBEDDED_SCRIPTS 13 | #endif 14 | -------------------------------------------------------------------------------- /clink/core/include/core/globber.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include "str.h" 7 | 8 | //------------------------------------------------------------------------------ 9 | class globber 10 | { 11 | public: 12 | struct extrainfo 13 | { 14 | int32 st_mode; 15 | int32 attr; 16 | uint64 size; 17 | FILETIME accessed; 18 | FILETIME modified; 19 | FILETIME created; 20 | }; 21 | 22 | globber(const char* pattern); 23 | ~globber(); 24 | void files(bool state) { m_files = state; } 25 | void directories(bool state) { m_directories = state; } 26 | void suffix_dirs(bool state) { m_dir_suffix = state; } 27 | void hidden(bool state) { m_hidden = state; } 28 | void system(bool state) { m_system = state; } 29 | void dots(bool state) { m_dots = state; } 30 | bool older_than(int32 seconds); 31 | bool next(str_base& out, bool rooted=true, extrainfo* extrainfo=nullptr); 32 | void close(); 33 | 34 | private: 35 | globber(const globber&) = delete; 36 | void operator = (const globber&) = delete; 37 | void next_file(); 38 | WIN32_FIND_DATAW m_data; 39 | HANDLE m_handle; 40 | str<280> m_root; 41 | bool m_files; 42 | bool m_directories; 43 | bool m_dir_suffix; 44 | bool m_hidden; 45 | bool m_system; 46 | bool m_dots; 47 | bool m_onlyolder; 48 | FILETIME m_olderthan; 49 | 50 | }; 51 | -------------------------------------------------------------------------------- /clink/core/include/core/object.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | //------------------------------------------------------------------------------ 7 | struct object 8 | { 9 | virtual ~object() {} 10 | 11 | #if defined(USE_MEMORY_TRACKING) && defined(USE_RTTI) 12 | void* __cdecl object::operator new(size_t size); 13 | #endif 14 | }; 15 | 16 | //------------------------------------------------------------------------------ 17 | #if defined(USE_MEMORY_TRACKING) && defined(USE_RTTI) 18 | #define USE_DEBUG_OBJECT 19 | #endif 20 | -------------------------------------------------------------------------------- /clink/core/include/core/singleton.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | //------------------------------------------------------------------------------ 9 | template 10 | class singleton 11 | { 12 | public: 13 | singleton(); 14 | ~singleton(); 15 | static T* get(); 16 | 17 | private: 18 | static T*& get_store(); 19 | }; 20 | 21 | //------------------------------------------------------------------------------ 22 | template singleton::singleton() 23 | { 24 | assert(get_store() == nullptr); 25 | get_store() = (T*)this; 26 | } 27 | 28 | //------------------------------------------------------------------------------ 29 | template singleton::~singleton() 30 | { 31 | get_store() = nullptr; 32 | } 33 | 34 | //------------------------------------------------------------------------------ 35 | template T* singleton::get() 36 | { 37 | return get_store(); 38 | } 39 | 40 | //------------------------------------------------------------------------------ 41 | template T*& singleton::get_store() 42 | { 43 | static T* instance; 44 | return instance; 45 | } 46 | -------------------------------------------------------------------------------- /clink/core/include/core/str_hash.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | //------------------------------------------------------------------------------ 7 | template uint32 str_hash_impl(const T* in, uint32 length) 8 | { 9 | uint32 hash = 5381; 10 | 11 | while (int32 c = *in++) 12 | { 13 | hash = ((hash << 5) + hash) ^ c; 14 | if (!--length) 15 | break; 16 | } 17 | 18 | return hash; 19 | } 20 | 21 | //------------------------------------------------------------------------------ 22 | inline uint32 str_hash(const char* in, int32 length=-1) 23 | { 24 | return str_hash_impl(in, length); 25 | } 26 | 27 | //------------------------------------------------------------------------------ 28 | inline uint32 wstr_hash(const wchar_t* in, int32 length=-1) 29 | { 30 | return str_hash_impl(in, length); 31 | } 32 | -------------------------------------------------------------------------------- /clink/core/include/core/str_map.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020-2021 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | //------------------------------------------------------------------------------ 9 | struct cmp_str_case 10 | { 11 | bool operator()(const char* a, const char* b) const 12 | { 13 | return strcmp(a, b) < 0; 14 | } 15 | }; 16 | 17 | //------------------------------------------------------------------------------ 18 | struct cmp_str_caseless 19 | { 20 | bool operator()(const char* a, const char* b) const 21 | { 22 | return stricmp(a, b) < 0; 23 | } 24 | }; 25 | 26 | //------------------------------------------------------------------------------ 27 | // This C++11 syntax w/VS2019 causes clink_test_x64.exe to crash during startup. 28 | //template using str_map_case = std::map; 29 | //template using str_map_caseless = std::map; 30 | 31 | //------------------------------------------------------------------------------ 32 | // Alternative form using C++03. 33 | template struct str_map_case 34 | { 35 | typedef std::map type; 36 | }; 37 | template struct str_map_caseless 38 | { 39 | typedef std::map type; 40 | }; 41 | -------------------------------------------------------------------------------- /clink/core/include/core/str_transform.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include "base.h" 7 | 8 | #include 9 | 10 | class wstr_base; 11 | 12 | //------------------------------------------------------------------------------ 13 | enum transform_mode : int32 14 | { 15 | lower, 16 | upper, 17 | title, 18 | }; 19 | 20 | //------------------------------------------------------------------------------ 21 | void str_transform(const wchar_t* in, uint32 len, wstr_base& out, transform_mode mode); 22 | -------------------------------------------------------------------------------- /clink/core/include/core/str_unordered_set.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020-2021 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include "str_hash.h" 7 | #include 8 | #include 9 | 10 | //------------------------------------------------------------------------------ 11 | struct match_hasher 12 | { 13 | size_t operator()(const char* match) const 14 | { 15 | return str_hash(match); 16 | } 17 | size_t operator()(const wchar_t* match) const 18 | { 19 | return wstr_hash(match); 20 | } 21 | }; 22 | 23 | //------------------------------------------------------------------------------ 24 | struct match_comparator 25 | { 26 | bool operator()(const char* m1, const char* m2) const 27 | { 28 | return strcmp(m1, m2) == 0; 29 | } 30 | bool operator()(const wchar_t* m1, const wchar_t* m2) const 31 | { 32 | return wcscmp(m1, m2) == 0; 33 | } 34 | }; 35 | 36 | //------------------------------------------------------------------------------ 37 | typedef std::unordered_set str_unordered_set; 38 | typedef std::unordered_set wstr_unordered_set; 39 | template class str_unordered_map : public std::unordered_map {}; 40 | template class wstr_unordered_map : public std::unordered_map {}; 41 | -------------------------------------------------------------------------------- /clink/core/src/auto_free_str.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020-2022 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include "pch.h" 5 | 6 | #include 7 | 8 | #include "auto_free_str.h" 9 | 10 | //------------------------------------------------------------------------------ 11 | auto_free_str::~auto_free_str() 12 | { 13 | free(m_ptr); 14 | } 15 | 16 | //------------------------------------------------------------------------------ 17 | auto_free_str& auto_free_str::operator=(auto_free_str&& other) 18 | { 19 | free(m_ptr); 20 | m_ptr = other.m_ptr; 21 | other.m_ptr = nullptr; 22 | return *this; 23 | } 24 | 25 | //------------------------------------------------------------------------------ 26 | void auto_free_str::set(const char* s, int32 len) 27 | { 28 | if (!s) 29 | { 30 | free(m_ptr); 31 | m_ptr = nullptr; 32 | } 33 | else if (s == m_ptr) 34 | { 35 | if (len < int32(strlen(m_ptr))) 36 | m_ptr[len] = '\0'; 37 | } 38 | else 39 | { 40 | char* old = m_ptr; 41 | if (len < 0) 42 | len = int32(strlen(s)); 43 | m_ptr = (char*)malloc(len + 1); 44 | memcpy(m_ptr, s, len); 45 | m_ptr[len] = '\0'; 46 | free(old); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /clink/core/src/pch.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include "pch.h" 5 | -------------------------------------------------------------------------------- /clink/core/src/pch.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include "bldopts.h" 7 | 8 | #include "base.h" 9 | 10 | #include 11 | -------------------------------------------------------------------------------- /clink/core/src/str_iter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include "pch.h" 5 | #include "str_iter.h" 6 | 7 | //------------------------------------------------------------------------------ 8 | template <> 9 | int32 str_iter_impl::next() 10 | { 11 | if (!more()) 12 | return 0; 13 | 14 | int32 ax = 0; 15 | int32 encode_length = 0; 16 | while (int32 c = uint8(*m_ptr++)) 17 | { 18 | ax = (ax << 6) | (c & 0x7f); 19 | if (encode_length) 20 | { 21 | --encode_length; 22 | continue; 23 | } 24 | 25 | if ((c & 0xc0) < 0xc0) 26 | return ax; 27 | 28 | if (encode_length = !!(c & 0x20)) 29 | encode_length += !!(c & 0x10); 30 | 31 | ax &= (0x1f >> encode_length); 32 | 33 | if (!more()) 34 | break; 35 | } 36 | 37 | return 0; 38 | } 39 | 40 | //------------------------------------------------------------------------------ 41 | template <> 42 | int32 str_iter_impl::next() 43 | { 44 | if (!more()) 45 | return 0; 46 | 47 | int32 ax = 0; 48 | while (int32 c = *m_ptr++) 49 | { 50 | // Decode surrogate pairs. 51 | if ((c & 0xfc00) == 0xd800) 52 | { 53 | ax = c << 10; 54 | continue; 55 | } 56 | else if ((c & 0xfc00) == 0xdc00 && ax >= (1 << 10)) 57 | return ax + c - 0x35fdc00; 58 | else 59 | return c; 60 | } 61 | 62 | return 0; 63 | } 64 | 65 | //------------------------------------------------------------------------------ 66 | template <> 67 | uint32 str_iter_impl::length() const 68 | { 69 | return (uint32)((m_ptr <= m_end) ? m_end - m_ptr : strlen(m_ptr)); 70 | } 71 | 72 | //------------------------------------------------------------------------------ 73 | template <> 74 | uint32 str_iter_impl::length() const 75 | { 76 | return (uint32)((m_ptr <= m_end) ? m_end - m_ptr : wcslen(m_ptr)); 77 | } 78 | -------------------------------------------------------------------------------- /clink/core/test/wstr.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include "pch.h" 5 | 6 | #include 7 | 8 | #define str wstr 9 | #define str_moveable wstr_moveable 10 | #define STR(x) L##x 11 | #define NAME_SUFFIX " (wchar_t)" 12 | #include "str.cpp" 13 | #undef str 14 | #undef str_moveable 15 | -------------------------------------------------------------------------------- /clink/core/warning.h: -------------------------------------------------------------------------------- 1 | #pragma warning( 1: 5038 ) // data member 'member1' will be initialized after data member 'member2' -------------------------------------------------------------------------------- /clink/lib/include/lib/alias_cache.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | //------------------------------------------------------------------------------ 12 | class alias_cache 13 | { 14 | public: 15 | alias_cache() : m_names(4096) {} 16 | void clear(); 17 | bool get_alias(const char* name, str_base& out); 18 | private: 19 | str_map_caseless::type m_map; 20 | linear_allocator m_names; 21 | }; 22 | -------------------------------------------------------------------------------- /clink/lib/include/lib/clink_ctrlevent.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | void clink_install_ctrlevent(); 5 | void clink_shutdown_ctrlevent(); 6 | 7 | int32 clink_is_signaled(); 8 | 9 | void clink_set_signaled(int32 sig); // SIGINT, etc. 10 | -------------------------------------------------------------------------------- /clink/lib/include/lib/clink_rl_signal.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | void clink_sighandler(int32 sig); 9 | bool clink_maybe_handle_signal(); 10 | 11 | void force_signaled_redisplay(); 12 | -------------------------------------------------------------------------------- /clink/lib/include/lib/doskey.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | //------------------------------------------------------------------------------ 11 | class doskey_alias 12 | { 13 | public: 14 | doskey_alias(); 15 | void reset(); 16 | bool next(str_base& out); 17 | explicit operator bool () const; 18 | 19 | const str_base& UNITTEST_get_stream() const { return m_buffer; } 20 | 21 | private: 22 | friend class doskey; 23 | str<32> m_buffer; 24 | const char* m_cursor; 25 | }; 26 | 27 | 28 | 29 | //------------------------------------------------------------------------------ 30 | class doskey 31 | { 32 | public: 33 | doskey(const char* shell_name); 34 | doskey(const wchar_t* shell_name); 35 | bool add_alias(const char* alias, const char* text); 36 | bool remove_alias(const char* alias); 37 | void resolve(const char* chars, doskey_alias& out, int32* point=nullptr); 38 | 39 | private: 40 | bool resolve_impl(str_iter& s, class str_stream& out, int32* point); 41 | wstr<16> m_shell_name; 42 | }; 43 | -------------------------------------------------------------------------------- /clink/lib/include/lib/ellipsify.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | class str_base; 7 | 8 | typedef void (*vstrlen_func_t)(const char* s, int32 len); 9 | enum ellipsify_mode { INVALID=-1, RIGHT, LEFT, PATH }; 10 | 11 | int32 ellipsify(const char* in, int32 limit, str_base& out, bool expand_ctrl); 12 | int32 ellipsify_to_callback(const char* in, int32 limit, int32 expand_ctrl, vstrlen_func_t callback); 13 | int32 ellipsify_ex(const char* in, int32 limit, ellipsify_mode mode, str_base& out, const char* ellipsis=nullptr, bool expand_ctrl=false, bool* truncated=nullptr); 14 | 15 | extern const char* const ellipsis; 16 | #ifdef USE_ASCII_ELLIPSIS 17 | const int32 ellipsis_len = 3; 18 | const int32 ellipsis_cells = 3; 19 | #else 20 | const int32 ellipsis_len = 3; 21 | const int32 ellipsis_cells = 1; 22 | #endif 23 | -------------------------------------------------------------------------------- /clink/lib/include/lib/errfile_reader.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class errfile_reader 9 | { 10 | public: 11 | errfile_reader(); 12 | ~errfile_reader(); 13 | bool open(const char* name); 14 | bool next(str_base& out); 15 | private: 16 | FILE* m_file = nullptr; 17 | int8 m_utf16 = -1; 18 | wstr_moveable m_buffer; 19 | }; 20 | -------------------------------------------------------------------------------- /clink/lib/include/lib/hinter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include "core/str.h" 7 | 8 | class line_state; 9 | 10 | //------------------------------------------------------------------------------ 11 | class input_hint 12 | { 13 | public: 14 | bool empty() const { return m_empty; } 15 | void clear(); 16 | void set(const char* hint, int32 pos); 17 | bool equals(const input_hint& other) const; 18 | const char* c_str() const { return m_hint.c_str(); } 19 | int32 pos() const { return m_pos; } 20 | 21 | DWORD get_timeout() const; 22 | void clear_timeout(); 23 | 24 | private: 25 | str_moveable m_hint; 26 | int32 m_pos = -1; 27 | DWORD m_defer = 0; 28 | bool m_empty = true; 29 | }; 30 | 31 | //------------------------------------------------------------------------------ 32 | class hinter 33 | { 34 | public: 35 | virtual void get_hint(const line_state& line, input_hint& out) = 0; 36 | }; 37 | -------------------------------------------------------------------------------- /clink/lib/include/lib/history_timeformatter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | //------------------------------------------------------------------------------ 10 | class history_timeformatter 11 | { 12 | public: 13 | history_timeformatter(bool plaintext=false); 14 | ~history_timeformatter(); 15 | void set_timeformat(const char* timeformat, bool for_popup=false); 16 | uint32 max_timelen(); 17 | void format(time_t time, str_base& out); 18 | private: 19 | void ensure_timeformat(); 20 | str_moveable m_timeformat; 21 | uint32 m_max_timelen = 0; 22 | bool m_for_popup = false; 23 | const bool m_plaintext; 24 | }; 25 | -------------------------------------------------------------------------------- /clink/lib/include/lib/host_callbacks.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | //------------------------------------------------------------------------------ 9 | class line_state; 10 | class line_states; 11 | class matches; 12 | enum class recognition : char; 13 | 14 | //------------------------------------------------------------------------------ 15 | struct host_context 16 | { 17 | str_moveable binaries; 18 | str_moveable profile; 19 | str_moveable default_settings; 20 | str_moveable default_inputrc; 21 | str_moveable settings; 22 | str_moveable scripts; 23 | }; 24 | 25 | //------------------------------------------------------------------------------ 26 | class host_callbacks 27 | { 28 | public: 29 | virtual void filter_prompt() = 0; 30 | virtual void filter_transient_prompt(bool final) = 0; 31 | virtual bool can_suggest(const line_state& line) = 0; 32 | virtual bool suggest(const line_states& lines, matches* matches, int32 generation_id) = 0; 33 | virtual bool filter_matches(char** matches) = 0; 34 | virtual bool call_lua_rl_global_function(const char* func_name, const line_state* line) = 0; 35 | virtual const char** copy_dir_history(int32* total) = 0; 36 | virtual void send_event(const char* event_name) = 0; 37 | virtual void send_oncommand_event(line_state& line, const char* command, bool quoted, recognition recog, const char* file) = 0; 38 | virtual void send_oninputlinechanged_event(const char* line) = 0; 39 | virtual bool has_event_handler(const char* event_name) = 0; 40 | virtual bool get_command_word(line_state& line, str_base& command_word, bool& quoted, recognition& recog, str_base& file) = 0; 41 | }; 42 | 43 | //------------------------------------------------------------------------------ 44 | void host_cmd_enqueue_lines(std::list& lines, bool hide_prompt, bool show_line); 45 | void host_get_app_context(int32& id, host_context& context); 46 | -------------------------------------------------------------------------------- /clink/lib/include/lib/input_params.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022-2023 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | //------------------------------------------------------------------------------ 7 | class input_params 8 | { 9 | public: 10 | bool get(uint32 param, uint32& value) const; 11 | uint32 count() const; 12 | short length() const; 13 | protected: 14 | bool add(unsigned short value, uint8 len); 15 | void clear(); 16 | private: 17 | unsigned short m_params[4]; 18 | uint8 m_num = 0; 19 | short m_len = 0; 20 | }; 21 | -------------------------------------------------------------------------------- /clink/lib/include/lib/intercept.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | class str_base; 7 | 8 | //------------------------------------------------------------------------------ 9 | enum class intercept_result : uint8 10 | { 11 | none, 12 | prev_dir, 13 | chdir, 14 | }; 15 | 16 | //------------------------------------------------------------------------------ 17 | intercept_result intercept_directory(const char* line, str_base* out=nullptr, bool only_cd_chdir=false); 18 | void make_cd_command(const char* dir, str_base& out); 19 | -------------------------------------------------------------------------------- /clink/lib/include/lib/line_buffer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | struct word; 9 | 10 | //------------------------------------------------------------------------------ 11 | class line_buffer 12 | { 13 | public: 14 | virtual ~line_buffer() = default; 15 | virtual void reset() = 0; 16 | virtual void begin_line() = 0; 17 | virtual void end_line() = 0; 18 | virtual const char* get_buffer() const = 0; 19 | virtual uint32 get_length() const = 0; 20 | virtual uint32 get_cursor() const = 0; 21 | virtual int32 get_anchor() const = 0; 22 | virtual uint32 set_cursor(uint32 pos) = 0; 23 | virtual void set_selection(uint32 anchor, uint32 pos) = 0; 24 | virtual bool insert(const char* text) = 0; 25 | virtual bool remove(uint32 from, uint32 to) = 0; 26 | virtual void begin_undo_group() = 0; 27 | virtual void end_undo_group() = 0; 28 | virtual bool undo() = 0; 29 | virtual void draw() = 0; 30 | virtual void redraw() = 0; 31 | virtual void set_need_draw() = 0; 32 | }; 33 | -------------------------------------------------------------------------------- /clink/lib/include/lib/match_colors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "matches.h" 4 | 5 | #if defined(__MINGW32__) || defined(__MINGW64__) 6 | #define enum_indicator_no int32 7 | #else 8 | #define enum_indicator_no enum indicator_no 9 | #endif 10 | 11 | void parse_match_colors(); 12 | bool using_match_colors(); 13 | bool get_match_color(const char* filename, match_type type, str_base& out); 14 | const char* get_indicator_color(enum_indicator_no colored_filetype); 15 | const char* get_completion_prefix_color(); 16 | bool is_colored(enum_indicator_no colored_filetype); 17 | void make_color(const char* seq, str_base& out); 18 | -------------------------------------------------------------------------------- /clink/lib/include/lib/match_generator.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | class line_state; 7 | class line_states; 8 | class match_builder; 9 | struct match_display_filter_entry; 10 | enum class display_filter_flags; 11 | 12 | //------------------------------------------------------------------------------ 13 | struct word_break_info 14 | { 15 | word_break_info() { clear(); } 16 | void clear() { truncate = 0; keep = 0; } 17 | 18 | int32 truncate : 16; 19 | int32 keep : 16; 20 | }; 21 | 22 | //------------------------------------------------------------------------------ 23 | class match_generator 24 | { 25 | public: 26 | virtual bool generate(const line_states& line, match_builder& builder, bool old_filtering=false) = 0; 27 | virtual void get_word_break_info(const line_state& line, word_break_info& info) const = 0; 28 | virtual bool match_display_filter(const char* needle, char** matches, match_builder* builder, display_filter_flags flag, bool nosort, bool* old_filtering=nullptr) { return false; } 29 | virtual bool filter_matches(char** matches, char completion_type, bool filename_completion_desired) { return false; } 30 | 31 | private: 32 | }; 33 | -------------------------------------------------------------------------------- /clink/lib/include/lib/pager.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Christopher Antos, Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include "editor_module.h" 7 | 8 | class printer; 9 | 10 | //------------------------------------------------------------------------------ 11 | class pager 12 | { 13 | public: 14 | virtual void start_pager(printer& printer) = 0; 15 | virtual bool on_print_lines(printer& printer, int32 lines) = 0; 16 | }; 17 | 18 | //------------------------------------------------------------------------------ 19 | void print_pager_prompt(bool help=false); 20 | -------------------------------------------------------------------------------- /clink/lib/include/lib/reclassify.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | //------------------------------------------------------------------------------ 7 | enum class reclassify_reason : uint8 8 | { 9 | recognizer, 10 | hinter, 11 | force, 12 | lazy_force, 13 | }; 14 | 15 | //------------------------------------------------------------------------------ 16 | void reclassify(reclassify_reason why); 17 | -------------------------------------------------------------------------------- /clink/lib/include/lib/recognizer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | class str_base; 7 | 8 | enum class recognition : char { unrecognized = -1, unknown, executable, navigate, max }; 9 | 10 | recognition recognize_command(const char* line, const char* word, bool quoted, bool& ready, str_base* file); 11 | 12 | HANDLE get_recognizer_event(); 13 | bool check_recognizer_refresh(); 14 | 15 | extern "C" void end_recognizer(); 16 | void shutdown_recognizer(); 17 | -------------------------------------------------------------------------------- /clink/lib/include/lib/scroll_car.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #ifdef SHOW_VERT_SCROLLBARS 7 | bool use_vert_scrollbars(); 8 | int32 calc_scroll_car_size(int32 rows, int32 total); 9 | int32 calc_scroll_car_offset(int32 top, int32 rows, int32 total, int32 car_size); 10 | const char* get_scroll_car_char(int32 visible_offset, int32 car_offset, int32 car_size, bool floating); 11 | int32 hittest_scroll_car(int32 row, int32 rows, int32 total); 12 | #endif 13 | -------------------------------------------------------------------------------- /clink/lib/include/lib/slash_translation.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | //------------------------------------------------------------------------------ 7 | namespace slash_translation { 8 | 9 | enum 10 | { 11 | // IMPORTANT: Do not rearrange these values! They are documented and are 12 | // persisted in the clink_settings file and referenced by numeric value in 13 | // Lua scripts. 14 | 15 | // IMPORTANT: Keep these in sync with the match.translate_slashes setting. 16 | 17 | off, 18 | system, 19 | slash, 20 | backslash, 21 | automatic, // Can't name it 'auto' because that's a reserved keyword. 22 | max 23 | }; 24 | 25 | } 26 | 27 | //------------------------------------------------------------------------------ 28 | class str_base; 29 | 30 | //------------------------------------------------------------------------------ 31 | void set_slash_translation(int32 mode); 32 | int32 get_slash_translation(); 33 | void do_slash_translation(str_base& in_out, const char* sep=nullptr); 34 | -------------------------------------------------------------------------------- /clink/lib/include/lib/sticky_search.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | bool has_sticky_search_position(); 7 | 8 | void save_sticky_search_position(); 9 | void capture_sticky_search_position(); 10 | void restore_sticky_search_position(); 11 | void clear_sticky_search_position(); 12 | 13 | bool can_sticky_search_add_history(const char* line); 14 | -------------------------------------------------------------------------------- /clink/lib/include/lib/wakeup_chars.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | class str_base; 9 | 10 | void set_ctrl_wakeup_mask(uint32 mask); 11 | void strip_wakeup_chars(wchar_t* chars, uint32 max_chars); 12 | void strip_wakeup_chars(str_base& out); 13 | -------------------------------------------------------------------------------- /clink/lib/include/lib/word_classifier.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | class line_states; 7 | class word_classifications; 8 | 9 | #include 10 | 11 | //------------------------------------------------------------------------------ 12 | class word_classifier 13 | { 14 | public: 15 | virtual void classify(const line_states& commands, word_classifications& classifications) = 0; 16 | }; 17 | -------------------------------------------------------------------------------- /clink/lib/src/alias_cache.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include "pch.h" 5 | #include "alias_cache.h" 6 | 7 | #include 8 | 9 | //------------------------------------------------------------------------------ 10 | void alias_cache::clear() 11 | { 12 | m_map.clear(); 13 | m_names.clear(); 14 | } 15 | 16 | //------------------------------------------------------------------------------ 17 | bool alias_cache::get_alias(const char* name, str_base& out) 18 | { 19 | const auto& iter = m_map.find(name); 20 | if (iter != m_map.end()) 21 | { 22 | const char* value = iter->second.get(); 23 | if (!value || !*value) 24 | return false; 25 | out = value; 26 | return true; 27 | } 28 | 29 | const bool exists = os::get_alias(name, out); 30 | 31 | const char* cache_name = m_names.store(name); 32 | auto_free_str cache_value(out.c_str(), out.length()); 33 | m_map.emplace(cache_name, std::move(cache_value)); 34 | 35 | return exists; 36 | } 37 | -------------------------------------------------------------------------------- /clink/lib/src/column_widths.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Christopher Antos 2 | // 3 | // Portions Copyright (C) 1985-2022 Free Software Foundation, Inc. 4 | // https://github.com/coreutils/coreutils/blob/3067a9293af07ba2cf1ababe6b4482196717f806/src/ls.c 5 | // License: https://github.com/coreutils/coreutils/blob/5b9d747261590ffde5f47fcf8cef06ee5bb5df63/COPYING 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | #define USE_DESC_PARENS 12 | 13 | class match_adapter; 14 | 15 | //------------------------------------------------------------------------------ 16 | typedef unsigned short width_t; 17 | 18 | //------------------------------------------------------------------------------ 19 | struct column_widths 20 | { 21 | size_t num_columns() const { return m_widths.size(); } 22 | width_t column_width(size_t i) const { return m_widths[i]; } 23 | width_t max_match_len(size_t i) const { return m_max_match_len_in_column[i]; } 24 | std::vector m_widths; 25 | std::vector m_max_match_len_in_column; 26 | width_t m_col_padding = 0; // Padding between columns. 27 | width_t m_desc_padding = 0; // Min padding between match and description. 28 | width_t m_sind = 0; // LCD length. 29 | bool m_can_condense = false; 30 | bool m_right_justify = false; 31 | }; 32 | 33 | //------------------------------------------------------------------------------ 34 | // Calculates column widths to fit as many columns of matches as possible. 35 | // MAX_MATCHES < 0 makes all columns the same width. 36 | // MAX_MATCHES > 0 disables fitting if the matches exceeds MAX_MATCHES. 37 | // MAX_MATCHES == 0 is unlimited. 38 | column_widths calculate_columns( 39 | const match_adapter& adapter, 40 | int32 max_matches=0, 41 | bool one_column=false, 42 | bool omit_desc=false, 43 | width_t extra=0, 44 | int32 presuf=0); 45 | -------------------------------------------------------------------------------- /clink/lib/src/input_dispatcher.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Christopher Antos, Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | //------------------------------------------------------------------------------ 7 | class input_dispatcher 8 | { 9 | public: 10 | virtual void dispatch(int32 bind_group) = 0; 11 | virtual bool available(uint32 timeout) = 0; 12 | virtual uint8 peek() = 0; 13 | }; 14 | -------------------------------------------------------------------------------- /clink/lib/src/input_params.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022-2023 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include "pch.h" 5 | #include "input_params.h" 6 | #include 7 | #include 8 | 9 | //------------------------------------------------------------------------------ 10 | bool input_params::get(uint32 param, uint32& value) const 11 | { 12 | if (param >= m_num) 13 | { 14 | value = 0; 15 | return false; 16 | } 17 | 18 | value = m_params[param]; 19 | return true; 20 | } 21 | 22 | //------------------------------------------------------------------------------ 23 | uint32 input_params::count() const 24 | { 25 | return m_num; 26 | } 27 | 28 | //------------------------------------------------------------------------------ 29 | short input_params::length() const 30 | { 31 | return m_len; 32 | } 33 | 34 | //------------------------------------------------------------------------------ 35 | bool input_params::add(unsigned short value, uint8 len) 36 | { 37 | if (m_num >= sizeof_array(m_params)) 38 | return false; 39 | 40 | m_params[m_num++] = value; 41 | m_len += len; 42 | 43 | // Offset the '*' key, so that depth + len is always the key sequence 44 | // length, even when the param is empty (no digits). 45 | m_len--; 46 | return true; 47 | } 48 | 49 | //------------------------------------------------------------------------------ 50 | void input_params::clear() 51 | { 52 | m_num = 0; 53 | m_len = 0; 54 | } 55 | -------------------------------------------------------------------------------- /clink/lib/src/match_pipeline.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | class line_states; 9 | class match_generator; 10 | class matches_impl; 11 | 12 | //------------------------------------------------------------------------------ 13 | class match_pipeline 14 | { 15 | public: 16 | match_pipeline(matches_impl& matches); 17 | void reset() const; 18 | void set_no_sort(); 19 | void generate(const line_states& states, match_generator* generator, bool old_filtering=false) const; 20 | void restrict(str_base& needle) const; 21 | void restrict(char** keep_matches) const; 22 | void select(const char* needle) const; 23 | void sort() const; 24 | 25 | private: 26 | matches_impl& m_matches; 27 | }; 28 | -------------------------------------------------------------------------------- /clink/lib/src/pager_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Christopher Antos, Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include "editor_module.h" 7 | #include "input_dispatcher.h" 8 | #include "pager.h" 9 | 10 | //------------------------------------------------------------------------------ 11 | class pager_impl 12 | : public editor_module 13 | , public pager 14 | { 15 | public: 16 | enum pager_amount { unlimited, line, half_page, page, first_page }; 17 | pager_impl(input_dispatcher& dispatcher); 18 | virtual void start_pager(printer& printer) override; 19 | virtual bool on_print_lines(printer& printer, int32 lines) override; 20 | 21 | private: 22 | virtual void bind_input(binder& binder) override; 23 | virtual void on_begin_line(const context& context) override; 24 | virtual void on_end_line() override; 25 | virtual void on_input(const input& input, result& result, const context& context) override; 26 | virtual void on_matches_changed(const context& context, const line_state& line, const char* needle) override; 27 | virtual void on_terminal_resize(int32 columns, int32 rows, const context& context) override; 28 | virtual void on_signal(int32 sig) override; 29 | void set_limit(printer& printer, pager_amount amount); 30 | int32 m_max = 0; 31 | int32 m_pager_bind_group = -1; 32 | input_dispatcher& m_dispatcher; 33 | }; 34 | -------------------------------------------------------------------------------- /clink/lib/src/pch.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include "pch.h" 5 | -------------------------------------------------------------------------------- /clink/lib/src/pch.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | #include 17 | -------------------------------------------------------------------------------- /clink/lib/src/scroll_helper.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include "pch.h" 5 | #include 6 | #include "scroll_helper.h" 7 | 8 | //------------------------------------------------------------------------------ 9 | scroll_helper::scroll_helper() 10 | { 11 | clear(); 12 | } 13 | 14 | //------------------------------------------------------------------------------ 15 | void scroll_helper::clear() 16 | { 17 | m_scroll_tick = m_accelerate_tick = GetTickCount() - 0xffff; 18 | m_can_scroll = false; 19 | } 20 | 21 | //------------------------------------------------------------------------------ 22 | bool scroll_helper::can_scroll() const 23 | { 24 | return m_can_scroll; 25 | } 26 | 27 | //------------------------------------------------------------------------------ 28 | uint32 scroll_helper::scroll_speed() const 29 | { 30 | return m_scroll_speed; 31 | } 32 | 33 | //------------------------------------------------------------------------------ 34 | uint32 scroll_helper::on_input() 35 | { 36 | const uint32 now = GetTickCount(); 37 | m_can_scroll = (now - m_scroll_tick) > 15; 38 | if (now - m_scroll_tick > 250) 39 | m_accelerate_tick = now; 40 | const uint32 accelerate_duration = (now - m_accelerate_tick); 41 | m_scroll_speed = ((accelerate_duration > 2000) ? 10 : 42 | (accelerate_duration > 1000) ? 3 : 1); 43 | return now; 44 | } 45 | 46 | //------------------------------------------------------------------------------ 47 | void scroll_helper::on_scroll(uint32 now) 48 | { 49 | m_scroll_tick = now; 50 | } -------------------------------------------------------------------------------- /clink/lib/src/scroll_helper.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | //------------------------------------------------------------------------------ 7 | class scroll_helper 8 | { 9 | public: 10 | scroll_helper(); 11 | void clear(); 12 | bool can_scroll() const; 13 | uint32 scroll_speed() const; 14 | uint32 on_input(); 15 | void on_scroll(uint32 now); 16 | private: 17 | uint32 m_scroll_tick; 18 | uint32 m_accelerate_tick; 19 | uint32 m_scroll_speed; 20 | bool m_can_scroll; 21 | }; 22 | -------------------------------------------------------------------------------- /clink/lib/src/slash_translation.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include "pch.h" 5 | #include "slash_translation.h" 6 | 7 | #include 8 | #include 9 | 10 | //------------------------------------------------------------------------------ 11 | static int32 s_slash_translation = slash_translation::off; 12 | 13 | //------------------------------------------------------------------------------ 14 | void set_slash_translation(int32 mode) 15 | { 16 | s_slash_translation = mode; 17 | } 18 | 19 | //------------------------------------------------------------------------------ 20 | int32 get_slash_translation() 21 | { 22 | return s_slash_translation; 23 | } 24 | 25 | //------------------------------------------------------------------------------ 26 | void do_slash_translation(str_base& in_out, const char* _sep) 27 | { 28 | assert(s_slash_translation > slash_translation::off); 29 | 30 | uint8 sep; 31 | 32 | switch (s_slash_translation) 33 | { 34 | default: 35 | sep = 0; 36 | break; 37 | 38 | case slash_translation::slash: 39 | sep = '/'; 40 | break; 41 | 42 | case slash_translation::backslash: 43 | sep = '\\'; 44 | break; 45 | 46 | case slash_translation::automatic: 47 | // Use whatever sep was passed in by the caller. 48 | // Or if the caller passed nullptr, use the system path separator. 49 | sep = _sep ? *_sep : 0; 50 | break; 51 | } 52 | 53 | assert(sep == 0 || sep == '/' || sep == '\\'); 54 | 55 | path::normalise_separators(in_out, sep); 56 | } 57 | 58 | -------------------------------------------------------------------------------- /clink/lib/src/wakeup_chars.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include "pch.h" 5 | #include "wakeup_chars.h" 6 | 7 | #include 8 | 9 | #include 10 | 11 | //------------------------------------------------------------------------------ 12 | static uint32 s_dwCtrlWakeupMask = 0; 13 | void set_ctrl_wakeup_mask(uint32 mask) 14 | { 15 | s_dwCtrlWakeupMask = mask; 16 | } 17 | 18 | //------------------------------------------------------------------------------ 19 | template void strip_wakeup_chars_worker(T* chars, uint32 max_chars) 20 | { 21 | if (!max_chars) 22 | return; 23 | 24 | T* read = chars; 25 | T* write = chars; 26 | 27 | while (max_chars--) 28 | { 29 | const T c = *read; 30 | if (!c) 31 | break; 32 | 33 | if (c < 0 || c >= 32 || !(s_dwCtrlWakeupMask & 1 << c)) 34 | { 35 | if (write != read) 36 | *write = c; 37 | ++write; 38 | } 39 | 40 | ++read; 41 | } 42 | 43 | if (write != read) 44 | *write = '\0'; 45 | } 46 | 47 | //------------------------------------------------------------------------------ 48 | void strip_wakeup_chars(wchar_t* chars, uint32 max_chars) 49 | { 50 | strip_wakeup_chars_worker(chars, max_chars); 51 | } 52 | 53 | //------------------------------------------------------------------------------ 54 | void strip_wakeup_chars(str_base& out) 55 | { 56 | uint32 max_chars = out.length(); 57 | strip_wakeup_chars_worker(out.data(), max_chars); 58 | } 59 | -------------------------------------------------------------------------------- /clink/lua/include/lua/lua_hinter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include "lib/hinter.h" 7 | 8 | class lua_state; 9 | class line_state; 10 | 11 | //------------------------------------------------------------------------------ 12 | class lua_hinter : public hinter 13 | { 14 | public: 15 | lua_hinter(lua_state& lua); 16 | void get_hint(const line_state& line, input_hint& out) override; 17 | 18 | private: 19 | lua_state& m_lua; 20 | }; 21 | -------------------------------------------------------------------------------- /clink/lua/include/lua/lua_input_idle.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include "terminal/input_idle.h" 7 | 8 | class lua_state; 9 | 10 | //------------------------------------------------------------------------------ 11 | class lua_input_idle 12 | : public input_idle 13 | { 14 | public: 15 | lua_input_idle(lua_state& state); 16 | ~lua_input_idle(); 17 | void reset() override; 18 | uint32 get_timeout() override; 19 | uint32 get_wait_events(void** events, size_t max) override; 20 | void on_wait_event(uint32 index) override; 21 | void on_idle() override; 22 | 23 | void kick(); 24 | 25 | static void signal_delayed_init(); 26 | static void signal_reclassify(); 27 | static HANDLE get_idle_event(); 28 | 29 | private: 30 | bool is_enabled(); 31 | bool has_coroutines(); 32 | void resume_coroutines(); 33 | lua_state& m_state; 34 | uint32 m_iterations = 0; 35 | bool m_enabled = true; 36 | 37 | uint32 m_index_recognizer = -1; 38 | uint32 m_index_task_manager = -1; 39 | uint32 m_index_force_idle = -1; 40 | 41 | static bool s_signaled_delayed_init; 42 | static bool s_signaled_reclassify; 43 | }; 44 | -------------------------------------------------------------------------------- /clink/lua/include/lua/lua_match_generator.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | class lua_state; 9 | struct lua_State; 10 | 11 | //------------------------------------------------------------------------------ 12 | class lua_match_generator 13 | : public match_generator 14 | { 15 | public: 16 | lua_match_generator(lua_state& lua); 17 | lua_match_generator(lua_State* state); 18 | virtual ~lua_match_generator(); 19 | 20 | virtual bool filter_matches(char** matches, char completion_type, bool filename_completion_desired) override; 21 | 22 | private: 23 | virtual bool generate(const line_states& lines, match_builder& builder, bool old_filtering=false) override; 24 | virtual void get_word_break_info(const line_state& line, word_break_info& info) const override; 25 | virtual bool match_display_filter(const char* needle, char** matches, match_builder* builder, display_filter_flags flags, bool nosort, bool* old_filtering=nullptr) override; 26 | lua_State* get_state() const; 27 | lua_state* m_lua = nullptr; 28 | lua_State* m_state = nullptr; 29 | }; 30 | -------------------------------------------------------------------------------- /clink/lua/include/lua/lua_script_loader.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #if defined(CLINK_USE_EMBEDDED_SCRIPTS) 9 | void lua_load_script_impl(class lua_state&, const char*, const char*, int32); 10 | 11 | #define lua_load_script(state, module, name) \ 12 | do { \ 13 | extern const uint8* const module##_##name##_lua_script; \ 14 | extern const int32 module##_##name##_lua_script_len; \ 15 | lua_load_script_impl( \ 16 | state, \ 17 | "@~clink~/" #module "/" #name ".lua", \ 18 | (char*)module##_##name##_lua_script, \ 19 | module##_##name##_lua_script_len); \ 20 | } while(0) 21 | #else 22 | void lua_load_script_impl(class lua_state&, const char*, int32); 23 | 24 | #define lua_load_script(state, module, name) \ 25 | do { \ 26 | extern const char* const module##_##name##_lua_file; \ 27 | lua_load_script_impl(state, module##_##name##_lua_file, 0); \ 28 | } while(0) 29 | #endif // CLINK_USE_EMBEDDED_SCRIPTS 30 | -------------------------------------------------------------------------------- /clink/lua/include/lua/lua_task_manager.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | class lua_state; 5 | 6 | HANDLE get_task_manager_event(); 7 | void task_manager_on_idle(lua_state& lua); 8 | void task_manager_diagnostics(); 9 | extern "C" void end_task_manager(); 10 | void shutdown_task_manager(bool final); 11 | -------------------------------------------------------------------------------- /clink/lua/include/lua/lua_word_classifications.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include "lua_bindable.h" 7 | 8 | struct lua_State; 9 | enum class word_class : uint8; 10 | class word_classifications; 11 | 12 | //------------------------------------------------------------------------------ 13 | // word_classifications collects the coloring info for the whole input line. 14 | // lua_word_classifications wraps it to apply coloring info only to the words 15 | // for a given line_state (group of words for a command) from the input line. 16 | class lua_word_classifications 17 | : public lua_bindable 18 | { 19 | public: 20 | lua_word_classifications(word_classifications& classifications, uint32 index_offset, uint32 command_word_index, uint32 num_words); 21 | 22 | bool get_word_class(int32 word_index_zero_based, word_class& wc) const; 23 | 24 | protected: 25 | int32 classify_word(lua_State* state); 26 | int32 apply_color(lua_State* state); 27 | int32 shift(lua_State* state); 28 | int32 reset_shift(lua_State* state); 29 | int32 break_word(lua_State* state); 30 | int32 unbreak_word(lua_State* state); 31 | #ifdef DEBUG 32 | int32 get_word_count(lua_State* state); 33 | int32 get_word_start(lua_State* state); 34 | int32 get_word_end(lua_State* state); 35 | #endif 36 | 37 | private: 38 | word_classifications& m_classifications; 39 | const uint32 m_index_offset; 40 | uint32 m_num_words; 41 | uint32 m_command_word_index; 42 | uint32 m_shift = 0; 43 | const uint32 m_original_command_word_index; 44 | 45 | friend class lua_bindable; 46 | static const char* const c_name; 47 | static const method c_methods[]; 48 | }; 49 | -------------------------------------------------------------------------------- /clink/lua/include/lua/lua_word_classifier.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include "core/str.h" 7 | #include "lib/word_classifier.h" 8 | #include "lib/word_classifications.h" 9 | 10 | class lua_state; 11 | 12 | //------------------------------------------------------------------------------ 13 | class lua_word_classifier 14 | : public word_classifier 15 | { 16 | public: 17 | lua_word_classifier(lua_state& state); 18 | virtual void classify(const line_states& commands, word_classifications& classifications) override; 19 | 20 | private: 21 | lua_state& m_state; 22 | }; 23 | -------------------------------------------------------------------------------- /clink/lua/include/lua/suggest.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | class lua_state; 7 | class str_base; 8 | class line_states; 9 | class matches; 10 | 11 | //------------------------------------------------------------------------------ 12 | class suggester 13 | { 14 | public: 15 | suggester(lua_state& lua); 16 | bool suggest(const line_states& lines, matches* matches, int32 generation_id); 17 | 18 | private: 19 | lua_state& m_lua; 20 | }; 21 | -------------------------------------------------------------------------------- /clink/lua/scripts/_manifest.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2015 Martin Ridgers 2 | -- License: http://opensource.org/licenses/MIT 3 | 4 | return { 5 | name = "lib", 6 | files = { 7 | "error.lua", 8 | "core.lua", 9 | "events.lua", 10 | "console.lua", 11 | "coroutines.lua", 12 | "generator.lua", 13 | "arguments.lua", 14 | "classifier.lua", 15 | "hinter.lua", 16 | "debugger.lua", 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /clink/lua/scripts/console.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2021 Christopher Antos 2 | -- License: http://opensource.org/licenses/MIT 3 | 4 | -------------------------------------------------------------------------------- 5 | --- -name: console.screengrab 6 | --- -ver: 1.1.40 7 | --- -arg: candidate_pattern:string 8 | --- -arg: accept_pattern:string 9 | --- -ret: table 10 | --- Uses the provided Lua string patterns to collect text from the current 11 | --- console screen and returns a table of matching text snippets. The snippets 12 | --- are ordered by distance from the input line. 13 | --- 14 | --- For example candidate_pattern could specify a 15 | --- pattern that identifies words, and accept_pattern 16 | --- could specify a pattern that matches words composed of hexadecimal digits. 17 | --- -show: local matches = console.screengrab( 18 | --- -show:   "[^%w]*(%w%w[%w]+)", -- Words with 3 or more letters are candidates. 19 | --- -show:   "^%x+$") -- A candidate containing only hexadecimal digits is a match. 20 | function console.screengrab(candidate_pattern, accept_pattern) 21 | local matches = {} 22 | 23 | local _end = console.gettop() 24 | local _start = _end + console.getheight() - 1 25 | 26 | if _start >= console.getnumlines() then 27 | _start = console.getnumlines() - 1 28 | end 29 | 30 | for i = _start,_end,-1 do 31 | local line = console.getlinetext(i) 32 | if line then 33 | -- Collect candidates from the line. 34 | local words = {} 35 | for word in line:gmatch(candidate_pattern) do 36 | -- Accept matching candidates. 37 | if word:match(accept_pattern) then 38 | table.insert(words, word) 39 | end 40 | end 41 | 42 | -- Add the matches in reverse order so they're in proximity order. 43 | for j = #words,1,-1 do 44 | table.insert(matches, words[j]) 45 | end 46 | end 47 | end 48 | 49 | return matches 50 | end 51 | -------------------------------------------------------------------------------- /clink/lua/src/command_link_dialog.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | //------------------------------------------------------------------------------ 9 | class command_link_dialog 10 | { 11 | typedef bool (*cld_callback_t)(HWND hdlg, uint32 index); 12 | 13 | struct button_details 14 | { 15 | int32 m_choice; 16 | str_moveable m_caption1; 17 | wstr_moveable m_caption2; 18 | bool m_command_link = false; 19 | cld_callback_t m_handler = nullptr; 20 | }; 21 | 22 | public: 23 | command_link_dialog(); 24 | ~command_link_dialog(); 25 | void add(int32 choice, const char* caption1, const char* caption2=nullptr, cld_callback_t handler=nullptr); 26 | int32 do_modal(HWND parent, int16 width, const char* title, const char* message); 27 | 28 | protected: 29 | INT_PTR dlgproc(UINT msg, WPARAM wParam, LPARAM lParam); 30 | bool on_command(WORD id, HWND hwnd, WORD code); 31 | void owner_draw(HWND hwnd, HDC hdc, DWORD dwState, uint32 index); 32 | void custom_draw(NMCUSTOMDRAW const* pnm, uint32 index); 33 | void end_dialog(int32 choice); 34 | 35 | static INT_PTR CALLBACK static_dlgproc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); 36 | 37 | private: 38 | HWND m_hdlg = 0; 39 | std::vector m_buttons; 40 | str_moveable m_title; 41 | str_moveable m_message; 42 | int32 m_width; 43 | int32 m_choice = 0; 44 | int32 m_cy_bold; 45 | int32 m_cy_normal; 46 | HFONT m_hfont_bold = 0; 47 | HFONT m_hfont_normal = 0; 48 | bool m_continue; 49 | }; 50 | -------------------------------------------------------------------------------- /clink/lua/src/line_states_lua.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include "line_state_lua.h" 7 | #include "lua_word_classifications.h" 8 | 9 | #include 10 | 11 | class line_states; 12 | 13 | //------------------------------------------------------------------------------ 14 | class line_states_lua 15 | { 16 | public: 17 | line_states_lua(const line_states& lines); 18 | line_states_lua(const line_states& lines, word_classifications& classifications); 19 | ~line_states_lua() = default; 20 | void push(lua_State* state); 21 | static void make_new(lua_State* state, const line_states& lines); 22 | private: 23 | std::vector m_lines; 24 | std::vector m_classifications; 25 | }; 26 | -------------------------------------------------------------------------------- /clink/lua/src/lua_script_loader.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include "pch.h" 5 | #include "lua_state.h" 6 | #include 7 | 8 | #if defined(CLINK_USE_EMBEDDED_SCRIPTS) 9 | 10 | //------------------------------------------------------------------------------ 11 | void lua_load_script_impl(lua_state& state, const char* name, const char* script, int32 length) 12 | { 13 | assert(!state.is_internal()); 14 | state.set_internal(true); 15 | 16 | state.do_string(script, length, nullptr, name); 17 | 18 | state.set_internal(false); 19 | } 20 | 21 | #else // CLINK_USE_EMBEDDED_SCRIPTS 22 | 23 | //------------------------------------------------------------------------------ 24 | void lua_load_script_impl(lua_state& state, const char* path, int32 length) 25 | { 26 | assert(!state.is_internal()); 27 | state.set_internal(true); 28 | 29 | state.do_file(path); 30 | 31 | state.set_internal(false); 32 | } 33 | 34 | #endif // CLINK_USE_EMBEDDED_SCRIPTS 35 | -------------------------------------------------------------------------------- /clink/lua/src/match_builder_lua.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include "lua_bindable.h" 7 | #include 8 | #include 9 | 10 | class match_builder; 11 | struct lua_State; 12 | enum class match_type : unsigned short; 13 | 14 | //------------------------------------------------------------------------------ 15 | class match_builder_lua 16 | : public lua_bindable 17 | { 18 | public: 19 | match_builder_lua(match_builder& builder); 20 | match_builder_lua(std::shared_ptr& toolkit); 21 | ~match_builder_lua(); 22 | 23 | int32 do_add_matches(lua_State* state, bool self_on_stack); 24 | 25 | protected: 26 | int32 add_match(lua_State* state); 27 | int32 add_matches(lua_State* state); 28 | int32 is_empty(lua_State* state); 29 | int32 set_append_character(lua_State* state); 30 | int32 set_suppress_append(lua_State* state); 31 | int32 set_suppress_quoting(lua_State* state); 32 | int32 set_force_quoting(lua_State* state); 33 | int32 set_fully_qualify(lua_State* state); 34 | int32 set_no_sort(lua_State* state); 35 | int32 set_volatile(lua_State* state); 36 | 37 | int32 deprecated_add_match(lua_State* state); 38 | int32 set_matches_are_files(lua_State* state); 39 | 40 | int32 clear_toolkit(lua_State* state); 41 | int32 set_input_line(lua_State* state); 42 | int32 matches_ready(lua_State* state); 43 | 44 | private: 45 | bool add_match_impl(lua_State* state, int32 stack_index, match_type type); 46 | match_builder* m_builder; 47 | std::shared_ptr m_toolkit; 48 | 49 | friend class lua_bindable; 50 | static const char* const c_name; 51 | static const method c_methods[]; 52 | }; 53 | -------------------------------------------------------------------------------- /clink/lua/src/matches_lua.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include "lua_bindable.h" 7 | #include 8 | #include 9 | 10 | struct lua_State; 11 | 12 | //------------------------------------------------------------------------------ 13 | class matches_lua 14 | : public lua_bindable 15 | { 16 | public: 17 | matches_lua(const matches& matches); 18 | matches_lua(std::shared_ptr& toolkit); 19 | ~matches_lua(); 20 | 21 | protected: 22 | int32 get_prefix(lua_State* state); 23 | int32 get_count(lua_State* state); 24 | int32 get_match(lua_State* state); 25 | int32 get_type(lua_State* state); 26 | 27 | private: 28 | const matches* m_matches; 29 | std::shared_ptr m_toolkit; 30 | str_moveable m_prefix; 31 | bool m_has_prefix = false; 32 | 33 | friend class lua_bindable; 34 | static const char* const c_name; 35 | static const method c_methods[]; 36 | }; 37 | -------------------------------------------------------------------------------- /clink/lua/src/pch.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include "pch.h" 5 | -------------------------------------------------------------------------------- /clink/lua/src/pch.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include 11 | 12 | extern "C" { 13 | #include 14 | #include 15 | #include 16 | } 17 | 18 | #include 19 | -------------------------------------------------------------------------------- /clink/lua/src/rl_buffer_lua.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include "core/str.h" 7 | 8 | #include "lua_bindable.h" 9 | 10 | struct lua_State; 11 | class line_buffer; 12 | 13 | //------------------------------------------------------------------------------ 14 | class rl_buffer_lua 15 | : public lua_bindable 16 | { 17 | public: 18 | rl_buffer_lua(line_buffer& buffer); 19 | ~rl_buffer_lua(); 20 | 21 | void do_begin_output(); 22 | 23 | protected: 24 | int32 get_buffer(lua_State* state); 25 | int32 get_length(lua_State* state); 26 | int32 get_cursor(lua_State* state); 27 | int32 get_anchor(lua_State* state); 28 | int32 set_cursor(lua_State* state); 29 | int32 insert(lua_State* state); 30 | int32 remove(lua_State* state); 31 | int32 begin_undo_group(lua_State* state); 32 | int32 end_undo_group(lua_State* state); 33 | int32 begin_output(lua_State* state); 34 | int32 refresh_line(lua_State* state); 35 | int32 get_argument(lua_State* state); 36 | int32 set_argument(lua_State* state); 37 | int32 has_suggestion(lua_State* state); 38 | int32 insert_suggestion(lua_State* state); 39 | int32 set_comment_row(lua_State* state); 40 | int32 ding(lua_State* state); 41 | 42 | private: 43 | line_buffer& m_rl_buffer; 44 | int32 m_num_undo = 0; 45 | 46 | static int32 s_nested; 47 | static bool s_began_output; 48 | 49 | friend class lua_bindable; 50 | static const char* const c_name; 51 | static const method c_methods[]; 52 | }; 53 | -------------------------------------------------------------------------------- /clink/process/include/process/pe.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | class str_base; 7 | 8 | //------------------------------------------------------------------------------ 9 | class pe_info 10 | { 11 | public: 12 | typedef FARPROC funcptr_t; 13 | pe_info(void* base); 14 | funcptr_t* get_import_by_name(const char* dll, const char* func_name, str_base* found_in_module=nullptr) const; 15 | funcptr_t* get_import_by_addr(const char* dll, funcptr_t func_addr, str_base* found_in_module=nullptr) const; 16 | funcptr_t get_export(const char* func_name) const; 17 | 18 | private: 19 | typedef funcptr_t* (pe_info::*import_iter_t)(IMAGE_IMPORT_DESCRIPTOR*, const void*) const; 20 | 21 | IMAGE_NT_HEADERS* get_nt_headers() const; 22 | void* get_data_directory(int32 index, int32* size=nullptr) const; 23 | void* rva_to_addr(uint32 rva) const; 24 | funcptr_t* import_by_addr(IMAGE_IMPORT_DESCRIPTOR* iid, const void* func_addr) const; 25 | funcptr_t* import_by_name(IMAGE_IMPORT_DESCRIPTOR* iid, const void* func_name) const; 26 | funcptr_t* iterate_imports(const char* dll, const void* param, import_iter_t iter_func, str_base* found_in_module) const; 27 | void* m_base; 28 | mutable const char* m_image = nullptr; 29 | }; 30 | -------------------------------------------------------------------------------- /clink/process/include/process/vm.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | //------------------------------------------------------------------------------ 7 | class vm 8 | { 9 | public: 10 | enum 11 | { 12 | access_read = 1 << 0, 13 | access_write = 1 << 1, 14 | access_execute = 1 << 2, 15 | access_cow = 1 << 3, // copy-on-write 16 | access_rw = access_read|access_write, 17 | access_rx = access_read|access_execute, 18 | access_rwx = access_read|access_execute|access_write, 19 | }; 20 | 21 | struct region 22 | { 23 | void* base; 24 | uint32 page_count; 25 | }; 26 | 27 | vm(int32 pid=-1); 28 | ~vm(); 29 | static size_t get_block_granularity(); 30 | static size_t get_page_size(); 31 | void* get_alloc_base(void* address); 32 | region get_region(void* address); 33 | void* get_page(void* address); 34 | region alloc_region(uint32 page_count, uint32 access=access_read|access_write); 35 | void free_region(const region& region); 36 | int32 get_access(const region& region); 37 | bool set_access(const region& region, uint32 access); 38 | bool read(void* dest, const void* src, size_t size); 39 | bool write(void* dest, const void* src, size_t size); 40 | void flush_icache(const region& region={}); 41 | 42 | private: 43 | void* m_handle; 44 | }; 45 | -------------------------------------------------------------------------------- /clink/process/src/pch.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include "pch.h" 5 | -------------------------------------------------------------------------------- /clink/process/src/pch.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include 11 | -------------------------------------------------------------------------------- /clink/terminal/include/terminal/ecma48_wrapper.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include "ecma48_iter.h" 7 | 8 | #include 9 | 10 | //------------------------------------------------------------------------------ 11 | class ecma48_wrapper 12 | { 13 | public: 14 | ecma48_wrapper(const char* in, uint32 wrap); 15 | bool next(str_base& out); 16 | private: 17 | std::vector m_lines; 18 | size_t m_next = 0; 19 | }; 20 | -------------------------------------------------------------------------------- /clink/terminal/include/terminal/find_line.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | //------------------------------------------------------------------------------ 7 | enum find_line_mode : int32 8 | { 9 | none = 0x00, 10 | use_regex = 0x01, 11 | ignore_case = 0x02, 12 | }; 13 | DEFINE_ENUM_FLAG_OPERATORS(find_line_mode); 14 | 15 | //------------------------------------------------------------------------------ 16 | int32 find_line(HANDLE h, const CONSOLE_SCREEN_BUFFER_INFO& csbi, 17 | wchar_t* chars_buffer, int32 chars_capacity, 18 | WORD* attrs_buffer, int32 attrs_capacity, 19 | int32 starting_line, int32 distance, 20 | const char* text, find_line_mode mode, 21 | const BYTE* attrs=nullptr, int32 num_attrs=0, BYTE mask=0xff); 22 | -------------------------------------------------------------------------------- /clink/terminal/include/terminal/input_idle.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | //------------------------------------------------------------------------------ 7 | class input_idle 8 | { 9 | public: 10 | virtual ~input_idle() = default; 11 | virtual void reset() = 0; 12 | virtual uint32 get_timeout() = 0; 13 | virtual uint32 get_wait_events(void** events, size_t max) = 0; 14 | virtual void on_wait_event(uint32 index) = 0; 15 | virtual void on_idle() = 0; 16 | }; 17 | -------------------------------------------------------------------------------- /clink/terminal/include/terminal/key_tester.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | //------------------------------------------------------------------------------ 9 | enum class mouse_input_type : uint8 10 | { 11 | none, 12 | left_click, 13 | right_click, 14 | double_click, 15 | wheel, 16 | hwheel, 17 | drag, 18 | }; 19 | 20 | //------------------------------------------------------------------------------ 21 | class key_tester 22 | { 23 | public: 24 | virtual ~key_tester() = default; 25 | virtual bool is_bound(const char* seq, int32 len) = 0; 26 | virtual bool accepts_mouse_input(mouse_input_type type) { return false; } 27 | virtual bool translate(const char* seq, int32 len, str_base& out) { return false; } 28 | }; 29 | -------------------------------------------------------------------------------- /clink/terminal/include/terminal/scroll.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | //------------------------------------------------------------------------------ 7 | void set_scrolled_screen_buffer(); 8 | bool is_scroll_mode(); 9 | void reset_scroll_mode(); 10 | 11 | //------------------------------------------------------------------------------ 12 | enum SCRMODE 13 | { 14 | SCR_BYLINE, 15 | SCR_BYPAGE, 16 | SCR_TOEND, 17 | SCR_ABSOLUTE, 18 | }; 19 | int32 ScrollConsoleRelative(HANDLE h, int32 direction, SCRMODE mode); 20 | -------------------------------------------------------------------------------- /clink/terminal/include/terminal/terminal.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | class screen_buffer; 7 | class terminal_in; 8 | class terminal_out; 9 | 10 | //------------------------------------------------------------------------------ 11 | struct terminal 12 | { 13 | screen_buffer* screen; 14 | terminal_in* in; 15 | terminal_out* out; 16 | bool screen_owned; 17 | }; 18 | 19 | //------------------------------------------------------------------------------ 20 | terminal terminal_create(screen_buffer* screen=nullptr, bool cursor_visibility=true); 21 | void terminal_destroy(const terminal& terminal); 22 | 23 | //------------------------------------------------------------------------------ 24 | const char* find_key_name(const char* keyseq, int32& len, int32& eqclass, int32& order); 25 | 26 | //------------------------------------------------------------------------------ 27 | void set_verbose_input(int32 verbose); // 1 = inline, 2 = at top of screen 28 | void interrupt_input(); 29 | void reset_keyseq_to_name_map(); 30 | -------------------------------------------------------------------------------- /clink/terminal/include/terminal/terminal_in.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | class input_idle; 7 | class key_tester; 8 | class str_base; 9 | 10 | //------------------------------------------------------------------------------ 11 | class terminal_in 12 | { 13 | public: 14 | enum : int32 { 15 | input_none = int32(0x80000000), 16 | input_abort, 17 | input_terminal_resize, 18 | input_exit, 19 | }; 20 | 21 | virtual ~terminal_in() = default; 22 | virtual int32 begin(bool can_hide_cursor=true) = 0; 23 | virtual int32 end(bool can_show_cursor=true) = 0; 24 | virtual void override_handle() {} 25 | virtual bool available(uint32 timeout) = 0; 26 | virtual void select(input_idle* callback=nullptr, uint32 timeout=INFINITE) = 0; 27 | virtual int32 read() = 0; 28 | virtual int32 peek() = 0; 29 | virtual bool send_terminal_request(const char* request, const char* pattern, str_base& out) { return false; } 30 | virtual key_tester* set_key_tester(key_tester* keys) = 0; 31 | }; 32 | -------------------------------------------------------------------------------- /clink/terminal/include/terminal/terminal_out.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include "attributes.h" 7 | 8 | class str_base; 9 | 10 | //------------------------------------------------------------------------------ 11 | enum find_line_mode : int32; 12 | 13 | //------------------------------------------------------------------------------ 14 | class terminal_out 15 | { 16 | public: 17 | virtual ~terminal_out() = default; 18 | virtual void open() = 0; // Not strictly required; begin() should implicitly open() if necessary. 19 | virtual void begin() = 0; 20 | virtual void end() = 0; 21 | virtual void close() = 0; // Should be not strictly required. 22 | virtual void override_handle() {} 23 | virtual void write(const char* chars, int32 length) = 0; 24 | template void write(const char (&chars)[S]); 25 | virtual bool get_line_text(int32 line, str_base& out) const = 0; 26 | virtual void flush() = 0; 27 | virtual int32 get_columns() const = 0; 28 | virtual int32 get_rows() const = 0; 29 | virtual int32 is_line_default_color(int32 line) const = 0; 30 | virtual int32 line_has_color(int32 line, const BYTE* attrs, int32 num_attrs, BYTE mask=0xff) const = 0; 31 | virtual int32 find_line(int32 starting_line, int32 distance, const char* text, find_line_mode mode, const BYTE* attrs=nullptr, int32 num_attrs=0, BYTE mask=0xff) const = 0; 32 | }; 33 | 34 | //------------------------------------------------------------------------------ 35 | template void terminal_out::write(const char (&chars)[S]) 36 | { 37 | write(chars, S - 1); 38 | } 39 | -------------------------------------------------------------------------------- /clink/terminal/src/cielab.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | namespace cie 7 | { 8 | 9 | //------------------------------------------------------------------------------ 10 | struct lab 11 | { 12 | lab() = default; 13 | lab(COLORREF c) { from_rgb(c); } 14 | 15 | void from_rgb(COLORREF c); 16 | 17 | double l = 0; 18 | double a = 0; 19 | double b = 0; 20 | }; 21 | 22 | //------------------------------------------------------------------------------ 23 | // Delta E* CIE (1976) 24 | double deltaE_2(const lab& lab1, const lab& lab2); // skips sqrt() 25 | //double deltaE(const lab& lab1, const lab& lab2); 26 | //double deltaE(COLORREF c1, COLORREF c2); 27 | 28 | //------------------------------------------------------------------------------ 29 | // Delta E 1994 gets confused too easily by luminance. 30 | // Delta E 2000 uses a lot of trigonometric ratios, and looks too slow. 31 | 32 | }; 33 | -------------------------------------------------------------------------------- /clink/terminal/src/pch.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include "pch.h" 5 | -------------------------------------------------------------------------------- /clink/terminal/src/pch.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include 11 | -------------------------------------------------------------------------------- /clink/terminal/src/terminal.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include "pch.h" 5 | #include "terminal.h" 6 | #include "ecma48_terminal_out.h" 7 | #include "win_screen_buffer.h" 8 | #include "win_terminal_in.h" 9 | 10 | #include 11 | 12 | //------------------------------------------------------------------------------ 13 | terminal terminal_create(screen_buffer* screen, bool cursor_visibility) 14 | { 15 | #if defined(PLATFORM_WINDOWS) 16 | terminal term; 17 | term.screen_owned = (screen == nullptr); 18 | term.screen = screen ? screen : new win_screen_buffer(); 19 | term.in = new win_terminal_in(cursor_visibility); 20 | term.out = new ecma48_terminal_out(*term.screen); 21 | return term; 22 | #else 23 | return {}; 24 | #endif 25 | } 26 | 27 | //------------------------------------------------------------------------------ 28 | void terminal_destroy(const terminal& terminal) 29 | { 30 | delete terminal.out; 31 | delete terminal.in; 32 | if (terminal.screen_owned) 33 | delete terminal.screen; 34 | } 35 | -------------------------------------------------------------------------------- /clink/test/src/clatch.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include "pch.h" 5 | 6 | // For compatibility with Windows 8.1 SDK. 7 | #if !defined( ENABLE_VIRTUAL_TERMINAL_PROCESSING ) 8 | # define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 9 | #elif ENABLE_VIRTUAL_TERMINAL_PROCESSING != 0x0004 10 | # error ENABLE_VIRTUAL_TERMINAL_PROCESSING must be 0x0004 11 | #endif 12 | 13 | namespace clatch { 14 | 15 | //------------------------------------------------------------------------------ 16 | void colors::initialize() 17 | { 18 | #pragma warning(push) 19 | #pragma warning(disable:4996) 20 | DWORD type; 21 | DWORD data; 22 | DWORD size; 23 | LSTATUS status = RegGetValue(HKEY_CURRENT_USER, "Console", "ForceV2", RRF_RT_REG_DWORD, &type, &data, &size); 24 | if (status != ERROR_SUCCESS || 25 | type != REG_DWORD || 26 | size != sizeof(data) || 27 | data != 0) 28 | { 29 | DWORD mode; 30 | HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); 31 | if (GetConsoleMode(h, &mode)) 32 | { 33 | SetConsoleMode(h, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING); 34 | *get_colored_storage() = true; 35 | } 36 | } 37 | #pragma warning(pop) 38 | } 39 | 40 | }; 41 | -------------------------------------------------------------------------------- /clink/test/src/env_fixture.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | //------------------------------------------------------------------------------ 7 | class env_fixture 8 | { 9 | public: 10 | env_fixture(const char** env); 11 | ~env_fixture(); 12 | 13 | protected: 14 | void convert_eq_to_null(wchar_t* env_strings); 15 | void clear(); 16 | wchar_t* m_env_strings; 17 | }; 18 | -------------------------------------------------------------------------------- /clink/test/src/fs_fixture.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | //------------------------------------------------------------------------------ 9 | class fs_fixture 10 | { 11 | public: 12 | fs_fixture(const char** fs=nullptr); 13 | ~fs_fixture(); 14 | const char* get_root() const; 15 | 16 | private: 17 | void clean(const char* path); 18 | str<> m_root; 19 | const char** m_fs; 20 | }; 21 | -------------------------------------------------------------------------------- /clink/test/src/pch.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include "pch.h" 5 | -------------------------------------------------------------------------------- /clink/test/src/pch.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Martin Ridgers 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | #include "clatch.h" 12 | 13 | -------------------------------------------------------------------------------- /complete/test.clinkcomplete: -------------------------------------------------------------------------------- 1 | local args = {...} 2 | 3 | require("arghelper") 4 | 5 | local function test_names(_, _, _, builder, _) 6 | local matches = {} 7 | local testcmd = path.join(path.getdirectory(args[1]), "test.cmd") 8 | local p = io.popen(testcmd.." --list-tests") 9 | if p then 10 | for l in p:lines() do 11 | table.insert(matches, l) 12 | end 13 | builder:setnosort() 14 | builder:setforcequoting() 15 | p:close() 16 | end 17 | return matches 18 | end 19 | 20 | clink.argmatcher(args[1]) 21 | :_addexflags({ 22 | { "/dbg", "Run test under the debugger" }, 23 | { "/x64", "Run clink_test_x64.exe (the default)" }, 24 | { "/x86", "Run clink_test_x86.exe" }, 25 | { "/rel", "Run release version (runs debug version by default)" }, 26 | { "-d", "Load Lua debugger" }, 27 | { "-t", "Show execution time" }, 28 | }) 29 | :addarg(test_names) 30 | :nofiles() 31 | -------------------------------------------------------------------------------- /detours/detver.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Common version parameters. 4 | // 5 | // Microsoft Research Detours Package, Version 4.0.1 6 | // 7 | // Copyright (c) Microsoft Corporation. All rights reserved. 8 | // 9 | 10 | #define _USING_V110_SDK71_ 1 11 | #include "winver.h" 12 | #if 0 13 | #include 14 | #include 15 | #else 16 | #ifndef DETOURS_STRINGIFY 17 | #define DETOURS_STRINGIFY_(x) #x 18 | #define DETOURS_STRINGIFY(x) DETOURS_STRINGIFY_(x) 19 | #endif 20 | 21 | #define VER_FILEFLAGSMASK 0x3fL 22 | #define VER_FILEFLAGS 0x0L 23 | #define VER_FILEOS 0x00040004L 24 | #define VER_FILETYPE 0x00000002L 25 | #define VER_FILESUBTYPE 0x00000000L 26 | #endif 27 | #define VER_DETOURS_BITS DETOURS_STRINGIFY(DETOURS_BITS) 28 | -------------------------------------------------------------------------------- /detours/disolarm.cpp: -------------------------------------------------------------------------------- 1 | #define DETOURS_ARM_OFFLINE_LIBRARY 2 | #include "disasm.cpp" 3 | -------------------------------------------------------------------------------- /detours/disolarm64.cpp: -------------------------------------------------------------------------------- 1 | #define DETOURS_ARM64_OFFLINE_LIBRARY 2 | #include "disasm.cpp" 3 | -------------------------------------------------------------------------------- /detours/disolia64.cpp: -------------------------------------------------------------------------------- 1 | #define DETOURS_IA64_OFFLINE_LIBRARY 2 | #include "disasm.cpp" 3 | -------------------------------------------------------------------------------- /detours/disolx64.cpp: -------------------------------------------------------------------------------- 1 | #define DETOURS_X64_OFFLINE_LIBRARY 2 | #include "disasm.cpp" 3 | -------------------------------------------------------------------------------- /detours/disolx86.cpp: -------------------------------------------------------------------------------- 1 | #define DETOURS_X86_OFFLINE_LIBRARY 2 | #include "disasm.cpp" 3 | -------------------------------------------------------------------------------- /docs/atom-one-light.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Atom One Light by Daniel Gamage 4 | Original One Light Syntax theme from https://github.com/atom/one-light-syntax 5 | 6 | base: #fafafa 7 | mono-1: #383a42 8 | mono-2: #686b77 9 | mono-3: #a0a1a7 10 | hue-1: #0184bb 11 | hue-2: #4078f2 12 | hue-3: #a626a4 13 | hue-4: #50a14f 14 | hue-5: #e45649 15 | hue-5-2: #c91243 16 | hue-6: #986801 17 | hue-6-2: #c18401 18 | 19 | */ 20 | 21 | .hljs { 22 | display: block; 23 | overflow-x: auto; 24 | padding: 0.5em; 25 | color: #383a42; 26 | background: #fafafa; 27 | } 28 | 29 | .hljs-comment, 30 | .hljs-quote { 31 | color: #a0a1a7; 32 | font-style: italic; 33 | } 34 | 35 | .hljs-doctag, 36 | .hljs-keyword, 37 | .hljs-formula { 38 | color: #a626a4; 39 | } 40 | 41 | .hljs-section, 42 | .hljs-name, 43 | .hljs-selector-tag, 44 | .hljs-deletion, 45 | .hljs-subst { 46 | color: #e45649; 47 | } 48 | 49 | .hljs-literal { 50 | color: #0184bb; 51 | } 52 | 53 | .hljs-string, 54 | .hljs-regexp, 55 | .hljs-addition, 56 | .hljs-attribute, 57 | .hljs-meta-string { 58 | color: #50a14f; 59 | } 60 | 61 | .hljs-built_in, 62 | .hljs-class .hljs-title { 63 | color: #c18401; 64 | } 65 | 66 | .hljs-attr, 67 | .hljs-variable, 68 | .hljs-template-variable, 69 | .hljs-type, 70 | .hljs-selector-class, 71 | .hljs-selector-attr, 72 | .hljs-selector-pseudo, 73 | .hljs-number { 74 | color: #986801; 75 | } 76 | 77 | .hljs-symbol, 78 | .hljs-bullet, 79 | .hljs-link, 80 | .hljs-meta, 81 | .hljs-selector-id, 82 | .hljs-title { 83 | color: #4078f2; 84 | } 85 | 86 | .hljs-emphasis { 87 | font-style: italic; 88 | } 89 | 90 | .hljs-strong { 91 | font-weight: bold; 92 | } 93 | 94 | .hljs-link { 95 | text-decoration: underline; 96 | } 97 | -------------------------------------------------------------------------------- /docs/examples/ex_classify_samp.lua: -------------------------------------------------------------------------------- 1 | -- In this example, the argmatcher matches a directory as the first argument and 2 | -- a file as the second argument. It uses a word classifier function to classify 3 | -- directories (words that end with a path separator) as "unexpected" in the 4 | -- second argument position. 5 | 6 | local function classify_handler(arg_index, word, word_index, line_state, classifications, user_data) 7 | -- `arg_index` is the argument position in the argmatcher. 8 | -- In this example only position 2 needs special treatent. 9 | if arg_index ~= 2 then 10 | return 11 | end 12 | 13 | -- `arg_index` is the argument position in the argmatcher. 14 | -- `word_index` is the word position in the `line_state`. 15 | -- Ex1: in `samp dir file` for the word `dir` the argument index is 1 and 16 | -- the word index is 2. 17 | -- Ex2: in `samp --help dir file` for the word `dir` the argument index is 18 | -- still 1, but the word index is 3. 19 | 20 | -- `word` is the word the classifier function was called for and `word_index` 21 | -- is its position in the line. Because `line_state` is also provided, the 22 | -- function can examine any words in the input line. 23 | if word:sub(-1) == "\\" then 24 | -- The word appears to be a directory, but this example expects only 25 | -- files in argument position 2. Here the word gets classified as "n" 26 | -- (unexpected) so it gets colored differently. 27 | classifications:classifyword(word_index, "n") 28 | end 29 | end 30 | 31 | local matcher = clink.argmatcher("samp") 32 | :addflags("--help") 33 | :addarg({ clink.dirmatches }) 34 | :addarg({ clink.filematches }) 35 | :setclassifier(classify_handler) 36 | -------------------------------------------------------------------------------- /docs/examples/ex_findstr.lua: -------------------------------------------------------------------------------- 1 | clink.argmatcher("findstr") 2 | :addflags({ 3 | "/b", "/e", "/l", "/r", "/s", "/i", "/x", "/v", "/n", "/m", "/o", "/p", "/offline", 4 | "/a:"..clink.argmatcher():addarg( "attr" ), 5 | "/f:"..clink.argmatcher():addarg( clink.filematches ), 6 | "/c:"..clink.argmatcher():addarg( "search_string" ), 7 | "/g:", -- This is the same as linking with clink.argmatcher():addarg(clink.filematches). 8 | "/d:"..clink.argmatcher():addarg( clink.dirmatches ) 9 | }) 10 | -------------------------------------------------------------------------------- /docs/examples/ex_generate.lua: -------------------------------------------------------------------------------- 1 | local git_branch_autocomplete = clink.generator(1) 2 | 3 | local function starts_with(str, start) 4 | return string.sub(str, 1, string.len(start)) == start 5 | end 6 | 7 | local function is_checkout_ac(text) 8 | if starts_with(text, "git checkout") then 9 | return true 10 | end 11 | return false 12 | end 13 | 14 | local function get_branches() 15 | -- Run git command to get branches. 16 | local handle = io.popen("git branch -a 2>&1") 17 | local result = handle:read("*a") 18 | handle:close() 19 | -- Parse the branches from the output. 20 | local branches = {} 21 | if starts_with(result, "fatal") == false then 22 | for branch in string.gmatch(result, " %S+") do 23 | branch = string.gsub(branch, " ", "") 24 | if branch ~= "HEAD" then 25 | table.insert(branches, branch) 26 | end 27 | end 28 | end 29 | return branches 30 | end 31 | 32 | function git_branch_autocomplete:generate(line_state, match_builder) 33 | -- Check if it's a checkout command. 34 | if not is_checkout_ac(line_state:getline()) then 35 | return false 36 | end 37 | -- Get branches and add them (does nothing if not in a git repo). 38 | local matchCount = 0 39 | for _, branch in ipairs(get_branches()) do 40 | match_builder:addmatch(branch) 41 | matchCount = matchCount + 1 42 | end 43 | -- If we found branches, then stop other match generators. 44 | return matchCount > 0 45 | end 46 | -------------------------------------------------------------------------------- /docs/examples/ex_hinter.lua: -------------------------------------------------------------------------------- 1 | local hinter = clink.hinter() 2 | 3 | function hinter:gethint(line_state) 4 | local h, p 5 | local cursorpos = line_state:getcursor() 6 | for i = 1, line_state:getwordcount() do 7 | local info = line_state:getwordinfo(i) 8 | if info.offset <= cursorpos and cursorpos <= info.offset + info.length then 9 | h = string.format("word starts at %d", info.offset) 10 | p = info.offset 11 | end 12 | end 13 | return h, p 14 | end 15 | -------------------------------------------------------------------------------- /docs/examples/ex_prompt.lua: -------------------------------------------------------------------------------- 1 | local green = "\x1b[92m" 2 | local yellow = "\x1b[93m" 3 | local cyan = "\x1b[36m" 4 | local normal = "\x1b[m" 5 | 6 | -- A prompt filter that discards any prompt so far and sets the 7 | -- prompt to the current working directory. An ANSI escape code 8 | -- colors it yellow. 9 | local cwd_prompt = clink.promptfilter(30) 10 | function cwd_prompt:filter(prompt) 11 | return yellow..os.getcwd()..normal 12 | end 13 | 14 | -- A prompt filter that inserts the date at the beginning of the 15 | -- the prompt. An ANSI escape code colors the date green. 16 | local date_prompt = clink.promptfilter(40) 17 | function date_prompt:filter(prompt) 18 | return green..os.date("%a %H:%M")..normal.." "..prompt 19 | end 20 | 21 | -- A prompt filter that may stop further prompt filtering. 22 | -- This is a silly example, but on Wednesdays, it stops the 23 | -- filtering, which in this example prevents git branch 24 | -- detection and the line feed and angle bracket. 25 | local wednesday_silliness = clink.promptfilter(60) 26 | function wednesday_silliness:filter(prompt) 27 | if os.date("%a") == "Wed" then 28 | -- The ,false stops any further filtering. 29 | return prompt.." HAPPY HUMP DAY! ", false 30 | end 31 | end 32 | 33 | -- A prompt filter that appends the current git branch. 34 | local git_branch_prompt = clink.promptfilter(65) 35 | function git_branch_prompt:filter(prompt) 36 | local line = io.popen("git branch --show-current 2>nul"):read("*a") 37 | local branch = line:match("(.+)\n") 38 | if branch then 39 | return prompt.." "..cyan.."["..branch.."]"..normal 40 | end 41 | end 42 | 43 | -- A prompt filter that adds a line feed and angle bracket. 44 | local bracket_prompt = clink.promptfilter(150) 45 | function bracket_prompt:filter(prompt) 46 | return prompt.."\n> " 47 | end 48 | -------------------------------------------------------------------------------- /docs/examples/ex_right_prompt.lua: -------------------------------------------------------------------------------- 1 | local p = clink.promptfilter(30) 2 | function p:filter(prompt) 3 | -- The :filter() function must be defined. But if the prompt filter is 4 | -- only interested in modifying the right side prompt, then the :filter() 5 | -- function may do nothing. 6 | end 7 | function p:rightfilter(prompt) 8 | local sep = #prompt > 0 and " " or "" 9 | return os.date()..sep..prompt 10 | end 11 | -------------------------------------------------------------------------------- /docs/examples/ex_suggest.lua: -------------------------------------------------------------------------------- 1 | local prefix_suggestor = clink.suggester("completion_prefix") 2 | 3 | function prefix_suggestor:suggest(line_state, matches) 4 | -- If the input line is empty or only spaces, don't suggest anything. 5 | if not line_state:getline():match("[^ ]") then 6 | return 7 | end 8 | 9 | -- If there is no common prefix, don't suggest anything. 10 | local prefix = matches:getprefix() 11 | if prefix == "" then 12 | return 13 | end 14 | 15 | -- Return the common prefix as the suggestion. 16 | local info = line_state:getwordinfo(line_state:getwordcount()) 17 | return prefix, info.offset 18 | end 19 | -------------------------------------------------------------------------------- /docs/examples/ex_surround_prompt.lua: -------------------------------------------------------------------------------- 1 | local p = clink.promptfilter(-100) -- Negative number so it runs early. 2 | function p:filter(prompt) 3 | -- The :filter() function must be defined. But if the prompt filter is 4 | -- only interested in surrounding the prompt with escape codes, then the 5 | -- :filter() function may do nothing. 6 | end 7 | function p:surround() 8 | -- For the normal (left side) prompt. 9 | local prompt_prefix = "" -- Fill this in with escape codes to be printed before the prompt text. 10 | local prompt_suffix = "" -- Fill this in with escape codes to be printed after the prompt text. 11 | -- For the right side prompt (if any). 12 | local rprompt_prefix = "" -- Fill this in with escape codes to be printed before the right side prompt text. 13 | local rprompt_suffix = "" -- Fill this in with escape codes to be printed after the right side prompt text. 14 | return prompt_prefix, prompt_suffix, rprompt_prefix, rprompt_suffix 15 | end 16 | -------------------------------------------------------------------------------- /docs/examples/ex_transient_prompt.lua: -------------------------------------------------------------------------------- 1 | -- Colors for the prompt strings. 2 | local cwd_color = "\x1b[0;1;37;44m" 3 | local symbol_color = "\x1b[0;1;34m" 4 | local date_color = "\x1b[0;36m" 5 | local transient_date_color = "\x1b[0;1;30m" 6 | local normal = "\x1b[m" 7 | 8 | -- Create prompt filter. 9 | local pf = clink.promptfilter(10) 10 | 11 | -- Customize the normal prompt. 12 | function pf:filter(prompt) 13 | -- Don't return false yet; let rightfilter have a chance. 14 | return cwd_color.." "..os.getcwd().." "..symbol_color.." > "..normal 15 | end 16 | 17 | -- Customize the normal right side prompt. 18 | function pf:rightfilter(prompt) 19 | -- If you have want stop further filtering, this is where to add returning false. 20 | return date_color..os.date() --, false 21 | end 22 | 23 | -- Customize the transient prompt. 24 | function pf:transientfilter(prompt) 25 | -- Don't return false yet; let transientrightfilter have a chance. 26 | return symbol_color.."> "..normal 27 | end 28 | 29 | -- Customize the transient right side prompt. 30 | function pf:transientrightfilter(prompt) 31 | -- Returns false to stop filtering. 32 | return transient_date_color..os.date("%c", os.time()), false 33 | end 34 | 35 | -- Show a reminder to turn on the transient prompt, to try out the example. 36 | if settings.get("prompt.transient") == "off" then 37 | print("Use 'clink set prompt.transient same_dir' to enable the transient prompt.") 38 | end 39 | -------------------------------------------------------------------------------- /docs/experimental.css: -------------------------------------------------------------------------------- 1 | .font-effect-shadow-multiple { 2 | text-shadow: .04em .04em 0 #fff,.08em .08em 0 #aaa; 3 | -webkit-text-shadow: .04em .04em 0 #fff, .08em .08em 0 #aaa; 4 | } 5 | -------------------------------------------------------------------------------- /docs/github.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | github.com style (c) Vasily Polovnyov 4 | 5 | */ 6 | 7 | .hljs { 8 | display: block; 9 | overflow-x: auto; 10 | padding: 0.5em; 11 | color: #333; 12 | background: #f8f8f8; 13 | } 14 | 15 | .hljs-comment, 16 | .hljs-quote { 17 | color: #998; 18 | font-style: italic; 19 | } 20 | 21 | .hljs-keyword, 22 | .hljs-selector-tag, 23 | .hljs-subst { 24 | color: #333; 25 | font-weight: bold; 26 | } 27 | 28 | .hljs-number, 29 | .hljs-literal, 30 | .hljs-variable, 31 | .hljs-template-variable, 32 | .hljs-tag .hljs-attr { 33 | color: #008080; 34 | } 35 | 36 | .hljs-string, 37 | .hljs-doctag { 38 | color: #d14; 39 | } 40 | 41 | .hljs-title, 42 | .hljs-section, 43 | .hljs-selector-id { 44 | color: #900; 45 | font-weight: bold; 46 | } 47 | 48 | .hljs-subst { 49 | font-weight: normal; 50 | } 51 | 52 | .hljs-type, 53 | .hljs-class .hljs-title { 54 | color: #458; 55 | font-weight: bold; 56 | } 57 | 58 | .hljs-tag, 59 | .hljs-name, 60 | .hljs-attribute { 61 | color: #000080; 62 | font-weight: normal; 63 | } 64 | 65 | .hljs-regexp, 66 | .hljs-link { 67 | color: #009926; 68 | } 69 | 70 | .hljs-symbol, 71 | .hljs-bullet { 72 | color: #990073; 73 | } 74 | 75 | .hljs-built_in, 76 | .hljs-builtin-name { 77 | color: #0086b3; 78 | } 79 | 80 | .hljs-meta { 81 | color: #999; 82 | font-weight: bold; 83 | } 84 | 85 | .hljs-deletion { 86 | background: #fdd; 87 | } 88 | 89 | .hljs-addition { 90 | background: #dfd; 91 | } 92 | 93 | .hljs-emphasis { 94 | font-style: italic; 95 | } 96 | 97 | .hljs-strong { 98 | font-weight: bold; 99 | } 100 | -------------------------------------------------------------------------------- /docs/googlecode.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Google Code style (c) Aahan Krish 4 | 5 | */ 6 | 7 | .hljs { 8 | display: block; 9 | overflow-x: auto; 10 | padding: 0.5em; 11 | background: white; 12 | color: black; 13 | } 14 | 15 | .hljs-comment, 16 | .hljs-quote { 17 | color: #800; 18 | } 19 | 20 | .hljs-keyword, 21 | .hljs-selector-tag, 22 | .hljs-section, 23 | .hljs-title, 24 | .hljs-name { 25 | color: #008; 26 | } 27 | 28 | .hljs-variable, 29 | .hljs-template-variable { 30 | color: #660; 31 | } 32 | 33 | .hljs-string, 34 | .hljs-selector-attr, 35 | .hljs-selector-pseudo, 36 | .hljs-regexp { 37 | color: #080; 38 | } 39 | 40 | .hljs-literal, 41 | .hljs-symbol, 42 | .hljs-bullet, 43 | .hljs-meta, 44 | .hljs-number, 45 | .hljs-link { 46 | color: #066; 47 | } 48 | 49 | .hljs-title, 50 | .hljs-doctag, 51 | .hljs-type, 52 | .hljs-attr, 53 | .hljs-built_in, 54 | .hljs-builtin-name, 55 | .hljs-params { 56 | color: #606; 57 | } 58 | 59 | .hljs-attribute, 60 | .hljs-subst { 61 | color: #000; 62 | } 63 | 64 | .hljs-formula { 65 | background-color: #eee; 66 | font-style: italic; 67 | } 68 | 69 | .hljs-selector-id, 70 | .hljs-selector-class { 71 | color: #9B703F 72 | } 73 | 74 | .hljs-addition { 75 | background-color: #baeeba; 76 | } 77 | 78 | .hljs-deletion { 79 | background-color: #ffc8bd; 80 | } 81 | 82 | .hljs-doctag, 83 | .hljs-strong { 84 | font-weight: bold; 85 | } 86 | 87 | .hljs-emphasis { 88 | font-style: italic; 89 | } 90 | -------------------------------------------------------------------------------- /getopt/getopt.patch: -------------------------------------------------------------------------------- 1 | diff --git a/getopt/getopt.h b/getopt/getopt.h 2 | index 7a588ec..b43f4a8 100644 3 | --- a/getopt/getopt.h 4 | +++ b/getopt/getopt.h 5 | @@ -97,7 +97,7 @@ gpietsch@comcast.net 6 | /* struct option: The type of long option */ 7 | struct option 8 | { 9 | - char *name; /* the name of the long option */ 10 | + const char *name; /* the name of the long option */ 11 | int has_arg; /* one of the above macros */ 12 | int *flag; /* determines if getopt_long() returns a 13 | * value for a long option; if it is 14 | -------------------------------------------------------------------------------- /installer/modern_mediumdesc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisant996/clink/d8a218ad53457119ef4e4dd370bed22f63ec458e/installer/modern_mediumdesc.exe -------------------------------------------------------------------------------- /lua/README: -------------------------------------------------------------------------------- 1 | 2 | This is Lua 5.2.4, released on 25 Feb 2015. 3 | 4 | For installation instructions, license details, and 5 | further information about Lua, see doc/readme.html. 6 | 7 | -------------------------------------------------------------------------------- /lua/doc/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisant996/clink/d8a218ad53457119ef4e4dd370bed22f63ec458e/lua/doc/logo.gif -------------------------------------------------------------------------------- /lua/doc/manual.css: -------------------------------------------------------------------------------- 1 | h3 code { 2 | font-family: inherit ; 3 | font-size: inherit ; 4 | } 5 | 6 | pre, code { 7 | font-size: 12pt ; 8 | } 9 | 10 | span.apii { 11 | float: right ; 12 | font-family: inherit ; 13 | font-style: normal ; 14 | font-size: small ; 15 | color: gray ; 16 | } 17 | 18 | p+h1, ul+h1 { 19 | font-style: normal ; 20 | padding-top: 0.4em ; 21 | padding-bottom: 0.4em ; 22 | padding-left: 16px ; 23 | margin-left: -16px ; 24 | background-color: #D0D0FF ; 25 | border-radius: 8px ; 26 | border: solid #000080 1px ; 27 | } 28 | -------------------------------------------------------------------------------- /lua/doc/osi-certified-72x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisant996/clink/d8a218ad53457119ef4e4dd370bed22f63ec458e/lua/doc/osi-certified-72x60.png -------------------------------------------------------------------------------- /lua/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.7.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "llimits.h" 12 | #include "lstate.h" 13 | 14 | #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ 15 | "stack overflow");} 16 | 17 | #define adjustresults(L,nres) \ 18 | { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } 19 | 20 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ 21 | "not enough elements in the stack") 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /lua/src/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.7.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) 15 | 16 | #define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | /* Active Lua function (given call info) */ 21 | #define ci_func(ci) (clLvalue((ci)->func)) 22 | 23 | 24 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, 25 | const char *opname); 26 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, StkId p1, StkId p2); 27 | LUAI_FUNC l_noret luaG_aritherror (lua_State *L, const TValue *p1, 28 | const TValue *p2); 29 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, 30 | const TValue *p2); 31 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); 32 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /lua/src/ldo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldo.h,v 2.20.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** Stack and Call structure of Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldo_h 8 | #define ldo_h 9 | 10 | 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | #include "lzio.h" 14 | 15 | 16 | #define luaD_checkstack(L,n) if (L->stack_last - L->top <= (n)) \ 17 | luaD_growstack(L, n); else condmovestack(L); 18 | 19 | 20 | #define incr_top(L) {L->top++; luaD_checkstack(L,0);} 21 | 22 | #define savestack(L,p) ((char *)(p) - (char *)L->stack) 23 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) 24 | 25 | 26 | /* type of protected functions, to be ran by `runprotected' */ 27 | typedef void (*Pfunc) (lua_State *L, void *ud); 28 | 29 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, 30 | const char *mode); 31 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line); 32 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); 33 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults, 34 | int allowyield); 35 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 36 | ptrdiff_t oldtop, ptrdiff_t ef); 37 | LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult, int nres); 38 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); 39 | LUAI_FUNC void luaD_growstack (lua_State *L, int n); 40 | LUAI_FUNC void luaD_shrinkstack (lua_State *L); 41 | 42 | LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); 43 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /lua/src/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h,v 2.8.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lfunc_h 8 | #define lfunc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ 15 | cast(int, sizeof(TValue)*((n)-1))) 16 | 17 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ 18 | cast(int, sizeof(TValue *)*((n)-1))) 19 | 20 | 21 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 22 | LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems); 23 | LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems); 24 | LUAI_FUNC UpVal *luaF_newupval (lua_State *L); 25 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 26 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 27 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 28 | LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); 29 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 30 | int pc); 31 | 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /lua/src/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.32.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** Initialization of libraries for lua.c and other clients 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | /* 9 | ** If you embed Lua in your program and need to open the standard 10 | ** libraries, call luaL_openlibs in your program. If you need a 11 | ** different set of libraries, copy this file to your project and edit 12 | ** it to suit your needs. 13 | */ 14 | 15 | 16 | #define linit_c 17 | #define LUA_LIB 18 | 19 | #include "lua.h" 20 | 21 | #include "lualib.h" 22 | #include "lauxlib.h" 23 | 24 | 25 | /* 26 | ** these libs are loaded by lua.c and are readily available to any Lua 27 | ** program 28 | */ 29 | static const luaL_Reg loadedlibs[] = { 30 | {"_G", luaopen_base}, 31 | {LUA_LOADLIBNAME, luaopen_package}, 32 | {LUA_COLIBNAME, luaopen_coroutine}, 33 | {LUA_TABLIBNAME, luaopen_table}, 34 | {LUA_IOLIBNAME, luaopen_io}, 35 | {LUA_OSLIBNAME, luaopen_os}, 36 | {LUA_STRLIBNAME, luaopen_string}, 37 | {LUA_BITLIBNAME, luaopen_bit32}, 38 | {LUA_MATHLIBNAME, luaopen_math}, 39 | {LUA_DBLIBNAME, luaopen_debug}, 40 | {NULL, NULL} 41 | }; 42 | 43 | 44 | /* 45 | ** these libs are preloaded and must be required before used 46 | */ 47 | static const luaL_Reg preloadedlibs[] = { 48 | {NULL, NULL} 49 | }; 50 | 51 | 52 | LUALIB_API void luaL_openlibs (lua_State *L) { 53 | const luaL_Reg *lib; 54 | /* call open functions from 'loadedlibs' and set results to global table */ 55 | for (lib = loadedlibs; lib->func; lib++) { 56 | luaL_requiref(L, lib->name, lib->func, 1); 57 | lua_pop(L, 1); /* remove lib */ 58 | } 59 | /* add open functions from 'preloadedlibs' into 'package.preload' table */ 60 | luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD"); 61 | for (lib = preloadedlibs; lib->func; lib++) { 62 | lua_pushcfunction(L, lib->func); 63 | lua_setfield(L, -2, lib->name); 64 | } 65 | lua_pop(L, 1); /* remove _PRELOAD table */ 66 | } 67 | 68 | -------------------------------------------------------------------------------- /lua/src/lmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.h,v 1.40.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lmem_h 8 | #define lmem_h 9 | 10 | 11 | #include 12 | 13 | #include "llimits.h" 14 | #include "lua.h" 15 | 16 | 17 | /* 18 | ** This macro avoids the runtime division MAX_SIZET/(e), as 'e' is 19 | ** always constant. 20 | ** The macro is somewhat complex to avoid warnings: 21 | ** +1 avoids warnings of "comparison has constant result"; 22 | ** cast to 'void' avoids warnings of "value unused". 23 | */ 24 | #define luaM_reallocv(L,b,on,n,e) \ 25 | (cast(void, \ 26 | (cast(size_t, (n)+1) > MAX_SIZET/(e)) ? (luaM_toobig(L), 0) : 0), \ 27 | luaM_realloc_(L, (b), (on)*(e), (n)*(e))) 28 | 29 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 30 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 31 | #define luaM_freearray(L, b, n) luaM_reallocv(L, (b), n, 0, sizeof((b)[0])) 32 | 33 | #define luaM_malloc(L,s) luaM_realloc_(L, NULL, 0, (s)) 34 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) 35 | #define luaM_newvector(L,n,t) \ 36 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) 37 | 38 | #define luaM_newobject(L,tag,s) luaM_realloc_(L, NULL, tag, (s)) 39 | 40 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ 41 | if ((nelems)+1 > (size)) \ 42 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) 43 | 44 | #define luaM_reallocvector(L, v,oldn,n,t) \ 45 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) 46 | 47 | LUAI_FUNC l_noret luaM_toobig (lua_State *L); 48 | 49 | /* not to be called directly */ 50 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 51 | size_t size); 52 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, 53 | size_t size_elem, int limit, 54 | const char *what); 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /lua/src/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.49.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** String table (keep all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lstring_h 8 | #define lstring_h 9 | 10 | #include "lgc.h" 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | 14 | 15 | #define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) 16 | 17 | #define sizeudata(u) (sizeof(union Udata)+(u)->len) 18 | 19 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 20 | (sizeof(s)/sizeof(char))-1)) 21 | 22 | #define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) 23 | 24 | 25 | /* 26 | ** test whether a string is a reserved word 27 | */ 28 | #define isreserved(s) ((s)->tsv.tt == LUA_TSHRSTR && (s)->tsv.extra > 0) 29 | 30 | 31 | /* 32 | ** equality for short strings, which are always internalized 33 | */ 34 | #define eqshrstr(a,b) check_exp((a)->tsv.tt == LUA_TSHRSTR, (a) == (b)) 35 | 36 | 37 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); 38 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); 39 | LUAI_FUNC int luaS_eqstr (TString *a, TString *b); 40 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 41 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); 42 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 43 | LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); 44 | 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /lua/src/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h,v 2.16.1.2 2013/08/30 15:49:41 roberto Exp $ 3 | ** Lua tables (hash) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltable_h 8 | #define ltable_h 9 | 10 | #include "lobject.h" 11 | 12 | 13 | #define gnode(t,i) (&(t)->node[i]) 14 | #define gkey(n) (&(n)->i_key.tvk) 15 | #define gval(n) (&(n)->i_val) 16 | #define gnext(n) ((n)->i_key.nk.next) 17 | 18 | #define invalidateTMcache(t) ((t)->flags = 0) 19 | 20 | /* returns the key, given the value of a table entry */ 21 | #define keyfromval(v) \ 22 | (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val)))) 23 | 24 | 25 | LUAI_FUNC const TValue *luaH_getint (Table *t, int key); 26 | LUAI_FUNC void luaH_setint (lua_State *L, Table *t, int key, TValue *value); 27 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 28 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 29 | LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key); 30 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 31 | LUAI_FUNC Table *luaH_new (lua_State *L); 32 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, int nasize, int nhsize); 33 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); 34 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 35 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 36 | LUAI_FUNC int luaH_getn (Table *t); 37 | 38 | 39 | #if defined(LUA_DEBUG) 40 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 41 | LUAI_FUNC int luaH_isdummy (Node *n); 42 | #endif 43 | 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /lua/src/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h,v 2.11.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltm_h 8 | #define ltm_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | /* 15 | * WARNING: if you change the order of this enumeration, 16 | * grep "ORDER TM" 17 | */ 18 | typedef enum { 19 | TM_INDEX, 20 | TM_NEWINDEX, 21 | TM_GC, 22 | TM_MODE, 23 | TM_LEN, 24 | TM_EQ, /* last tag method with `fast' access */ 25 | TM_ADD, 26 | TM_SUB, 27 | TM_MUL, 28 | TM_DIV, 29 | TM_MOD, 30 | TM_POW, 31 | TM_UNM, 32 | TM_LT, 33 | TM_LE, 34 | TM_CONCAT, 35 | TM_CALL, 36 | TM_N /* number of elements in the enum */ 37 | } TMS; 38 | 39 | 40 | 41 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 42 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 43 | 44 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 45 | 46 | #define ttypename(x) luaT_typenames_[(x) + 1] 47 | #define objtypename(x) ttypename(ttypenv(x)) 48 | 49 | LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS]; 50 | 51 | 52 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 53 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 54 | TMS event); 55 | LUAI_FUNC void luaT_init (lua_State *L); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /lua/src/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /lua/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.43.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | 15 | LUAMOD_API int (luaopen_base) (lua_State *L); 16 | 17 | #define LUA_COLIBNAME "coroutine" 18 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 19 | 20 | #define LUA_TABLIBNAME "table" 21 | LUAMOD_API int (luaopen_table) (lua_State *L); 22 | 23 | #define LUA_IOLIBNAME "io" 24 | LUAMOD_API int (luaopen_io) (lua_State *L); 25 | 26 | #define LUA_OSLIBNAME "os" 27 | LUAMOD_API int (luaopen_os) (lua_State *L); 28 | 29 | #define LUA_STRLIBNAME "string" 30 | LUAMOD_API int (luaopen_string) (lua_State *L); 31 | 32 | #define LUA_BITLIBNAME "bit32" 33 | LUAMOD_API int (luaopen_bit32) (lua_State *L); 34 | 35 | #define LUA_MATHLIBNAME "math" 36 | LUAMOD_API int (luaopen_math) (lua_State *L); 37 | 38 | #define LUA_DBLIBNAME "debug" 39 | LUAMOD_API int (luaopen_debug) (lua_State *L); 40 | 41 | #define LUA_LOADLIBNAME "package" 42 | LUAMOD_API int (luaopen_package) (lua_State *L); 43 | 44 | 45 | /* open all previous libraries */ 46 | LUALIB_API void (luaL_openlibs) (lua_State *L); 47 | 48 | 49 | 50 | #if !defined(lua_assert) 51 | #define lua_assert(x) ((void)0) 52 | #endif 53 | 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /lua/src/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.39.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | /* load one chunk; from lundump.c */ 14 | LUAI_FUNC Closure* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); 15 | 16 | /* make header; from lundump.c */ 17 | LUAI_FUNC void luaU_header (lu_byte* h); 18 | 19 | /* dump one chunk; from ldump.c */ 20 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); 21 | 22 | /* data to catch conversion errors */ 23 | #define LUAC_TAIL "\x19\x93\r\n\x1a\n" 24 | 25 | /* size in bytes of header of binary files */ 26 | #define LUAC_HEADERSIZE (sizeof(LUA_SIGNATURE)-sizeof(char)+2+6+sizeof(LUAC_TAIL)-sizeof(char)) 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /lua/src/lvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lvm.h,v 2.18.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** Lua virtual machine 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lvm_h 8 | #define lvm_h 9 | 10 | 11 | #include "ldo.h" 12 | #include "lobject.h" 13 | #include "ltm.h" 14 | 15 | 16 | #define tostring(L,o) (ttisstring(o) || (luaV_tostring(L, o))) 17 | 18 | #define tonumber(o,n) (ttisnumber(o) || (((o) = luaV_tonumber(o,n)) != NULL)) 19 | 20 | #define equalobj(L,o1,o2) (ttisequal(o1, o2) && luaV_equalobj_(L, o1, o2)) 21 | 22 | #define luaV_rawequalobj(o1,o2) equalobj(NULL,o1,o2) 23 | 24 | 25 | /* not to called directly */ 26 | LUAI_FUNC int luaV_equalobj_ (lua_State *L, const TValue *t1, const TValue *t2); 27 | 28 | 29 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); 30 | LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); 31 | LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); 32 | LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); 33 | LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, 34 | StkId val); 35 | LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, 36 | StkId val); 37 | LUAI_FUNC void luaV_finishOp (lua_State *L); 38 | LUAI_FUNC void luaV_execute (lua_State *L); 39 | LUAI_FUNC void luaV_concat (lua_State *L, int total); 40 | LUAI_FUNC void luaV_arith (lua_State *L, StkId ra, const TValue *rb, 41 | const TValue *rc, TMS op); 42 | LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /lua/src/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c,v 1.35.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #include 9 | 10 | #define lzio_c 11 | #define LUA_CORE 12 | 13 | #include "lua.h" 14 | 15 | #include "llimits.h" 16 | #include "lmem.h" 17 | #include "lstate.h" 18 | #include "lzio.h" 19 | 20 | 21 | int luaZ_fill (ZIO *z) { 22 | size_t size; 23 | lua_State *L = z->L; 24 | const char *buff; 25 | lua_unlock(L); 26 | buff = z->reader(L, z->data, &size); 27 | lua_lock(L); 28 | if (buff == NULL || size == 0) 29 | return EOZ; 30 | z->n = size - 1; /* discount char being returned */ 31 | z->p = buff; 32 | return cast_uchar(*(z->p++)); 33 | } 34 | 35 | 36 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { 37 | z->L = L; 38 | z->reader = reader; 39 | z->data = data; 40 | z->n = 0; 41 | z->p = NULL; 42 | } 43 | 44 | 45 | /* --------------------------------------------------------------- read --- */ 46 | size_t luaZ_read (ZIO *z, void *b, size_t n) { 47 | while (n) { 48 | size_t m; 49 | if (z->n == 0) { /* no bytes in buffer? */ 50 | if (luaZ_fill(z) == EOZ) /* try to read more */ 51 | return n; /* no more input; return number of missing bytes */ 52 | else { 53 | z->n++; /* luaZ_fill consumed first byte; put it back */ 54 | z->p--; 55 | } 56 | } 57 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ 58 | memcpy(b, z->p, m); 59 | z->n -= m; 60 | z->p += m; 61 | b = (char *)b + m; 62 | n -= m; 63 | } 64 | return 0; 65 | } 66 | 67 | /* ------------------------------------------------------------------------ */ 68 | char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) { 69 | if (n > buff->buffsize) { 70 | if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; 71 | luaZ_resizebuffer(L, buff, n); 72 | } 73 | return buff->buffer; 74 | } 75 | 76 | 77 | -------------------------------------------------------------------------------- /lua/src/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h,v 1.26.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lzio_h 9 | #define lzio_h 10 | 11 | #include "lua.h" 12 | 13 | #include "lmem.h" 14 | 15 | 16 | #define EOZ (-1) /* end of stream */ 17 | 18 | typedef struct Zio ZIO; 19 | 20 | #define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z)) 21 | 22 | 23 | typedef struct Mbuffer { 24 | char *buffer; 25 | size_t n; 26 | size_t buffsize; 27 | } Mbuffer; 28 | 29 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) 30 | 31 | #define luaZ_buffer(buff) ((buff)->buffer) 32 | #define luaZ_sizebuffer(buff) ((buff)->buffsize) 33 | #define luaZ_bufflen(buff) ((buff)->n) 34 | 35 | #define luaZ_resetbuffer(buff) ((buff)->n = 0) 36 | 37 | 38 | #define luaZ_resizebuffer(L, buff, size) \ 39 | (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ 40 | (buff)->buffsize = size) 41 | 42 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) 43 | 44 | 45 | LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); 46 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, 47 | void *data); 48 | LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ 49 | 50 | 51 | 52 | /* --------- Private Part ------------------ */ 53 | 54 | struct Zio { 55 | size_t n; /* bytes still unread */ 56 | const char *p; /* current position in buffer */ 57 | lua_Reader reader; /* reader function */ 58 | void* data; /* additional data */ 59 | lua_State *L; /* Lua state (for reader) */ 60 | }; 61 | 62 | 63 | LUAI_FUNC int luaZ_fill (ZIO *z); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /readline/compat/dirent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Declaration of POSIX directory browsing functions and types for Win32. 6 | 7 | Author: Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com) 8 | History: Created March 1997. Updated June 2003. 9 | Rights: See end of file. 10 | 11 | */ 12 | 13 | #ifdef __cplusplus 14 | extern "C" 15 | { 16 | #endif 17 | 18 | typedef struct DIR DIR; 19 | 20 | struct dirent 21 | { 22 | char *d_name; 23 | unsigned attrib; 24 | __int64 size; 25 | }; 26 | 27 | DIR *opendir(const char *); 28 | int closedir(DIR *); 29 | struct dirent *readdir(DIR *); 30 | void rewinddir(DIR *); 31 | 32 | /* 33 | 34 | Copyright Kevlin Henney, 1997, 2003. All rights reserved. 35 | 36 | Permission to use, copy, modify, and distribute this software and its 37 | documentation for any purpose is hereby granted without fee, provided 38 | that this copyright and permissions notice appear in all copies and 39 | derivatives. 40 | 41 | This software is supplied "as is" without express or implied warranty. 42 | 43 | But that said, if there are any problems please get in touch. 44 | 45 | */ 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | -------------------------------------------------------------------------------- /readline/compat/fnmatch.c: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include "fnmatch.h" 9 | 10 | //------------------------------------------------------------------------------ 11 | int fnmatch(const char *pattern, const char *string, int flags) 12 | { 13 | return wildmatch(pattern, string, flags); 14 | } 15 | -------------------------------------------------------------------------------- /readline/compat/fnmatch.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #define FNM_MATCH 0 /* Match. */ 9 | #define FNM_NOMATCH 1 /* Match failed. */ 10 | 11 | #define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ 12 | #define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ 13 | #define FNM_PERIOD 0x04 /* Period must be matched by period. */ 14 | #define FNM_LEADING_DIR 0x08 /* Ignore / after Imatch. */ 15 | #define FNM_CASEFOLD 0x10 /* Case insensitive search. */ 16 | 17 | #define FNM_IGNORECASE FNM_CASEFOLD 18 | #define FNM_FILE_NAME FNM_PATHNAME 19 | 20 | int fnmatch(const char *pattern, const char *string, int flags); 21 | -------------------------------------------------------------------------------- /readline/readline/ansi_stdlib.h: -------------------------------------------------------------------------------- 1 | /* ansi_stdlib.h -- An ANSI Standard stdlib.h. */ 2 | /* A minimal stdlib.h containing extern declarations for those functions 3 | that bash uses. */ 4 | 5 | /* Copyright (C) 1993,2023 Free Software Foundation, Inc. 6 | 7 | This file is part of GNU Bash, the Bourne Again SHell. 8 | 9 | Bash is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | Bash is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with Bash. If not, see . 21 | */ 22 | 23 | #if !defined (_STDLIB_H_) 24 | #define _STDLIB_H_ 1 25 | 26 | /* String conversion functions. */ 27 | extern int atoi (); 28 | 29 | extern double atof (); 30 | extern double strtod (); 31 | 32 | /* Memory allocation functions. */ 33 | /* Generic pointer type. */ 34 | #ifndef PTR_T 35 | # define PTR_T void * 36 | #endif /* PTR_T */ 37 | 38 | extern PTR_T malloc (); 39 | extern PTR_T realloc (); 40 | extern void free (); 41 | 42 | /* Other miscellaneous functions. */ 43 | extern void abort (); 44 | extern void exit (); 45 | extern char *getenv (); 46 | extern void qsort (); 47 | 48 | #endif /* _STDLIB_H */ 49 | -------------------------------------------------------------------------------- /readline/readline/doc/history.dvi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisant996/clink/d8a218ad53457119ef4e4dd370bed22f63ec458e/readline/readline/doc/history.dvi -------------------------------------------------------------------------------- /readline/readline/doc/history.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisant996/clink/d8a218ad53457119ef4e4dd370bed22f63ec458e/readline/readline/doc/history.pdf -------------------------------------------------------------------------------- /readline/readline/doc/readline.dvi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisant996/clink/d8a218ad53457119ef4e4dd370bed22f63ec458e/readline/readline/doc/readline.dvi -------------------------------------------------------------------------------- /readline/readline/doc/readline.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisant996/clink/d8a218ad53457119ef4e4dd370bed22f63ec458e/readline/readline/doc/readline.pdf -------------------------------------------------------------------------------- /readline/readline/doc/rluserman.dvi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisant996/clink/d8a218ad53457119ef4e4dd370bed22f63ec458e/readline/readline/doc/rluserman.dvi -------------------------------------------------------------------------------- /readline/readline/doc/rluserman.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisant996/clink/d8a218ad53457119ef4e4dd370bed22f63ec458e/readline/readline/doc/rluserman.pdf -------------------------------------------------------------------------------- /readline/readline/doc/version.texi: -------------------------------------------------------------------------------- 1 | @ignore 2 | Copyright (C) 1988-2024 Free Software Foundation, Inc. 3 | @end ignore 4 | 5 | @set EDITION 8.3 6 | @set VERSION 8.3 7 | 8 | @set UPDATED 5 January 2024 9 | @set UPDATED-MONTH January 2024 10 | 11 | @set LASTCHANGE Fri Jan 5 11:01:44 EST 2024 12 | -------------------------------------------------------------------------------- /readline/readline/examples/autoconf/BASH_CHECK_LIB_TERMCAP: -------------------------------------------------------------------------------- 1 | AC_DEFUN([BASH_CHECK_LIB_TERMCAP], 2 | [ 3 | if test "X$bash_cv_termcap_lib" = "X"; then 4 | _bash_needmsg=yes 5 | else 6 | AC_MSG_CHECKING(which library has the termcap functions) 7 | _bash_needmsg= 8 | fi 9 | AC_CACHE_VAL(bash_cv_termcap_lib, 10 | [AC_CHECK_FUNC(tgetent, bash_cv_termcap_lib=libc, 11 | [AC_CHECK_LIB(termcap, tgetent, bash_cv_termcap_lib=libtermcap, 12 | [AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo, 13 | [AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses, 14 | [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses, 15 | [AC_CHECK_LIB(ncursesw, tgetent, bash_cv_termcap_lib=libncursesw, 16 | bash_cv_termcap_lib=gnutermcap)])])])])])]) 17 | if test "X$_bash_needmsg" = "Xyes"; then 18 | AC_MSG_CHECKING(which library has the termcap functions) 19 | fi 20 | AC_MSG_RESULT(using $bash_cv_termcap_lib) 21 | if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then 22 | LDFLAGS="$LDFLAGS -L./lib/termcap" 23 | TERMCAP_LIB="./lib/termcap/libtermcap.a" 24 | TERMCAP_DEP="./lib/termcap/libtermcap.a" 25 | elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then 26 | TERMCAP_LIB=-ltermcap 27 | TERMCAP_DEP= 28 | elif test $bash_cv_termcap_lib = libtinfo; then 29 | TERMCAP_LIB=-ltinfo 30 | TERMCAP_DEP= 31 | elif test $bash_cv_termcap_lib = libncurses; then 32 | TERMCAP_LIB=-lncurses 33 | TERMCAP_DEP= 34 | elif test $bash_cv_termcap_lib = libcurses; then 35 | TERMCAP_LIB=-lcurses 36 | TERMCAP_DEP= 37 | elif test $bash_cv_termcap_lib = libc; then 38 | TERMCAP_LIB= 39 | TERMCAP_DEP= 40 | else 41 | TERMCAP_LIB=-lncurses 42 | TERMCAP_DEP= 43 | fi 44 | ]) 45 | -------------------------------------------------------------------------------- /readline/readline/examples/rl-fgets.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisant996/clink/d8a218ad53457119ef4e4dd370bed22f63ec458e/readline/readline/examples/rl-fgets.c -------------------------------------------------------------------------------- /readline/readline/examples/rl-test-timeout: -------------------------------------------------------------------------------- 1 | ./rl-timeout readline1 0.5 2 | ./rl-timeout readline2 0.25 3 | 4 | ./rl-timeout callback1 0.5 5 | ./rl-timeout callback2 0.5 6 | 7 | -------------------------------------------------------------------------------- /readline/readline/examples/rlbasic.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #ifdef HAVE_LOCALE_H 7 | # include 8 | #endif 9 | 10 | #if defined (READLINE_LIBRARY) 11 | # include "readline.h" 12 | # include "history.h" 13 | #else 14 | # include 15 | # include 16 | #endif 17 | 18 | int 19 | main (int c, char **v) 20 | { 21 | char *input; 22 | 23 | #ifdef HAVE_SETLOCALE 24 | setlocale (LC_ALL, ""); 25 | #endif 26 | 27 | for (;;) { 28 | input = readline ((char *)NULL); 29 | if (input == 0) 30 | break; 31 | printf ("%s\n", input); 32 | if (strcmp (input, "exit") == 0) 33 | break; 34 | free (input); 35 | } 36 | exit (0); 37 | } 38 | -------------------------------------------------------------------------------- /readline/readline/examples/rlfe/ChangeLog: -------------------------------------------------------------------------------- 1 | 2004-11-04 Per Bothner 2 | 3 | * pty.c: Import from screen-4.0.2. 4 | * configure.in, Makefile.in, config.h.in: Set up autoconf handling, 5 | copying a bunk of stuff over from screen. 6 | * rlfe.c: Use OpenPTY from pty.c instead of get_master_pty. 7 | 8 | 2004-11-03 Per Bothner 9 | 10 | * rlfe.c: Get input emphasis (boldening) more robust. 11 | 12 | * rlfe.c: Various cleanups on comments and names. 13 | 14 | 2003-11-07 Wolfgang Taeuber 15 | 16 | * Specify a history file and the size of the history file with command 17 | * line options; use EDITOR/VISUAL to set vi/emacs preference. 18 | 19 | 1999-09-03 Chet Ramey 20 | 21 | * fep.c: Memmove is not universally available. This patch assumes 22 | that an autoconf test has been performed, and that memcpy is 23 | available without checking. 24 | 25 | * fep.c: VDISCARD is not universally available, even when termios is. 26 | 27 | * fep.c: If a system doesn't have TIOCSCTTY, the first `open' 28 | performed after setsid allocates a controlling terminal. The 29 | original code would leave the child process running on the slave pty 30 | without a controlling tty if TIOCSCTTY was not available. 31 | 32 | * fep.c: Most versions of SVR4, including solaris, don't allow 33 | terminal ioctl calls on the master side of the pty. 34 | 35 | 1999-08-28 Per Bothner 36 | 37 | * fep.c: Initial release. 38 | -------------------------------------------------------------------------------- /readline/readline/examples/rlfe/extern.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1993-2002 2 | * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de) 3 | * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de) 4 | * Copyright (c) 1987 Oliver Laumann 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program (see the file COPYING); if not, write to the 18 | * Free Software Foundation, Inc., 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 20 | * 21 | **************************************************************** 22 | * $Id: extern.h,v 1.18 1994/05/31 12:31:57 mlschroe Exp $ FAU 23 | */ 24 | 25 | #if !defined(__GNUC__) || __GNUC__ < 2 26 | #undef __attribute__ 27 | #define __attribute__(x) 28 | #endif 29 | 30 | #if !defined (__P) 31 | # if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus) 32 | # define __P(protos) protos 33 | # else 34 | # define __P(protos) () 35 | # endif 36 | #endif 37 | 38 | /* pty.c */ 39 | extern int OpenPTY __P((char **)); 40 | extern void InitPTY __P((int)); 41 | -------------------------------------------------------------------------------- /readline/readline/examples/rlfe/screen.h: -------------------------------------------------------------------------------- 1 | /* Dummy header to avoid modifying pty.c */ 2 | #include "os.h" 3 | -------------------------------------------------------------------------------- /readline/readline/examples/rlkeymaps.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #if defined (READLINE_LIBRARY) 7 | # include "readline.h" 8 | # include "history.h" 9 | #else 10 | # include 11 | # include 12 | #endif 13 | 14 | int 15 | main (int c, char **v) 16 | { 17 | Keymap nmap, emacsmap, newemacs; 18 | int r, errs; 19 | 20 | errs = 0; 21 | nmap = rl_make_keymap (); 22 | 23 | r = rl_set_keymap_name ("emacs", nmap); 24 | if (r >= 0) 25 | { 26 | fprintf (stderr, "rlkeymaps: error: able to rename `emacs' keymap\n"); 27 | errs++; 28 | } 29 | 30 | emacsmap = rl_get_keymap_by_name ("emacs"); 31 | r = rl_set_keymap_name ("newemacs", emacsmap); 32 | if (r >= 0) 33 | { 34 | fprintf (stderr, "rlkeymaps: error: able to set new name for emacs keymap\n"); 35 | errs++; 36 | } 37 | 38 | r = rl_set_keymap_name ("newemacs", nmap); 39 | if (r < 0) 40 | { 41 | fprintf (stderr, "rlkeymaps: error: newemacs: could not set keymap name\n"); 42 | errs++; 43 | } 44 | 45 | newemacs = rl_copy_keymap (emacsmap); 46 | r = rl_set_keymap_name ("newemacs", newemacs); 47 | if (r < 0) 48 | { 49 | fprintf (stderr, "rlkeymaps: error: newemacs: could not set `newemacs' keymap to new map\n"); 50 | errs++; 51 | } 52 | 53 | r = rl_set_keymap_name ("emacscopy", newemacs); 54 | if (r < 0) 55 | { 56 | fprintf (stderr, "rlkeymaps: error: emacscopy: could not rename created keymap\n"); 57 | errs++; 58 | } 59 | 60 | exit (errs); 61 | } 62 | -------------------------------------------------------------------------------- /readline/readline/examples/rlversion.c: -------------------------------------------------------------------------------- 1 | /* 2 | * rlversion -- print out readline's version number 3 | */ 4 | 5 | /* Copyright (C) 1987-2009 Free Software Foundation, Inc. 6 | 7 | This file is part of the GNU Readline Library (Readline), a library for 8 | reading lines of text with interactive input and history editing. 9 | 10 | Readline is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | Readline is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with Readline. If not, see . 22 | */ 23 | 24 | #if defined (HAVE_CONFIG_H) 25 | # include 26 | #endif 27 | 28 | #include 29 | #include 30 | #include "posixstat.h" 31 | 32 | #ifdef HAVE_STDLIB_H 33 | # include 34 | #else 35 | extern void exit(); 36 | #endif 37 | 38 | #ifdef READLINE_LIBRARY 39 | # include "readline.h" 40 | #else 41 | # include 42 | #endif 43 | 44 | int 45 | main() 46 | { 47 | printf ("%s\n", rl_library_version ? rl_library_version : "unknown"); 48 | exit (0); 49 | } 50 | -------------------------------------------------------------------------------- /readline/readline/examples/rlwrap-0.30.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisant996/clink/d8a218ad53457119ef4e4dd370bed22f63ec458e/readline/readline/examples/rlwrap-0.30.tar.gz -------------------------------------------------------------------------------- /readline/readline/gettimeofday.c: -------------------------------------------------------------------------------- 1 | /* gettimeofday.c - gettimeofday replacement using time() */ 2 | 3 | /* Copyright (C) 2020, 2022 Free Software Foundation, Inc. 4 | 5 | This file is part of GNU Bash, the Bourne Again SHell. 6 | 7 | Bash is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | Bash is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Bash. If not, see . 19 | */ 20 | 21 | #include "config.h" 22 | 23 | #if !defined (HAVE_GETTIMEOFDAY) 24 | 25 | #include "posixtime.h" 26 | #if HAVE_STDINT_H 27 | #include 28 | #endif 29 | 30 | /* A version of gettimeofday that just sets tv_sec from time(3) on Unix-like 31 | systems that don't have it, or a version for Win32 systems. */ 32 | int 33 | gettimeofday (struct timeval *restrict tv, void *restrict tz) 34 | { 35 | #if !defined (_WIN32) 36 | tv->tv_sec = (time_t) time ((time_t *)0); 37 | tv->tv_usec = 0; 38 | #else 39 | /* EPOCH is the number of 100 nanosecond intervals from 40 | January 1, 1601 (UTC) to January 1, 1970. 41 | (the correct value has 9 trailing zeros) */ 42 | static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL); 43 | 44 | SYSTEMTIME system_time; 45 | FILETIME file_time; 46 | uint64_t time; 47 | 48 | GetSystemTime(&system_time); 49 | SystemTimeToFileTime(&system_time, &file_time); 50 | time = ((uint64_t)file_time.dwLowDateTime); 51 | time += ((uint64_t)file_time.dwHighDateTime) << 32; 52 | 53 | tp->tv_sec = (long) ((time - EPOCH) / 10000000L); 54 | tp->tv_usec = (long) (system_time.wMilliseconds * 1000); 55 | #endif 56 | 57 | return 0; 58 | } 59 | #endif 60 | -------------------------------------------------------------------------------- /readline/readline/history.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: History 7 | Description: Gnu History library for managing previously-entered lines 8 | URL: http://tiswww.cwru.edu/php/chet/readline/rltop.html 9 | Version: @LIBVERSION@ 10 | Libs: -L${libdir} -lhistory 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /readline/readline/m4/codeset.m4: -------------------------------------------------------------------------------- 1 | # codeset.m4 serial 5 (gettext-0.18.2) 2 | dnl Copyright (C) 2000-2002, 2006, 2008-2014, 2016, 2019-2022 Free Software 3 | dnl Foundation, Inc. 4 | dnl This file is free software; the Free Software Foundation 5 | dnl gives unlimited permission to copy and/or distribute it, 6 | dnl with or without modifications, as long as this notice is preserved. 7 | 8 | dnl From Bruno Haible. 9 | 10 | AC_DEFUN([AM_LANGINFO_CODESET], 11 | [ 12 | AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset], 13 | [AC_LINK_IFELSE( 14 | [AC_LANG_PROGRAM( 15 | [[#include ]], 16 | [[char* cs = nl_langinfo(CODESET); return !cs;]])], 17 | [am_cv_langinfo_codeset=yes], 18 | [am_cv_langinfo_codeset=no]) 19 | ]) 20 | if test $am_cv_langinfo_codeset = yes; then 21 | AC_DEFINE([HAVE_LANGINFO_CODESET], [1], 22 | [Define if you have and nl_langinfo(CODESET).]) 23 | fi 24 | ]) 25 | -------------------------------------------------------------------------------- /readline/readline/parse-colors.h: -------------------------------------------------------------------------------- 1 | /* `dir', `vdir' and `ls' directory listing programs for GNU. 2 | 3 | Modified by Chet Ramey for Readline. 4 | 5 | Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012 Free Software Foundation, 6 | Inc. 7 | 8 | This program is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program. If not, see . */ 20 | 21 | /* Written by Richard Stallman and David MacKenzie. */ 22 | 23 | /* Color support by Peter Anvin and Dennis 24 | Flaherty based on original patches by 25 | Greg Lee . */ 26 | 27 | #ifndef _PARSE_COLORS_H_ 28 | #define _PARSE_COLORS_H_ 29 | 30 | #include "readline.h" 31 | 32 | #define LEN_STR_PAIR(s) sizeof (s) - 1, s 33 | 34 | void _rl_parse_colors (void); 35 | 36 | /* begin_clink_change */ 37 | extern const char* const c_default_completion_prefix_color; 38 | void _rl_free_colors (void); 39 | /* end_clink_change */ 40 | 41 | /* begin_clink_change */ 42 | #ifndef PARSE_COLOR_ONLY_FUNCTION_PROTOTYPES 43 | /* end_clink_change */ 44 | 45 | static const char *const indicator_name[]= 46 | { 47 | "lc", "rc", "ec", "rs", "no", "fi", "di", "ln", "pi", "so", 48 | "bd", "cd", "mi", "or", "ex", "do", "su", "sg", "st", 49 | "ow", "tw", "ca", "mh", "cl", NULL 50 | }; 51 | 52 | /* Buffer for color sequences */ 53 | static char *color_buf; 54 | 55 | /* begin_clink_change */ 56 | #endif // ONLY_FUNCTION_PROTOTYPES 57 | /* end_clink_change */ 58 | 59 | #endif /* !_PARSE_COLORS_H_ */ 60 | -------------------------------------------------------------------------------- /readline/readline/patchlevel: -------------------------------------------------------------------------------- 1 | # Do not edit -- exists only for use by patch 2 | 3 | 7 4 | -------------------------------------------------------------------------------- /readline/readline/posixjmp.h: -------------------------------------------------------------------------------- 1 | /* posixjmp.h -- wrapper for setjmp.h with changes for POSIX systems. */ 2 | 3 | /* Copyright (C) 1987,1991-2015 Free Software Foundation, Inc. 4 | 5 | This file is part of GNU Bash, the Bourne Again SHell. 6 | 7 | Bash is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | Bash is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Bash. If not, see . 19 | */ 20 | 21 | #ifndef _POSIXJMP_H_ 22 | #define _POSIXJMP_H_ 23 | 24 | /* begin_clink_change */ 25 | //#include 26 | #if defined(__MINGW32__) || defined(__MINGW64__) || defined(__BUILD_READLINE_MINGW__) 27 | # include 28 | #else 29 | # include 30 | #endif 31 | /* end_clink_change */ 32 | 33 | /* This *must* be included *after* config.h */ 34 | 35 | #if defined (HAVE_POSIX_SIGSETJMP) 36 | # define procenv_t sigjmp_buf 37 | 38 | # define setjmp_nosigs(x) sigsetjmp((x), 0) 39 | # define setjmp_sigs(x) sigsetjmp((x), 1) 40 | 41 | # define _rl_longjmp(x, n) siglongjmp((x), (n)) 42 | # define sh_longjmp(x, n) siglongjmp((x), (n)) 43 | #else 44 | # define procenv_t jmp_buf 45 | 46 | # define setjmp_nosigs setjmp 47 | # define setjmp_sigs setjmp 48 | 49 | # define _rl_longjmp(x, n) longjmp((x), (n)) 50 | # define sh_longjmp(x, n) longjmp((x), (n)) 51 | #endif 52 | 53 | #endif /* _POSIXJMP_H_ */ 54 | -------------------------------------------------------------------------------- /readline/readline/posixselect.h: -------------------------------------------------------------------------------- 1 | /* posixselect.h -- wrapper for select(2) includes and definitions */ 2 | 3 | /* Copyright (C) 2009 Free Software Foundation, Inc. 4 | 5 | This file is part of GNU Bash, the Bourne Again SHell. 6 | 7 | Bash is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | Bash is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Bash. If not, see . 19 | */ 20 | 21 | #ifndef _POSIXSELECT_H_ 22 | #define _POSIXSELECT_H_ 23 | 24 | #if defined (FD_SET) && !defined (HAVE_SELECT) && !defined (_WIN32) 25 | # define HAVE_SELECT 1 26 | #endif 27 | 28 | #if defined (HAVE_SELECT) 29 | # if !defined (HAVE_SYS_SELECT_H) || !defined (M_UNIX) 30 | # include "posixtime.h" 31 | # endif 32 | #endif /* HAVE_SELECT */ 33 | #if defined (HAVE_SYS_SELECT_H) 34 | # include 35 | #endif 36 | 37 | #ifndef USEC_PER_SEC 38 | # define USEC_PER_SEC 1000000 39 | #endif 40 | 41 | #define USEC_TO_TIMEVAL(us, tv) \ 42 | do { \ 43 | (tv).tv_sec = (us) / USEC_PER_SEC; \ 44 | (tv).tv_usec = (us) % USEC_PER_SEC; \ 45 | } while (0) 46 | 47 | #endif /* _POSIXSELECT_H_ */ 48 | -------------------------------------------------------------------------------- /readline/readline/readline.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: Readline 7 | Description: Gnu Readline library for command line editing 8 | URL: http://tiswww.cwru.edu/php/chet/readline/rltop.html 9 | Version: @LIBVERSION@ 10 | Requires.private: @TERMCAP_PKG_CONFIG_LIB@ 11 | Libs: -L${libdir} -lreadline 12 | Cflags: -I${includedir} 13 | -------------------------------------------------------------------------------- /readline/readline/rlshell.h: -------------------------------------------------------------------------------- 1 | /* rlshell.h -- utility functions normally provided by bash. */ 2 | 3 | /* Copyright (C) 1999-2021 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU Readline Library (Readline), a library 6 | for reading lines of text with interactive input and history editing. 7 | 8 | Readline is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | Readline is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with Readline. If not, see . 20 | */ 21 | 22 | #if !defined (_RL_SHELL_H_) 23 | #define _RL_SHELL_H_ 24 | 25 | #include "rlstdc.h" 26 | 27 | extern char *sh_single_quote (char *); 28 | extern void sh_set_lines_and_columns (int, int); 29 | extern char *sh_get_env_value (const char *); 30 | extern char *sh_get_home_dir (void); 31 | extern int sh_unset_nodelay_mode (int); 32 | 33 | #endif /* _RL_SHELL_H_ */ 34 | -------------------------------------------------------------------------------- /readline/readline/rlstdc.h: -------------------------------------------------------------------------------- 1 | /* stdc.h -- macros to make source compile on both ANSI C and K&R C compilers. */ 2 | 3 | /* Copyright (C) 1993-2009,2023 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU Readline Library (Readline), a library 6 | for reading lines of text with interactive input and history editing. 7 | 8 | Readline is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | Readline is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with Readline. If not, see . 20 | */ 21 | 22 | #if !defined (_RL_STDC_H_) 23 | #define _RL_STDC_H_ 24 | 25 | /* Adapted from BSD /usr/include/sys/cdefs.h. */ 26 | 27 | /* A function can be defined using prototypes and compile on both ANSI C 28 | and traditional C compilers with something like this: 29 | extern char *func PARAMS((char *, char *, int)); */ 30 | 31 | #if !defined (PARAMS) 32 | # if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus) 33 | # define PARAMS(protos) protos 34 | # else 35 | # define PARAMS(protos) () 36 | # endif 37 | #endif 38 | 39 | #ifndef __attribute__ 40 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) 41 | # define __attribute__(x) 42 | # endif 43 | #endif 44 | 45 | #endif /* !_RL_STDC_H_ */ 46 | -------------------------------------------------------------------------------- /readline/readline/savestring.c: -------------------------------------------------------------------------------- 1 | /* savestring.c - function version of savestring for backwards compatibility */ 2 | 3 | /* Copyright (C) 1998,2003,2017 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU Readline Library (Readline), a library 6 | for reading lines of text with interactive input and history editing. 7 | 8 | Readline is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | Readline is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with Readline. If not, see . 20 | */ 21 | 22 | #define READLINE_LIBRARY 23 | 24 | #include 25 | #ifdef HAVE_STRING_H 26 | # include 27 | #endif 28 | #include "xmalloc.h" 29 | 30 | /* Backwards compatibility, now that savestring has been removed from 31 | all `public' readline header files. */ 32 | char * 33 | savestring (const char *s) 34 | { 35 | char *ret; 36 | 37 | ret = (char *)xmalloc (strlen (s) + 1); 38 | strcpy (ret, s); 39 | return ret; 40 | } 41 | -------------------------------------------------------------------------------- /readline/readline/support/mkdirs: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # mkdirs - a work-alike for `mkdir -p' 4 | # 5 | # Chet Ramey 6 | # chet@po.cwru.edu 7 | 8 | # Copyright (C) 1996-2002 Free Software Foundation, Inc. 9 | # 10 | # This program is free software: you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation, either version 3 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this program. If not, see . 22 | 23 | for dir 24 | do 25 | 26 | test -d "$dir" && continue 27 | 28 | tomake=$dir 29 | while test -n "$dir" ; do 30 | # dir=${dir%/*} 31 | # dir=`expr "$dir" ':' '\(/.*\)/[^/]*'` 32 | if dir=`expr "$dir" ':' '\(.*\)/[^/]*'`; then 33 | tomake="$dir $tomake" 34 | else 35 | dir= 36 | fi 37 | done 38 | 39 | for d in $tomake 40 | do 41 | test -d "$d" && continue 42 | echo mkdir "$d" 43 | mkdir "$d" 44 | done 45 | done 46 | 47 | exit 0 48 | -------------------------------------------------------------------------------- /readline/readline/tcap.h: -------------------------------------------------------------------------------- 1 | /* tcap.h -- termcap library functions and variables. */ 2 | 3 | /* Copyright (C) 1996-2015,2023 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU Readline Library (Readline), a library 6 | for reading lines of text with interactive input and history editing. 7 | 8 | Readline is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | Readline is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with Readline. If not, see . 20 | */ 21 | 22 | #if !defined (_RLTCAP_H_) 23 | #define _RLTCAP_H_ 24 | 25 | #if defined (HAVE_CONFIG_H) 26 | # include "config.h" 27 | #endif 28 | 29 | #if defined (HAVE_TERMCAP_H) 30 | # if defined (__linux__) && !defined (SPEED_T_IN_SYS_TYPES) 31 | # include "rltty.h" 32 | # endif 33 | # include 34 | #elif defined (HAVE_NCURSES_TERMCAP_H) 35 | # include 36 | #else 37 | 38 | /* On Solaris2, sys/types.h #includes sys/reg.h, which #defines PC. 39 | Unfortunately, PC is a global variable used by the termcap library. */ 40 | #ifdef PC 41 | # undef PC 42 | #endif 43 | 44 | extern char PC; 45 | extern char *UP, *BC; 46 | 47 | extern short ospeed; 48 | 49 | extern int tgetent (char *, const char *); 50 | extern int tgetflag (const char *); 51 | extern int tgetnum (const char *); 52 | extern char *tgetstr (const char *, char **); 53 | 54 | extern int tputs (const char *, int, int (*)(int)); 55 | 56 | extern char *tgoto (const char *, int, int); 57 | 58 | #endif /* HAVE_TERMCAP_H */ 59 | 60 | #endif /* !_RLTCAP_H_ */ 61 | -------------------------------------------------------------------------------- /readline/readline/xfree.c: -------------------------------------------------------------------------------- 1 | /* xfree.c -- safe version of free that ignores attempts to free NUL */ 2 | 3 | /* Copyright (C) 1991-2010,2017 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU Readline Library (Readline), a library 6 | for reading lines of text with interactive input and history editing. 7 | 8 | Readline is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | Readline is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with Readline. If not, see . 20 | */ 21 | 22 | #define READLINE_LIBRARY 23 | 24 | #if defined (HAVE_CONFIG_H) 25 | #include 26 | #endif 27 | 28 | #if defined (HAVE_STDLIB_H) 29 | # include 30 | #else 31 | # include "ansi_stdlib.h" 32 | #endif /* HAVE_STDLIB_H */ 33 | 34 | #include "xmalloc.h" 35 | 36 | /* **************************************************************** */ 37 | /* */ 38 | /* Memory Deallocation. */ 39 | /* */ 40 | /* **************************************************************** */ 41 | 42 | /* Use this as the function to call when adding unwind protects so we 43 | don't need to know what free() returns. */ 44 | void 45 | xfree (PTR_T string) 46 | { 47 | if (string) 48 | free (string); 49 | } 50 | -------------------------------------------------------------------------------- /readline/readline/xmalloc.h: -------------------------------------------------------------------------------- 1 | /* xmalloc.h -- memory allocation that aborts on errors. */ 2 | 3 | /* Copyright (C) 1999-2009,2010-2023 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU Readline Library (Readline), a library 6 | for reading lines of text with interactive input and history editing. 7 | 8 | Readline is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | Readline is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with Readline. If not, see . 20 | */ 21 | 22 | #if !defined (_XMALLOC_H_) 23 | #define _XMALLOC_H_ 24 | 25 | #if defined (READLINE_LIBRARY) 26 | # include "rlstdc.h" 27 | #else 28 | # include 29 | #endif 30 | 31 | #ifndef PTR_T 32 | # define PTR_T void * 33 | #endif /* !PTR_T */ 34 | 35 | extern PTR_T xmalloc (size_t); 36 | extern PTR_T xrealloc (void *, size_t); 37 | extern void xfree (void *); 38 | 39 | #endif /* _XMALLOC_H_ */ 40 | -------------------------------------------------------------------------------- /run.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | if exist "%~dp0.build\vs2022\bin\debug\clink.bat" (call "%~dp0.build\vs2022\bin\debug\clink.bat"& goto :eof) 3 | if exist "%~dp0.build\vs2019\bin\debug\clink.bat" (call "%~dp0.build\vs2019\bin\debug\clink.bat"& goto :eof) 4 | -------------------------------------------------------------------------------- /wildmatch/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /Linux-* 3 | /Darwin-* 4 | /cov-int 5 | -------------------------------------------------------------------------------- /wildmatch/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | dist: trusty 3 | 4 | language: cpp 5 | compiler: 6 | - gcc 7 | - clang 8 | 9 | before_install: 10 | - sudo apt-get install -y cmake 11 | 12 | install: 13 | - make -s V=1 14 | - make -s V=1 install 15 | 16 | script: 17 | - make -s V=1 test 18 | -------------------------------------------------------------------------------- /wildmatch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.12) 2 | project(wildmatch) 3 | 4 | include(GNUInstallDirs) 5 | include(CTest) 6 | 7 | enable_testing() 8 | set(CMAKE_SKIP_INSTALL_RPATH true) 9 | set(${PROJECT_NAME}_MAJOR_VERSION 0) 10 | set(${PROJECT_NAME}_MINOR_VERSION 5) 11 | set(${PROJECT_NAME}_PATCH_LEVEL 0) 12 | 13 | set(PROJECT_CFLAGS -std=c99 -Wall -Wextra -Wno-unused-parameter) 14 | set(PROJECT_CXXFLAGS -std=c++11 -Wall -Wextra -Wno-unused-parameter) 15 | include_directories(${CMAKE_SOURCE_DIR}) 16 | 17 | install(FILES README.md DESTINATION share/doc/${PROJECT_NAME}) 18 | 19 | add_subdirectory(wildmatch) 20 | add_subdirectory(tests) 21 | -------------------------------------------------------------------------------- /wildmatch/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c), 2016 David Aguilar 2 | Based on the original fnmatch implementation from OpenBSD. 3 | 4 | Copyright (c) 1989, 1993, 1994 5 | The Regents of the University of California. All rights reserved. 6 | 7 | This code is derived from software contributed to Berkeley by 8 | Guido van Rossum. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions 12 | are met: 13 | 1. Redistributions of source code must retain the above copyright 14 | notice, this list of conditions and the following disclaimer. 15 | 2. Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 3. Neither the name of the University nor the names of its contributors 19 | may be used to endorse or promote products derived from this software 20 | without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | SUCH DAMAGE. 33 | -------------------------------------------------------------------------------- /wildmatch/Makefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env make 2 | SH ?= sh 3 | uname_S := $(shell $(SH) -c 'uname -s || echo unknown') 4 | uname_R := $(shell $(SH) -c 'uname -r | cut -d- -f1 || echo 0.0.0') 5 | uname_M := $(shell $(SH) -c 'uname -m || echo unknown') 6 | FLAVOR ?= optimize 7 | 8 | platformdir ?= $(uname_S)-$(uname_R)-$(uname_M)-$(FLAVOR) 9 | builddir ?= $(CURDIR)/build/$(platformdir) 10 | 11 | prefix ?= $(CURDIR)/$(platformdir) 12 | #DESTDIR = 13 | 14 | ifdef V 15 | VERBOSE=1 16 | export VERBOSE 17 | CTEST_OUTPUT_ON_FAILURE=1 18 | export CTEST_OUTPUT_ON_FAILURE 19 | endif 20 | CMAKE_FLAGS ?= -DCMAKE_INSTALL_PREFIX=$(prefix) 21 | CMAKE_FILES = CMakeLists.txt 22 | 23 | # The default target in this Makefile is... 24 | all:: 25 | 26 | install: all 27 | $(MAKE) -C $(builddir) prefix=$(prefix) DESTDIR=$(DESTDIR) install 28 | .PHONY: install 29 | 30 | $(builddir)/stamp: $(CMAKE_FILES) 31 | mkdir -p $(builddir) 32 | cd $(builddir) && cmake $(CMAKE_FLAGS) $(CURDIR) 33 | touch $@ 34 | 35 | all:: $(builddir)/stamp 36 | $(MAKE) -C $(builddir) $(MAKEARGS) all 37 | .PHONY: all 38 | 39 | clean: $(builddir)/stamp 40 | $(MAKE) -C $(builddir) $(MAKEARGS) clean 41 | .PHONY: clean 42 | 43 | test: all 44 | $(MAKE) -C $(builddir) $(MAKEARGS) test 45 | .PHONY: test 46 | -------------------------------------------------------------------------------- /wildmatch/examples/wildmatch-cxx.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | void die(const char *msg) 8 | { 9 | std::cerr << "error: " << msg << std::endl; 10 | exit(1); 11 | } 12 | 13 | int main(int argc, char **argv) 14 | { 15 | int i; 16 | if (argc < 4) { 17 | die("usage: wildmatch \n" 18 | "modes: wildmatch, iwildmatch, pathmatch, fnmatch"); 19 | } 20 | 21 | bool match = false; 22 | 23 | if (!strcmp(argv[1], "wildmatch")) 24 | match = wild::match(argv[3], argv[2]); 25 | else if (!strcmp(argv[1], "iwildmatch")) 26 | match = wild::match(argv[3], argv[2], wild::WILDSTAR | wild::CASEFOLD); 27 | else if (!strcmp(argv[1], "pathmatch") || !strcmp(argv[1], "fnmatch")) 28 | match = wild::match(argv[3], argv[2], wild::FNMATCH); 29 | 30 | return (match) ? 0 : 1; 31 | } 32 | -------------------------------------------------------------------------------- /wildmatch/tests/.gitignore: -------------------------------------------------------------------------------- 1 | /test-wildmatch 2 | /test-results 3 | -------------------------------------------------------------------------------- /wildmatch/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(test-wildmatch test-wildmatch.c) 2 | target_link_libraries(test-wildmatch wildmatch) 3 | set_target_properties(test-wildmatch PROPERTIES RUNTIME_OUTPUT_DIRECTORY 4 | ${CMAKE_CURRENT_SOURCE_DIR}) 5 | target_compile_options(test-wildmatch PRIVATE ${PROJECT_CFLAGS}) 6 | 7 | add_test(git-wildmatch-tests ${CMAKE_CURRENT_SOURCE_DIR}/t3070-wildmatch.sh) 8 | -------------------------------------------------------------------------------- /wildmatch/tests/pch.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #include "pch.h" 5 | -------------------------------------------------------------------------------- /wildmatch/tests/pch.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Christopher Antos 2 | // License: http://opensource.org/licenses/MIT 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | -------------------------------------------------------------------------------- /wildmatch/tests/test-wildmatch.c: -------------------------------------------------------------------------------- 1 | /* This test is from Git's t/helper/test-wildmatch.c */ 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | void die(const char *msg) 10 | { 11 | fprintf(stderr, "%s\n", msg); 12 | exit(1); 13 | } 14 | 15 | int main(int argc, char **argv) 16 | { 17 | int i; 18 | if (argc < 4) { 19 | die("usage: test-wildmatch \n" 20 | "modes: wildmatch, iwildmatch, pathmatch"); 21 | } 22 | for (i = 2; i < argc; i++) { 23 | if (argv[i][0] == '/') 24 | die("Forward slash is not allowed at the beginning of the\n" 25 | "pattern because Windows does not like it. Use `XXX/' instead."); 26 | else if (!strncmp(argv[i], "XXX/", 4)) 27 | argv[i] += 3; 28 | } 29 | if (!strcmp(argv[1], "wildmatch")) 30 | return !!wildmatch(argv[3], argv[2], WM_WILDSTAR); 31 | else if (!strcmp(argv[1], "iwildmatch")) 32 | return !!wildmatch(argv[3], argv[2], WM_WILDSTAR | WM_CASEFOLD); 33 | else if (!strcmp(argv[1], "pathmatch")) 34 | return !!wildmatch(argv[3], argv[2], 0); 35 | else 36 | return 1; 37 | } 38 | -------------------------------------------------------------------------------- /wildmatch/tests/test-wildmatch.h: -------------------------------------------------------------------------------- 1 | #ifndef __TEST_WILDMATCH_H__ 2 | #define __TEST_WILDMATCH_H__ 3 | 4 | #include 5 | 6 | #define test_fail(x) {{ \ 7 | fprintf(stderr, "error: %s:%d\n", __FILE__, __LINE__); \ 8 | return x; \ 9 | }} 10 | 11 | #define assert_true(expr) {{ \ 12 | if (!(expr)) { \ 13 | test_fail(1); \ 14 | } \ 15 | }} 16 | 17 | #define assert_equal(a, b) assert_true((a) == (b)) 18 | #define assert_not_equal(a, b) assert_true((a) != (b)) 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /wildmatch/wildmatch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(wildmatch SHARED wildmatch.c) 2 | target_compile_options(wildmatch PRIVATE ${PROJECT_CFLAGS}) 3 | 4 | add_library(wildmatch-cxx SHARED wildmatch.cpp) 5 | target_compile_options(wildmatch-cxx PRIVATE ${PROJECT_CXXFLAGS}) 6 | 7 | install(TARGETS wildmatch wildmatch-cxx DESTINATION ${CMAKE_INSTALL_LIBDIR}) 8 | install(FILES wildmatch.h DESTINATION include/${PROJECT_NAME}) 9 | install(FILES wildmatch.hpp DESTINATION include/${PROJECT_NAME}) 10 | -------------------------------------------------------------------------------- /wildmatch/wildmatch/wildmatch.cpp: -------------------------------------------------------------------------------- 1 | #include "wildmatch.hpp" 2 | #include "wildmatch.c" // avoids a link-time dependency 3 | 4 | namespace wild { 5 | 6 | bool match(const char *pattern, const char *string, int32 flags) 7 | { 8 | return wildmatch(pattern, string, flags) == WM_MATCH; 9 | } 10 | 11 | bool match(const std::string& pattern, const std::string& string, int32 flags) 12 | { 13 | return wildmatch(pattern.c_str(), string.c_str(), flags) == WM_MATCH; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /wildmatch/wildmatch/wildmatch.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace wild { 6 | 7 | /* Flags */ 8 | constexpr int32 FNMATCH = 0x00; /* Zero flags for fnmatch(3) behavior. */ 9 | constexpr int32 NOESCAPE = 0x01; /* Disable backslash escaping. */ 10 | constexpr int32 PATHNAME = 0x02; /* Slash must be matched by slash. */ 11 | constexpr int32 PERIOD = 0x04; /* Period must be matched by period. */ 12 | constexpr int32 LEADING_DIR = 0x08; /* Ignore / after Imatch. */ 13 | constexpr int32 CASEFOLD = 0x10; /* Case insensitive search. */ 14 | constexpr int32 WILDSTAR = 0x40; /* Double-asterisks "**" matches slash too. */ 15 | /* WILDSTAR implies PATHNAME so that single-asterisks "*" can be used for 16 | * matching within path components. 17 | */ 18 | 19 | /* 20 | * wild::WILDSTAR is the default value for `flags` when calling 21 | * wild::match(..). The C++ API enables the extended "**" syntax by default. 22 | * This can be disabled or extended by specifying an explicit value for `flags`. 23 | * 24 | * For example, to get wildstar extended syntax plus case-insensitive 25 | * matching the flag values can be OR-d together, e.g. 26 | * 27 | * if (wild::match(str, pattern, wild::WILDSTAR | wild::CASEFOLD)) { 28 | * // matched 29 | * } 30 | */ 31 | bool match(const char *pattern, const char *string, int32 flags=WILDSTAR); 32 | bool match(const std::string& pattern, const std::string& string, int32 flags=WILDSTAR); 33 | 34 | } /* wild namespace */ 35 | --------------------------------------------------------------------------------