├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── SampleMacro.lua ├── build.bat ├── demo.gif ├── far3sdk ├── README ├── common.filters ├── common.props ├── include │ ├── DlgBuilder.hpp │ ├── PluginSettings.hpp │ ├── SimpleString.hpp │ ├── farcolor.hpp │ ├── farversion.hpp │ └── plugin.hpp └── vc_crt_fix │ ├── vc_crt_fix.asm │ ├── vc_crt_fix_impl.cpp │ └── vc_crt_fix_ulink.cpp └── src ├── CmdLine.cpp ├── CmdLine.hpp ├── GitAutocomplete.cpp ├── GitAutocomplete.hpp ├── GitAutocomplete.rc ├── GitAutocomplete.sln ├── GitAutocomplete.vcxproj ├── GitAutocomplete.vcxproj.filters ├── GitAutocompleteLng.hpp ├── GitAutocompleteW.vc.def ├── GitAutocomplete_en.hlf ├── GitAutocomplete_en.lng ├── GitAutocomplete_ru.hlf ├── GitAutocomplete_ru.lng ├── Guid.hpp ├── Logic.cpp ├── Logic.hpp ├── RefsDialog.cpp ├── RefsDialog.h ├── Trie.cpp ├── Trie.hpp ├── Utils.cpp ├── Utils.hpp └── Version.hpp /.gitignore: -------------------------------------------------------------------------------- 1 | /dist/ 2 | /build/ 3 | 4 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libgit2"] 2 | path = libgit2 3 | url = git@github.com:libgit2/libgit2.git 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Excelsior LLC, http://www.excelsior-usa.com 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | IN THE SOFTWARE. 20 | 21 | Except as contained in this notice, the name of a copyright holder shall not 22 | be used in advertising or otherwise to promote the sale, use or other dealings 23 | in this Software without prior written authorization of the copyright holder. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | About Git Autocomplete 2 | ====================== 3 | 4 | This [Far Manager](http://farmanager.com/) plugin enables you to quickly substitute names of Git references (branches and tags) into the command line using autocompletion and selection: 5 | 6 | ![Demo](demo.gif) 7 | 8 | For plugin settings, see configuration (`F9` - `Options` - `Plugins configuration` - `Git Autocomplete`) and help (`F1`). 9 | 10 | Download and install 11 | ==================== 12 | 13 | To install the plugin, download [the latest distribution](https://github.com/excelsior-oss/far-git-autocomplete/releases/latest) and unzip it into the `%FARPROFILE%` directory. 14 | 15 | This shall place: 16 | 17 | * the plugin itself - in the `Plugins` directory (both x86 and x64 versions), 18 | * a sample macro command - in the `Macros\scripts` directory. 19 | 20 | A macro command is required for invoking the plugin with a hotkey. The default one is `Ctrl+G`. 21 | You can create additional macro commands to invoke the plugin with different settings; see help for details. 22 | 23 | Alternatively you may download and update the plugin via [PlugRing](http://plugring.farmanager.com/plugin.php?pid=967). 24 | 25 | Building from source 26 | ==================== 27 | 28 | To build the plugin and dependent [libgit2 library](https://libgit2.github.com/), you will need: 29 | 30 | * Git 31 | * CMake 32 | * Microsoft Visual Studio Community 2015 or higher 33 | * zip 34 | 35 | Download the sources: 36 | 37 | git clone https://github.com/excelsior-oss/far-git-autocomplete.git --recursive 38 | 39 | And build everything using "MSBuild Command Prompt for VS2015": 40 | 41 | cd far-git-autocomplete 42 | build.bat 43 | 44 | The plugin will be in the `dist` directory. 45 | 46 | Credits 47 | ======= 48 | 49 | The plugin was originally developed by [Vladimir Parfinenko](https://github.com/cypok) and [Ivan Kireev](https://github.com/ivan2804) during the fifth annual [Excelsior Hack Day](https://www.excelsior-usa.com/blog/open-source/from-excelsior-hack-day-v-git-autocomplete-plugin-for-far-manager/). 50 | 51 | Released under the MIT/X11 license, see LICENSE. 52 | 53 | Copyright © 2016 [Excelsior LLC](https://www.excelsior-usa.com) 54 | -------------------------------------------------------------------------------- /SampleMacro.lua: -------------------------------------------------------------------------------- 1 | Macro { 2 | description="Git Autocomplete"; 3 | area="Shell"; key="CtrlG"; 4 | flags=""; 5 | code="Plugin.Call(\"89DF1D5B-F5BB-415B-993D-D34C5FFE049F\")"; 6 | } 7 | -------------------------------------------------------------------------------- /build.bat: -------------------------------------------------------------------------------- 1 | REM Building libgit2 2 | 3 | pushd libgit2 4 | 5 | mkdir build_32 6 | pushd build_32 7 | 8 | cmake -DBUILD_CLAR=OFF -DLIBGIT2_FILENAME=git2_32 -G "Visual Studio 14" .. 9 | cmake --build . --config Release 10 | cmake --build . --config Debug 11 | 12 | popd 13 | 14 | mkdir build_64 15 | pushd build_64 16 | 17 | cmake -DBUILD_CLAR=OFF -DLIBGIT2_FILENAME=git2_64 -G "Visual Studio 14 Win64" .. 18 | cmake --build . --config Release 19 | cmake --build . --config Debug 20 | 21 | popd 22 | 23 | popd 24 | 25 | 26 | REM Building plugin 27 | 28 | pushd src 29 | 30 | msbuild /p:Configuration=Debug /p:Platform=Win32 31 | msbuild /p:Configuration=Release /p:Platform=Win32 32 | msbuild /p:Configuration=Debug /p:Platform=x64 33 | msbuild /p:Configuration=Release /p:Platform=x64 34 | 35 | popd 36 | 37 | 38 | REM Building distribs 39 | 40 | mkdir dist 41 | pushd dist 42 | 43 | call :build_dist 32 ..\build\product\Release.Win32.v14.0 44 | call :build_dist 64 ..\build\product\Release.x64.v14.0 45 | 46 | pushd 32 && zip -r ..\GitAutocomplete-32.zip . && popd 47 | pushd 64 && zip -r ..\GitAutocomplete-64.zip . && popd 48 | pushd universal && zip -r ..\GitAutocomplete-universal.zip . && popd 49 | 50 | call :build_plugring 32 ..\build\product\Release.Win32.v14.0 51 | call :build_plugring 64 ..\build\product\Release.x64.v14.0 52 | 53 | popd 54 | 55 | goto :EOF 56 | 57 | :build_dist 58 | set BITNESS=%1 59 | set BUILD_DIR=%2 60 | 61 | set DST=%BITNESS% 62 | 63 | xcopy /i %BUILD_DIR%\plugins\GitAutocomplete %DST%\Plugins\GitAutocomplete 64 | del %DST%\Plugins\GitAutocomplete\*.map 65 | del %DST%\Plugins\GitAutocomplete\*.pdb 66 | xcopy ..\SampleMacro.lua %DST%\Macros\scripts\ 67 | ren %DST%\Macros\scripts\SampleMacro.lua GitAutocomplete.lua 68 | xcopy /i /e /y %DST% universal 69 | 70 | goto :EOF 71 | 72 | :build_plugring 73 | set BITNESS=%1 74 | set BUILD_DIR=%2 75 | 76 | set DST=%BITNESS%-plugring 77 | 78 | xcopy /i %BUILD_DIR%\plugins\GitAutocomplete %DST% 79 | del %DST%\*.map 80 | del %DST%\*.pdb 81 | pushd %DST% && zip -r ..\GitAutocomplete-%BITNESS%-plugring.zip . && popd 82 | 83 | goto :EOF 84 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/excelsior-oss/far-git-autocomplete/bc13ab4ed718f5ac35d429f35b7e740ffeb43a4d/demo.gif -------------------------------------------------------------------------------- /far3sdk/README: -------------------------------------------------------------------------------- 1 | Far Manager sources are available at http://farmanager.com/svn/trunk 2 | Last checked out revision is 14653 3 | 4 | * include directory contains headers from \plugins\common\unicode 5 | 6 | * vc_crt_fix directory contains files \plugins\common\vc_crt_fix* 7 | 8 | * common.filters and common.props are copied from \_build\vc\config 9 | with our patches 10 | 11 | 12 | These sources are distributed under the following license: 13 | 14 | Copyright (c) 1996 Eugene Roshal 15 | Copyright (c) 2000 Far Group 16 | All rights reserved. 17 | 18 | Redistribution and use in source and binary forms, with or without 19 | modification, are permitted provided that the following conditions 20 | are met: 21 | 1. Redistributions of source code must retain the above copyright 22 | notice, this list of conditions and the following disclaimer. 23 | 2. Redistributions in binary form must reproduce the above copyright 24 | notice, this list of conditions and the following disclaimer in the 25 | documentation and/or other materials provided with the distribution. 26 | 3. The name of the authors may not be used to endorse or promote products 27 | derived from this software without specific prior written permission. 28 | 29 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 30 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 31 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 32 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 33 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 34 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 38 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | 40 | EXCEPTION: 41 | Far Manager plugins that use only the following header files from this 42 | distribution (none or any): farcolor.hpp, plugin.hpp, farcolorW.pas and 43 | pluginW.pas; can be distributed under any other possible license with no 44 | implications from the above license on them. 45 | -------------------------------------------------------------------------------- /far3sdk/common.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | {0329377-fe44-4d7b-833d-cbd2efecd35a} 18 | lng 19 | 20 | 21 | {9b8726bd-d9c1-416c-8039-5e686cf23409} 22 | hlf 23 | 24 | 25 | 26 | 27 | 28 | Source Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Resource Files 35 | 36 | 37 | Language Files 38 | 39 | 40 | Help Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /far3sdk/common.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Debug 8 | Win32 9 | 10 | 11 | Debug 12 | x64 13 | 14 | 15 | Release 16 | Win32 17 | 18 | 19 | Release 20 | x64 21 | 22 | 23 | 24 | $(Configuration).$(Platform).v$(VisualStudioVersion)\$(OutDir) 25 | $(ProjectDir)..\build\ 26 | 27 | 28 | $(ProjectName) 29 | Win32Proj 30 | Unicode 31 | v100 32 | v110 33 | v120 34 | v140 35 | $(OutputsRoot)product\$(CurPath)\ 36 | $(OutputsRoot)intermediate\$(CurPath)\ 37 | false 38 | false 39 | false 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | $(ProjectDir)..\far3sdk\include;%(AdditionalIncludeDirectories) 48 | NOMINMAX;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) 49 | Level3 50 | /J 51 | true 52 | 53 | 54 | 55 | 56 | /Zc:threadSafeInit- %(AdditionalOptions) 57 | 58 | 59 | kernel32.lib;user32.lib;gdi32.lib;advapi32.lib;shell32.lib;ole32.lib;uuid.lib;mpr.lib;netapi32.lib;version.lib;oleaut32.lib;wbemuuid.lib;Rpcrt4.lib;%(AdditionalDependencies) 60 | %(AdditionalLibraryDirectories) 61 | true 62 | Windows 63 | 64 | $(ProjectName)W.vc.def 65 | $(IntDir)$(ProjectName).lib 66 | 67 | 68 | $(ProjectDir)..\far3sdk\include;%(AdditionalIncludeDirectories) 69 | 70 | 71 | 72 | 73 | 74 | Disabled 75 | false 76 | DEBUG;%(PreprocessorDefinitions) 77 | true 78 | MultiThreadedDebug 79 | ProgramDatabase 80 | 81 | 82 | true 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | MaxSpeed 91 | true 92 | true 93 | NDEBUG;%(PreprocessorDefinitions) 94 | false 95 | MultiThreaded 96 | false 97 | true 98 | true 99 | 100 | 101 | UseLinkTimeCodeGeneration 102 | 103 | 104 | 105 | 106 | 107 | NoExtensions 108 | 109 | 110 | 111 | 112 | Fixing subsystem version 113 | editbin /nologo /subsystem:console,5.0 /osversion:5.0 $(OutDir)$(TargetName)$(TargetExt) > nul 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | Fixing subsystem version 124 | editbin /nologo /subsystem:console,5.2 /osversion:5.2 $(OutDir)$(TargetName)$(TargetExt) > nul 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | %(Identity) 133 | true 134 | 135 | 136 | true 137 | 138 | 139 | 140 | 141 | 142 | 143 | %(Identity) 144 | copy %(Identity) $(OutDir) > nul 145 | $(OutDir)%(Identity);%(Outputs) 146 | 147 | 148 | %(Identity) 149 | copy %(Identity) $(OutDir) > nul 150 | $(OutDir)%(Identity);%(Outputs) 151 | 152 | 153 | %(Identity) 154 | copy %(Identity) $(OutDir) > nul 155 | $(OutDir)%(Identity);%(Outputs) 156 | 157 | 158 | 159 | 160 | 161 | -------------------------------------------------------------------------------- /far3sdk/include/DlgBuilder.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DLGBUILDER_HPP_E8B6F5CA_37A9_403A_A3F0_9ED7271B2BA7 2 | #define DLGBUILDER_HPP_E8B6F5CA_37A9_403A_A3F0_9ED7271B2BA7 3 | #pragma once 4 | 5 | /* 6 | DlgBuilder.hpp 7 | 8 | Dynamic construction of dialogs for FAR Manager 3.0 build 4765 9 | */ 10 | /* 11 | Copyright © 2009 Far Group 12 | All rights reserved. 13 | 14 | Redistribution and use in source and binary forms, with or without 15 | modification, are permitted provided that the following conditions 16 | are met: 17 | 1. Redistributions of source code must retain the above copyright 18 | notice, this list of conditions and the following disclaimer. 19 | 2. Redistributions in binary form must reproduce the above copyright 20 | notice, this list of conditions and the following disclaimer in the 21 | documentation and/or other materials provided with the distribution. 22 | 3. The name of the authors may not be used to endorse or promote products 23 | derived from this software without specific prior written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS' AND ANY EXPRESS OR 26 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 27 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 28 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 30 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 34 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | 38 | #ifndef __cplusplus 39 | #error C++ only 40 | #endif 41 | 42 | // Элемент выпадающего списка в диалоге. 43 | struct DialogBuilderListItem 44 | { 45 | // Строчка из LNG-файла, которая будет показана в диалоге. 46 | int MessageId; 47 | 48 | // Значение, которое будет записано в поле Value при выборе этой строчки. 49 | int ItemValue; 50 | }; 51 | 52 | template 53 | struct DialogItemBinding 54 | { 55 | int BeforeLabelID; 56 | int AfterLabelID; 57 | 58 | DialogItemBinding() 59 | : BeforeLabelID(-1), AfterLabelID(-1) 60 | { 61 | } 62 | 63 | virtual ~DialogItemBinding() 64 | { 65 | }; 66 | 67 | virtual void SaveValue(T *Item, int RadioGroupIndex) 68 | { 69 | } 70 | }; 71 | 72 | template 73 | struct CheckBoxBinding: public DialogItemBinding 74 | { 75 | private: 76 | BOOL *Value; 77 | int Mask; 78 | 79 | public: 80 | CheckBoxBinding(int *aValue, int aMask) : Value(aValue), Mask(aMask) { } 81 | 82 | virtual void SaveValue(T *Item, int RadioGroupIndex) override 83 | { 84 | if (!Mask) 85 | { 86 | *Value = Item->Selected; 87 | } 88 | else 89 | { 90 | if (Item->Selected) 91 | *Value |= Mask; 92 | else 93 | *Value &= ~Mask; 94 | } 95 | } 96 | }; 97 | 98 | template 99 | struct RadioButtonBinding: public DialogItemBinding 100 | { 101 | private: 102 | int *Value; 103 | 104 | public: 105 | RadioButtonBinding(int *aValue) : Value(aValue) { } 106 | 107 | virtual void SaveValue(T *Item, int RadioGroupIndex) override 108 | { 109 | if (Item->Selected) 110 | *Value = RadioGroupIndex; 111 | } 112 | }; 113 | 114 | /* 115 | Класс для динамического построения диалогов. Автоматически вычисляет положение и размер 116 | для добавляемых контролов, а также размер самого диалога. Автоматически записывает выбранные 117 | значения в указанное место после закрытия диалога по OK. 118 | 119 | По умолчанию каждый контрол размещается в новой строке диалога. Ширина для текстовых строк, 120 | checkbox и radio button вычисляется автоматически, для других элементов передаётся явно. 121 | Есть также возможность добавить статический текст слева или справа от контрола, при помощи 122 | методов AddTextBefore и AddTextAfter. 123 | 124 | Поддерживается также возможность расположения контролов в две колонки. Используется следующим 125 | образом: 126 | - StartColumns() 127 | - добавляются контролы для первой колонки 128 | - ColumnBreak() 129 | - добавляются контролы для второй колонки 130 | - EndColumns() 131 | 132 | Поддерживается также возможность расположения контролов внутри бокса. Используется следующим 133 | образом: 134 | - StartSingleBox() 135 | - добавляются контролы 136 | - EndSingleBox() 137 | 138 | Базовая версия класса используется как внутри кода Far, так и в плагинах. 139 | */ 140 | 141 | template 142 | class DialogBuilderBase 143 | { 144 | protected: 145 | T *m_DialogItems; 146 | DialogItemBinding **m_Bindings; 147 | int m_DialogItemsCount; 148 | int m_DialogItemsAllocated; 149 | int m_NextY; 150 | int m_Indent; 151 | int m_SingleBoxIndex; 152 | int m_FirstButtonID; 153 | int m_CancelButtonID; 154 | int m_ColumnStartIndex; 155 | int m_ColumnBreakIndex; 156 | int m_ColumnStartY; 157 | int m_ColumnEndY; 158 | intptr_t m_ColumnMinWidth; 159 | 160 | static const int SECOND_COLUMN = -2; 161 | 162 | void ReallocDialogItems() 163 | { 164 | // реаллокация инвалидирует указатели на DialogItemEx, возвращённые из 165 | // AddDialogItem и аналогичных методов, поэтому размер массива подбираем такой, 166 | // чтобы все нормальные диалоги помещались без реаллокации 167 | // TODO хорошо бы, чтобы они вообще не инвалидировались 168 | m_DialogItemsAllocated += 64; 169 | if (!m_DialogItems) 170 | { 171 | m_DialogItems = new T[m_DialogItemsAllocated]; 172 | m_Bindings = new DialogItemBinding * [m_DialogItemsAllocated]; 173 | } 174 | else 175 | { 176 | T *NewDialogItems = new T[m_DialogItemsAllocated]; 177 | DialogItemBinding **NewBindings = new DialogItemBinding * [m_DialogItemsAllocated]; 178 | for(int i=0; iType = Type; 200 | m_Bindings [Index] = nullptr; 201 | return Item; 202 | } 203 | 204 | void SetNextY(T *Item) 205 | { 206 | Item->X1 = 5 + m_Indent; 207 | Item->Y1 = Item->Y2 = m_NextY++; 208 | } 209 | 210 | intptr_t ItemWidth(const T &Item) 211 | { 212 | switch(Item.Type) 213 | { 214 | case DI_TEXT: 215 | return TextWidth(Item); 216 | 217 | case DI_CHECKBOX: 218 | case DI_RADIOBUTTON: 219 | case DI_BUTTON: 220 | return TextWidth(Item) + 4; 221 | 222 | case DI_EDIT: 223 | case DI_FIXEDIT: 224 | case DI_COMBOBOX: 225 | case DI_LISTBOX: 226 | case DI_PSWEDIT: 227 | { 228 | intptr_t Width = Item.X2 - Item.X1 + 1; 229 | // стрелка history занимает дополнительное место, но раньше она рисовалась поверх рамки??? 230 | if (Item.Flags & DIF_HISTORY) 231 | Width++; 232 | return Width; 233 | } 234 | 235 | default: 236 | break; 237 | } 238 | return 0; 239 | } 240 | 241 | void AddBorder(const wchar_t *TitleText) 242 | { 243 | T *Title = AddDialogItem(DI_DOUBLEBOX, TitleText); 244 | Title->X1 = 3; 245 | Title->Y1 = 1; 246 | } 247 | 248 | void UpdateBorderSize() 249 | { 250 | T *Title = &m_DialogItems[0]; 251 | intptr_t MaxWidth = MaxTextWidth(); 252 | intptr_t MaxHeight = 0; 253 | Title->X2 = Title->X1 + MaxWidth + 3; 254 | 255 | for (int i=1; iX2; 261 | } 262 | else if (m_DialogItems[i].Type == DI_TEXT && (m_DialogItems[i].Flags & DIF_CENTERTEXT)) 263 | {//BUGBUG: two columns items are not supported 264 | m_DialogItems[i].X2 = m_DialogItems[i].X1 + MaxWidth - 1; 265 | } 266 | 267 | if (m_DialogItems[i].Y2 > MaxHeight) 268 | { 269 | MaxHeight = m_DialogItems[i].Y2; 270 | } 271 | } 272 | 273 | Title->X2 += m_Indent; 274 | Title->Y2 = MaxHeight + 1; 275 | m_Indent = 0; 276 | } 277 | 278 | intptr_t MaxTextWidth() 279 | { 280 | intptr_t MaxWidth = 0; 281 | for(int i=1; i *Binding) 321 | { 322 | m_Bindings [m_DialogItemsCount-1] = Binding; 323 | } 324 | 325 | int GetItemID(T *Item) const 326 | { 327 | int Index = static_cast(Item - m_DialogItems); 328 | if (Index >= 0 && Index < m_DialogItemsCount) 329 | return Index; 330 | return -1; 331 | } 332 | 333 | DialogItemBinding *FindBinding(T *Item) 334 | { 335 | int Index = static_cast(Item - m_DialogItems); 336 | if (Index >= 0 && Index < m_DialogItemsCount) 337 | return m_Bindings [Index]; 338 | return nullptr; 339 | } 340 | 341 | void SaveValues() 342 | { 343 | int RadioGroupIndex = 0; 344 | for(int i=0; iSaveValue(&m_DialogItems [i], RadioGroupIndex); 353 | } 354 | } 355 | 356 | virtual const wchar_t *GetLangString(int MessageID) 357 | { 358 | return nullptr; 359 | } 360 | 361 | virtual intptr_t DoShowDialog() 362 | { 363 | return -1; 364 | } 365 | 366 | virtual DialogItemBinding *CreateCheckBoxBinding(int *Value, int Mask) 367 | { 368 | return nullptr; 369 | } 370 | 371 | virtual DialogItemBinding *CreateRadioButtonBinding(int *Value) 372 | { 373 | return nullptr; 374 | } 375 | 376 | DialogBuilderBase() 377 | : m_DialogItems(nullptr), m_Bindings(nullptr), m_DialogItemsCount(0), m_DialogItemsAllocated(0), m_NextY(2), m_Indent(0), m_SingleBoxIndex(-1), 378 | m_FirstButtonID(-1), m_CancelButtonID(-1), 379 | m_ColumnStartIndex(-1), m_ColumnBreakIndex(-1), m_ColumnStartY(-1), m_ColumnEndY(-1), m_ColumnMinWidth(0) 380 | { 381 | } 382 | 383 | virtual ~DialogBuilderBase() 384 | { 385 | for(int i=0; iFlags |= DIF_3STATE; 422 | SetNextY(Item); 423 | Item->X2 = Item->X1 + ItemWidth(*Item); 424 | if (!Mask) 425 | Item->Selected = *Value; 426 | else 427 | Item->Selected = (*Value & Mask) != 0; 428 | SetLastItemBinding(CreateCheckBoxBinding(Value, Mask)); 429 | return Item; 430 | } 431 | 432 | // Добавляет группу радиокнопок. 433 | void AddRadioButtons(int *Value, int OptionCount, const int MessageIDs[], bool FocusOnSelected=false) 434 | { 435 | for(int i=0; iX2 = Item->X1 + ItemWidth(*Item); 440 | if (!i) 441 | Item->Flags |= DIF_GROUP; 442 | if (*Value == i) 443 | { 444 | Item->Selected = TRUE; 445 | if (FocusOnSelected) 446 | Item->Flags |= DIF_FOCUS; 447 | } 448 | SetLastItemBinding(CreateRadioButtonBinding(Value)); 449 | } 450 | } 451 | 452 | // Добавляет поле типа DI_FIXEDIT для редактирования указанного числового значения. 453 | virtual T *AddIntEditField(int *Value, int Width) 454 | { 455 | return nullptr; 456 | } 457 | 458 | virtual T *AddUIntEditField(unsigned int *Value, int Width) 459 | { 460 | return nullptr; 461 | } 462 | 463 | // Добавляет указанную текстовую строку слева от элемента RelativeTo. 464 | T *AddTextBefore(T *RelativeTo, int LabelId) 465 | { 466 | T *Item = AddDialogItem(DI_TEXT, GetLangString(LabelId)); 467 | Item->Y1 = Item->Y2 = RelativeTo->Y1; 468 | Item->X1 = 5 + m_Indent; 469 | Item->X2 = Item->X1 + ItemWidth(*Item) - 1; 470 | 471 | intptr_t RelativeToWidth = RelativeTo->X2 - RelativeTo->X1; 472 | RelativeTo->X1 = Item->X2 + 2; 473 | RelativeTo->X2 = RelativeTo->X1 + RelativeToWidth; 474 | 475 | DialogItemBinding *Binding = FindBinding(RelativeTo); 476 | if (Binding) 477 | Binding->BeforeLabelID = GetItemID(Item); 478 | 479 | return Item; 480 | } 481 | 482 | // Добавляет указанную текстовую строку справа от элемента RelativeTo. 483 | T *AddTextAfter(T *RelativeTo, const wchar_t* Label, int skip=1) 484 | { 485 | T *Item = AddDialogItem(DI_TEXT, Label); 486 | Item->Y1 = Item->Y2 = RelativeTo->Y1; 487 | Item->X1 = RelativeTo->X1 + ItemWidth(*RelativeTo) + skip; 488 | 489 | DialogItemBinding *Binding = FindBinding(RelativeTo); 490 | if (Binding) 491 | Binding->AfterLabelID = GetItemID(Item); 492 | 493 | return Item; 494 | } 495 | 496 | T *AddTextAfter(T *RelativeTo, int LabelId, int skip=1) 497 | { 498 | return AddTextAfter(RelativeTo, GetLangString(LabelId), skip); 499 | } 500 | 501 | // Добавляет кнопку справа от элемента RelativeTo. 502 | T *AddButtonAfter(T *RelativeTo, int LabelId) 503 | { 504 | T *Item = AddDialogItem(DI_BUTTON, GetLangString(LabelId)); 505 | Item->Y1 = Item->Y2 = RelativeTo->Y1; 506 | Item->X1 = RelativeTo->X1 + ItemWidth(*RelativeTo) - 1 + 2; 507 | 508 | DialogItemBinding *Binding = FindBinding(RelativeTo); 509 | if (Binding) 510 | Binding->AfterLabelID = GetItemID(Item); 511 | 512 | return Item; 513 | } 514 | 515 | // Начинает располагать поля диалога в две колонки. 516 | void StartColumns() 517 | { 518 | m_ColumnStartIndex = m_DialogItemsCount; 519 | m_ColumnStartY = m_NextY; 520 | } 521 | 522 | // Завершает колонку полей в диалоге и переходит к следующей колонке. 523 | void ColumnBreak() 524 | { 525 | m_ColumnBreakIndex = m_DialogItemsCount; 526 | m_ColumnEndY = m_NextY; 527 | m_NextY = m_ColumnStartY; 528 | } 529 | 530 | // Завершает расположение полей диалога в две колонки. 531 | void EndColumns() 532 | { 533 | for(int i=m_ColumnStartIndex; i m_ColumnMinWidth) 537 | m_ColumnMinWidth = Width; 538 | if (i >= m_ColumnBreakIndex) 539 | { 540 | m_DialogItems [i].X1 = SECOND_COLUMN; 541 | m_DialogItems [i].X2 = SECOND_COLUMN + Width; 542 | } 543 | } 544 | 545 | m_ColumnStartIndex = -1; 546 | m_ColumnBreakIndex = -1; 547 | if (m_NextY < m_ColumnEndY) 548 | { 549 | m_NextY = m_ColumnEndY; 550 | } 551 | } 552 | 553 | // Начинает располагать поля диалога внутри single box 554 | void StartSingleBox(int MessageId=-1, bool LeftAlign=false) 555 | { 556 | T *SingleBox = AddDialogItem(DI_SINGLEBOX, MessageId == -1 ? L"" : GetLangString(MessageId)); 557 | SingleBox->Flags = LeftAlign ? DIF_LEFTTEXT : DIF_NONE; 558 | SingleBox->X1 = 5; 559 | SingleBox->Y1 = m_NextY++; 560 | m_Indent = 2; 561 | m_SingleBoxIndex = m_DialogItemsCount - 1; 562 | } 563 | 564 | // Завершает расположение полей диалога внутри single box 565 | void EndSingleBox() 566 | { 567 | if (m_SingleBoxIndex != -1) 568 | { 569 | m_DialogItems[m_SingleBoxIndex].Y2 = m_NextY++; 570 | m_Indent = 0; 571 | m_SingleBoxIndex = -1; 572 | } 573 | } 574 | 575 | // Добавляет пустую строку. 576 | void AddEmptyLine() 577 | { 578 | m_NextY++; 579 | } 580 | 581 | // Добавляет сепаратор. 582 | void AddSeparator(int MessageId=-1) 583 | { 584 | return AddSeparator(MessageId == -1 ? L"" : GetLangString(MessageId)); 585 | } 586 | 587 | void AddSeparator(const wchar_t* Text) 588 | { 589 | T *Separator = AddDialogItem(DI_TEXT, Text); 590 | Separator->Flags = DIF_SEPARATOR; 591 | Separator->X1 = -1; 592 | Separator->Y1 = Separator->Y2 = m_NextY++; 593 | } 594 | 595 | // Добавляет сепаратор, кнопки OK и Cancel. 596 | void AddOKCancel(int OKMessageId, int CancelMessageId, int ExtraMessageId = -1, bool Separator=true) 597 | { 598 | if (Separator) 599 | AddSeparator(); 600 | 601 | int MsgIDs[] = { OKMessageId, CancelMessageId, ExtraMessageId }; 602 | int NumButtons = (ExtraMessageId != -1) ? 3 : (CancelMessageId != -1? 2 : 1); 603 | 604 | AddButtons(NumButtons, MsgIDs, 0, 1); 605 | } 606 | 607 | // Добавляет линейку кнопок. 608 | void AddButtons(int ButtonCount, const int* MessageIDs, int defaultButtonIndex = 0, int cancelButtonIndex = -1) 609 | { 610 | int LineY = m_NextY++; 611 | T *PrevButton = nullptr; 612 | 613 | for (int i = 0; i < ButtonCount; i++) 614 | { 615 | T *NewButton = AddDialogItem(DI_BUTTON, GetLangString(MessageIDs[i])); 616 | NewButton->Flags = DIF_CENTERGROUP; 617 | NewButton->Y1 = NewButton->Y2 = LineY; 618 | if (PrevButton) 619 | { 620 | NewButton->X1 = PrevButton->X2 + 1; 621 | } 622 | else 623 | { 624 | NewButton->X1 = 2 + m_Indent; 625 | m_FirstButtonID = m_DialogItemsCount - 1; 626 | } 627 | NewButton->X2 = NewButton->X1 + ItemWidth(*NewButton); 628 | 629 | if (defaultButtonIndex == i) 630 | { 631 | NewButton->Flags |= DIF_DEFAULTBUTTON; 632 | } 633 | if (cancelButtonIndex == i) 634 | m_CancelButtonID = m_DialogItemsCount - 1; 635 | 636 | PrevButton = NewButton; 637 | } 638 | } 639 | 640 | intptr_t ShowDialogEx() 641 | { 642 | UpdateBorderSize(); 643 | UpdateSecondColumnPosition(); 644 | intptr_t Result = DoShowDialog(); 645 | if (Result >= 0 && Result != m_CancelButtonID) 646 | { 647 | SaveValues(); 648 | } 649 | 650 | if (m_FirstButtonID >= 0 && Result >= m_FirstButtonID) 651 | { 652 | Result -= m_FirstButtonID; 653 | } 654 | return Result; 655 | } 656 | 657 | bool ShowDialog() 658 | { 659 | intptr_t Result = ShowDialogEx(); 660 | return Result >= 0 && (m_CancelButtonID < 0 || Result + m_FirstButtonID != m_CancelButtonID); 661 | } 662 | 663 | }; 664 | 665 | class PluginDialogBuilder; 666 | 667 | class DialogAPIBinding: public DialogItemBinding 668 | { 669 | protected: 670 | const PluginStartupInfo &Info; 671 | HANDLE *DialogHandle; 672 | int ID; 673 | 674 | DialogAPIBinding(const PluginStartupInfo &aInfo, HANDLE *aHandle, int aID) 675 | : Info(aInfo), DialogHandle(aHandle), ID(aID) 676 | { 677 | } 678 | }; 679 | 680 | class PluginCheckBoxBinding: public DialogAPIBinding 681 | { 682 | int *Value; 683 | int Mask; 684 | 685 | public: 686 | PluginCheckBoxBinding(const PluginStartupInfo &aInfo, HANDLE *aHandle, int aID, int *aValue, int aMask) 687 | : DialogAPIBinding(aInfo, aHandle, aID), 688 | Value(aValue), Mask(aMask) 689 | { 690 | } 691 | 692 | virtual void SaveValue(FarDialogItem *Item, int RadioGroupIndex) override 693 | { 694 | int Selected = static_cast(Info.SendDlgMessage(*DialogHandle, DM_GETCHECK, ID, nullptr)); 695 | if (!Mask) 696 | { 697 | *Value = Selected; 698 | } 699 | else 700 | { 701 | if (Selected) 702 | *Value |= Mask; 703 | else 704 | *Value &= ~Mask; 705 | } 706 | } 707 | }; 708 | 709 | class PluginRadioButtonBinding: public DialogAPIBinding 710 | { 711 | private: 712 | int *Value; 713 | 714 | public: 715 | PluginRadioButtonBinding(const PluginStartupInfo &aInfo, HANDLE *aHandle, int aID, int *aValue) 716 | : DialogAPIBinding(aInfo, aHandle, aID), 717 | Value(aValue) 718 | { 719 | } 720 | 721 | virtual void SaveValue(FarDialogItem *Item, int RadioGroupIndex) override 722 | { 723 | if (Info.SendDlgMessage(*DialogHandle, DM_GETCHECK, ID, nullptr)) 724 | *Value = RadioGroupIndex; 725 | } 726 | }; 727 | 728 | class PluginEditFieldBinding: public DialogAPIBinding 729 | { 730 | private: 731 | wchar_t *Value; 732 | int MaxSize; 733 | 734 | public: 735 | PluginEditFieldBinding(const PluginStartupInfo &aInfo, HANDLE *aHandle, int aID, wchar_t *aValue, int aMaxSize) 736 | : DialogAPIBinding(aInfo, aHandle, aID), Value(aValue), MaxSize(aMaxSize) 737 | { 738 | } 739 | 740 | virtual void SaveValue(FarDialogItem *Item, int RadioGroupIndex) override 741 | { 742 | const wchar_t *DataPtr = reinterpret_cast(Info.SendDlgMessage(*DialogHandle, DM_GETCONSTTEXTPTR, ID, nullptr)); 743 | lstrcpynW(Value, DataPtr, MaxSize); 744 | } 745 | }; 746 | 747 | class PluginIntEditFieldBinding: public DialogAPIBinding 748 | { 749 | private: 750 | int *Value; 751 | wchar_t Buffer[32]; 752 | wchar_t Mask[32]; 753 | 754 | public: 755 | PluginIntEditFieldBinding(const PluginStartupInfo &aInfo, HANDLE *aHandle, int aID, int *aValue, int Width) 756 | : DialogAPIBinding(aInfo, aHandle, aID), 757 | Value(aValue) 758 | { 759 | memset(Buffer, 0, sizeof(Buffer)); 760 | aInfo.FSF->sprintf(Buffer, L"%u", *aValue); 761 | int MaskWidth = Width < 31 ? Width : 31; 762 | for(int i=1; i(Info.SendDlgMessage(*DialogHandle, DM_GETCONSTTEXTPTR, ID, nullptr)); 771 | *Value = Info.FSF->atoi(DataPtr); 772 | } 773 | 774 | wchar_t *GetBuffer() 775 | { 776 | return Buffer; 777 | } 778 | 779 | const wchar_t *GetMask() const 780 | { 781 | return Mask; 782 | } 783 | }; 784 | 785 | class PluginUIntEditFieldBinding: public DialogAPIBinding 786 | { 787 | private: 788 | unsigned int *Value; 789 | wchar_t Buffer[32]; 790 | wchar_t Mask[32]; 791 | 792 | public: 793 | PluginUIntEditFieldBinding(const PluginStartupInfo &aInfo, HANDLE *aHandle, int aID, unsigned int *aValue, int Width) 794 | : DialogAPIBinding(aInfo, aHandle, aID), 795 | Value(aValue) 796 | { 797 | memset(Buffer, 0, sizeof(Buffer)); 798 | aInfo.FSF->sprintf(Buffer, L"%u", *aValue); 799 | int MaskWidth = Width < 31 ? Width : 31; 800 | for(int i=1; i(Info.SendDlgMessage(*DialogHandle, DM_GETCONSTTEXTPTR, ID, nullptr)); 809 | *Value = static_cast(Info.FSF->atoi64(DataPtr)); 810 | } 811 | 812 | wchar_t *GetBuffer() 813 | { 814 | return Buffer; 815 | } 816 | 817 | const wchar_t *GetMask() const 818 | { 819 | return Mask; 820 | } 821 | }; 822 | 823 | class PluginListControlBinding : public DialogAPIBinding 824 | { 825 | private: 826 | int *SelectedIndex; 827 | wchar_t *TextBuf; 828 | FarList *List; 829 | 830 | public: 831 | PluginListControlBinding(const PluginStartupInfo &aInfo, HANDLE *aHandle, int aID, int *aValue, wchar_t *aText, FarList *aList) 832 | : DialogAPIBinding(aInfo, aHandle, aID), SelectedIndex(aValue), TextBuf(aText), List(aList) 833 | { 834 | } 835 | 836 | PluginListControlBinding(const PluginStartupInfo &aInfo, HANDLE *aHandle, int aID, int *aValue, FarList *aList) 837 | : DialogAPIBinding(aInfo, aHandle, aID), SelectedIndex(aValue), TextBuf(nullptr), List(aList) 838 | { 839 | } 840 | 841 | ~PluginListControlBinding() 842 | { 843 | if (List) 844 | { 845 | delete[] List->Items; 846 | } 847 | delete List; 848 | } 849 | 850 | virtual void SaveValue(FarDialogItem *Item, int RadioGroupIndex) override 851 | { 852 | if (SelectedIndex) 853 | { 854 | *SelectedIndex = static_cast(Info.SendDlgMessage(*DialogHandle, DM_LISTGETCURPOS, ID, nullptr)); 855 | } 856 | if (TextBuf) 857 | { 858 | FarDialogItemData fdid = {sizeof(FarDialogItemData), 0, TextBuf}; 859 | Info.SendDlgMessage(*DialogHandle, DM_GETTEXT, ID, &fdid); 860 | } 861 | } 862 | }; 863 | 864 | /* 865 | Версия класса для динамического построения диалогов, используемая в плагинах к Far. 866 | */ 867 | class PluginDialogBuilder: public DialogBuilderBase 868 | { 869 | protected: 870 | const PluginStartupInfo &Info; 871 | HANDLE DialogHandle; 872 | const wchar_t *HelpTopic; 873 | GUID PluginId; 874 | GUID Id; 875 | FARWINDOWPROC DlgProc; 876 | void* UserParam; 877 | FARDIALOGFLAGS Flags; 878 | 879 | virtual void InitDialogItem(FarDialogItem *Item, const wchar_t *Text) override 880 | { 881 | memset(Item, 0, sizeof(FarDialogItem)); 882 | Item->Data = Text; 883 | } 884 | 885 | virtual int TextWidth(const FarDialogItem &Item) override 886 | { 887 | return lstrlenW(Item.Data); 888 | } 889 | 890 | virtual const wchar_t *GetLangString(int MessageID) override 891 | { 892 | return Info.GetMsg(&PluginId, MessageID); 893 | } 894 | 895 | virtual intptr_t DoShowDialog() override 896 | { 897 | intptr_t Width = m_DialogItems[0].X2+4; 898 | intptr_t Height = m_DialogItems[0].Y2+2; 899 | DialogHandle = Info.DialogInit(&PluginId, &Id, -1, -1, Width, Height, HelpTopic, m_DialogItems, m_DialogItemsCount, 0, Flags, DlgProc, UserParam); 900 | return Info.DialogRun(DialogHandle); 901 | } 902 | 903 | virtual DialogItemBinding *CreateCheckBoxBinding(int *Value, int Mask) override 904 | { 905 | return new PluginCheckBoxBinding(Info, &DialogHandle, m_DialogItemsCount-1, Value, Mask); 906 | } 907 | 908 | virtual DialogItemBinding *CreateRadioButtonBinding(BOOL *Value) override 909 | { 910 | return new PluginRadioButtonBinding(Info, &DialogHandle, m_DialogItemsCount-1, Value); 911 | } 912 | 913 | FarDialogItem *AddListControl(FARDIALOGITEMTYPES Type, int *SelectedItem, wchar_t *Text, int Width, int Height, const wchar_t* ItemsText [], size_t ItemCount, FARDIALOGITEMFLAGS ItemFlags) 914 | { 915 | FarDialogItem *Item = AddDialogItem(Type, Text ? Text : L""); 916 | SetNextY(Item); 917 | Item->X2 = Item->X1 + Width; 918 | Item->Y2 = Item->Y2 + Height; 919 | Item->Flags |= ItemFlags; 920 | 921 | m_NextY += Height; 922 | 923 | FarListItem *ListItems = nullptr; 924 | if (ItemsText) 925 | { 926 | ListItems = new FarListItem[ItemCount]; 927 | for(size_t i=0; i(i)) ? LIF_SELECTED : 0; 931 | } 932 | } 933 | FarList *List = new FarList; 934 | List->StructSize = sizeof(FarList); 935 | List->Items = ListItems; 936 | List->ItemsNumber = ListItems ? ItemCount : 0; 937 | Item->ListItems = List; 938 | 939 | SetLastItemBinding(new PluginListControlBinding(Info, &DialogHandle, m_DialogItemsCount - 1, SelectedItem, Text, List)); 940 | return Item; 941 | } 942 | 943 | FarDialogItem *AddListControl(FARDIALOGITEMTYPES Type, int *SelectedItem, wchar_t *Text, int Width, int Height, const int MessageIDs [], size_t ItemCount, FARDIALOGITEMFLAGS ItemFlags) 944 | { 945 | const wchar_t** ItemsText = nullptr; 946 | if (MessageIDs) 947 | { 948 | ItemsText = new const wchar_t*[ItemCount]; 949 | for (size_t i = 0; i < ItemCount; i++) 950 | { 951 | ItemsText[i] = GetLangString(MessageIDs[i]); 952 | } 953 | } 954 | 955 | FarDialogItem* result = AddListControl(Type, SelectedItem, Text, Width, Height, ItemsText, ItemCount, ItemFlags); 956 | 957 | delete [] ItemsText; 958 | 959 | return result; 960 | } 961 | 962 | public: 963 | PluginDialogBuilder(const PluginStartupInfo &aInfo, const GUID &aPluginId, const GUID &aId, int TitleMessageID, const wchar_t *aHelpTopic, FARWINDOWPROC aDlgProc=nullptr, void* aUserParam=nullptr, FARDIALOGFLAGS aFlags = FDLG_NONE) 964 | : Info(aInfo), DialogHandle(nullptr), HelpTopic(aHelpTopic), PluginId(aPluginId), Id(aId), DlgProc(aDlgProc), UserParam(aUserParam), Flags(aFlags) 965 | { 966 | AddBorder(PluginDialogBuilder::GetLangString(TitleMessageID)); 967 | } 968 | 969 | PluginDialogBuilder(const PluginStartupInfo &aInfo, const GUID &aPluginId, const GUID &aId, const wchar_t *TitleMessage, const wchar_t *aHelpTopic, FARWINDOWPROC aDlgProc=nullptr, void* aUserParam=nullptr, FARDIALOGFLAGS aFlags = FDLG_NONE) 970 | : Info(aInfo), DialogHandle(nullptr), HelpTopic(aHelpTopic), PluginId(aPluginId), Id(aId), DlgProc(aDlgProc), UserParam(aUserParam), Flags(aFlags) 971 | { 972 | AddBorder(TitleMessage); 973 | } 974 | 975 | ~PluginDialogBuilder() 976 | { 977 | Info.DialogFree(DialogHandle); 978 | } 979 | 980 | virtual FarDialogItem *AddIntEditField(int *Value, int Width) override 981 | { 982 | FarDialogItem *Item = AddDialogItem(DI_FIXEDIT, L""); 983 | Item->Flags |= DIF_MASKEDIT; 984 | PluginIntEditFieldBinding *Binding; 985 | Binding = new PluginIntEditFieldBinding(Info, &DialogHandle, m_DialogItemsCount-1, Value, Width); 986 | Item->Data = Binding->GetBuffer(); 987 | Item->Mask = Binding->GetMask(); 988 | SetNextY(Item); 989 | Item->X2 = Item->X1 + Width - 1; 990 | SetLastItemBinding(Binding); 991 | return Item; 992 | } 993 | 994 | virtual FarDialogItem *AddUIntEditField(unsigned int *Value, int Width) override 995 | { 996 | FarDialogItem *Item = AddDialogItem(DI_FIXEDIT, L""); 997 | Item->Flags |= DIF_MASKEDIT; 998 | PluginUIntEditFieldBinding *Binding; 999 | Binding = new PluginUIntEditFieldBinding(Info, &DialogHandle, m_DialogItemsCount-1, Value, Width); 1000 | Item->Data = Binding->GetBuffer(); 1001 | Item->Mask = Binding->GetMask(); 1002 | SetNextY(Item); 1003 | Item->X2 = Item->X1 + Width - 1; 1004 | SetLastItemBinding(Binding); 1005 | return Item; 1006 | } 1007 | 1008 | FarDialogItem *AddEditField(wchar_t *Value, int MaxSize, int Width, const wchar_t *HistoryID = nullptr, bool UseLastHistory = false) 1009 | { 1010 | FarDialogItem *Item = AddDialogItem(DI_EDIT, Value); 1011 | SetNextY(Item); 1012 | Item->X2 = Item->X1 + Width - 1; 1013 | if (HistoryID) 1014 | { 1015 | Item->History = HistoryID; 1016 | Item->Flags |= DIF_HISTORY; 1017 | if (UseLastHistory) 1018 | Item->Flags |= DIF_USELASTHISTORY; 1019 | } 1020 | 1021 | SetLastItemBinding(new PluginEditFieldBinding(Info, &DialogHandle, m_DialogItemsCount-1, Value, MaxSize)); 1022 | return Item; 1023 | } 1024 | 1025 | FarDialogItem *AddPasswordField(wchar_t *Value, int MaxSize, int Width) 1026 | { 1027 | FarDialogItem *Item = AddDialogItem(DI_PSWEDIT, Value); 1028 | SetNextY(Item); 1029 | Item->X2 = Item->X1 + Width - 1; 1030 | 1031 | SetLastItemBinding(new PluginEditFieldBinding(Info, &DialogHandle, m_DialogItemsCount-1, Value, MaxSize)); 1032 | return Item; 1033 | } 1034 | 1035 | FarDialogItem *AddFixEditField(wchar_t *Value, int MaxSize, int Width, const wchar_t *Mask = nullptr) 1036 | { 1037 | FarDialogItem *Item = AddDialogItem(DI_FIXEDIT, Value); 1038 | SetNextY(Item); 1039 | Item->X2 = Item->X1 + Width - 1; 1040 | if (Mask) 1041 | { 1042 | Item->Mask = Mask; 1043 | Item->Flags |= DIF_MASKEDIT; 1044 | } 1045 | 1046 | SetLastItemBinding(new PluginEditFieldBinding(Info, &DialogHandle, m_DialogItemsCount-1, Value, MaxSize)); 1047 | return Item; 1048 | } 1049 | 1050 | FarDialogItem *AddComboBox(int *SelectedItem, wchar_t *Text, int Width, const wchar_t* ItemsText[], size_t ItemCount, FARDIALOGITEMFLAGS ItemFlags) 1051 | { 1052 | return AddListControl(DI_COMBOBOX, SelectedItem, Text, Width, 0, ItemsText, ItemCount, ItemFlags); 1053 | } 1054 | 1055 | FarDialogItem *AddComboBox(int *SelectedItem, wchar_t *Text, int Width, const int MessageIDs[], size_t ItemCount, FARDIALOGITEMFLAGS ItemFlags) 1056 | { 1057 | return AddListControl(DI_COMBOBOX, SelectedItem, Text, Width, 0, MessageIDs, ItemCount, ItemFlags); 1058 | } 1059 | 1060 | FarDialogItem *AddListBox(int *SelectedItem, int Width, int Height, const wchar_t* ItemsText[], size_t ItemCount, FARDIALOGITEMFLAGS ItemFlags) 1061 | { 1062 | return AddListControl(DI_LISTBOX, SelectedItem, nullptr, Width, Height, ItemsText, ItemCount, ItemFlags); 1063 | } 1064 | 1065 | FarDialogItem *AddListBox(int *SelectedItem, int Width, int Height, const int MessageIDs[], size_t ItemCount, FARDIALOGITEMFLAGS ItemFlags) 1066 | { 1067 | return AddListControl(DI_LISTBOX, SelectedItem, nullptr, Width, Height, MessageIDs, ItemCount, ItemFlags); 1068 | } 1069 | }; 1070 | 1071 | #endif // DLGBUILDER_HPP_E8B6F5CA_37A9_403A_A3F0_9ED7271B2BA7 1072 | -------------------------------------------------------------------------------- /far3sdk/include/PluginSettings.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __PLUGINSETTINGS_HPP__ 2 | #define __PLUGINSETTINGS_HPP__ 3 | 4 | #include "plugin.hpp" 5 | 6 | class PluginSettings 7 | { 8 | HANDLE handle; 9 | FARAPISETTINGSCONTROL SettingsControl; 10 | 11 | public: 12 | 13 | PluginSettings(const GUID &guid, FARAPISETTINGSCONTROL SettingsControl) 14 | { 15 | this->SettingsControl = SettingsControl; 16 | handle = INVALID_HANDLE_VALUE; 17 | 18 | FarSettingsCreate settings={sizeof(FarSettingsCreate),guid,handle}; 19 | if (SettingsControl(INVALID_HANDLE_VALUE,SCTL_CREATE,0,&settings)) 20 | handle = settings.Handle; 21 | } 22 | 23 | ~PluginSettings() 24 | { 25 | SettingsControl(handle,SCTL_FREE,0,0); 26 | } 27 | 28 | int CreateSubKey(size_t Root, const wchar_t *Name) 29 | { 30 | FarSettingsValue value={sizeof(FarSettingsValue),Root,Name}; 31 | return (int)SettingsControl(handle,SCTL_CREATESUBKEY,0,&value); 32 | } 33 | 34 | int OpenSubKey(size_t Root, const wchar_t *Name) 35 | { 36 | FarSettingsValue value={sizeof(FarSettingsValue),Root,Name}; 37 | return (int)SettingsControl(handle,SCTL_OPENSUBKEY,0,&value); 38 | } 39 | 40 | bool DeleteSubKey(size_t Root) 41 | { 42 | FarSettingsValue value={sizeof(FarSettingsValue),Root,nullptr}; 43 | return (int)SettingsControl(handle,SCTL_DELETE,0,&value) ? true : false; 44 | } 45 | 46 | bool DeleteValue(size_t Root, const wchar_t *Name) 47 | { 48 | FarSettingsValue value={sizeof(FarSettingsValue),Root,Name}; 49 | return (int)SettingsControl(handle,SCTL_DELETE,0,&value) ? true : false; 50 | } 51 | 52 | const wchar_t *Get(size_t Root, const wchar_t *Name, const wchar_t *Default) 53 | { 54 | FarSettingsItem item={sizeof(FarSettingsItem),Root,Name,FST_STRING}; 55 | if (SettingsControl(handle,SCTL_GET,0,&item)) 56 | { 57 | return item.String; 58 | } 59 | return Default; 60 | } 61 | 62 | void Get(size_t Root, const wchar_t *Name, wchar_t *Value, size_t Size, const wchar_t *Default) 63 | { 64 | lstrcpyn(Value, Get(Root,Name,Default), (int)Size); 65 | } 66 | 67 | unsigned __int64 Get(size_t Root, const wchar_t *Name, unsigned __int64 Default) 68 | { 69 | FarSettingsItem item={sizeof(FarSettingsItem),Root,Name,FST_QWORD}; 70 | if (SettingsControl(handle,SCTL_GET,0,&item)) 71 | { 72 | return item.Number; 73 | } 74 | return Default; 75 | } 76 | 77 | __int64 Get(size_t Root, const wchar_t *Name, __int64 Default) { return (__int64)Get(Root,Name,(unsigned __int64)Default); } 78 | int Get(size_t Root, const wchar_t *Name, int Default) { return (int)Get(Root,Name,(unsigned __int64)Default); } 79 | unsigned int Get(size_t Root, const wchar_t *Name, unsigned int Default) { return (unsigned int)Get(Root,Name,(unsigned __int64)Default); } 80 | DWORD Get(size_t Root, const wchar_t *Name, DWORD Default) { return (DWORD)Get(Root,Name,(unsigned __int64)Default); } 81 | bool Get(size_t Root, const wchar_t *Name, bool Default) { return Get(Root,Name,Default?1ull:0ull)?true:false; } 82 | 83 | size_t Get(size_t Root, const wchar_t *Name, void *Value, size_t Size) 84 | { 85 | FarSettingsItem item={sizeof(FarSettingsItem),Root,Name,FST_DATA}; 86 | if (SettingsControl(handle,SCTL_GET,0,&item)) 87 | { 88 | Size = (item.Data.Size>Size)?Size:item.Data.Size; 89 | memcpy(Value,item.Data.Data,Size); 90 | return Size; 91 | } 92 | return 0; 93 | } 94 | 95 | bool Set(size_t Root, const wchar_t *Name, const wchar_t *Value) 96 | { 97 | FarSettingsItem item={sizeof(FarSettingsItem),Root,Name,FST_STRING}; 98 | item.String=Value; 99 | return SettingsControl(handle,SCTL_SET,0,&item)!=FALSE; 100 | } 101 | 102 | bool Set(size_t Root, const wchar_t *Name, unsigned __int64 Value) 103 | { 104 | FarSettingsItem item={sizeof(FarSettingsItem),Root,Name,FST_QWORD}; 105 | item.Number=Value; 106 | return SettingsControl(handle,SCTL_SET,0,&item)!=FALSE; 107 | } 108 | 109 | bool Set(size_t Root, const wchar_t *Name, __int64 Value) { return Set(Root,Name,(unsigned __int64)Value); } 110 | bool Set(size_t Root, const wchar_t *Name, int Value) { return Set(Root,Name,(unsigned __int64)Value); } 111 | bool Set(size_t Root, const wchar_t *Name, unsigned int Value) { return Set(Root,Name,(unsigned __int64)Value); } 112 | bool Set(size_t Root, const wchar_t *Name, DWORD Value) { return Set(Root,Name,(unsigned __int64)Value); } 113 | bool Set(size_t Root, const wchar_t *Name, bool Value) { return Set(Root,Name,Value?1ull:0ull); } 114 | 115 | bool Set(size_t Root, const wchar_t *Name, const void *Value, size_t Size) 116 | { 117 | FarSettingsItem item={sizeof(FarSettingsItem),Root,Name,FST_DATA}; 118 | item.Data.Size=Size; 119 | item.Data.Data=Value; 120 | return SettingsControl(handle,SCTL_SET,0,&item)!=FALSE; 121 | } 122 | }; 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /far3sdk/include/SimpleString.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/excelsior-oss/far-git-autocomplete/bc13ab4ed718f5ac35d429f35b7e740ffeb43a4d/far3sdk/include/SimpleString.hpp -------------------------------------------------------------------------------- /far3sdk/include/farcolor.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FARCOLOR_HPP_57151931_4591_44A5_92CF_8E51D1FBC57E 2 | #define FARCOLOR_HPP_57151931_4591_44A5_92CF_8E51D1FBC57E 3 | #pragma once 4 | 5 | /* 6 | farcolor.hpp 7 | 8 | Colors Index for FAR Manager 3.0 build 4765 9 | */ 10 | /* 11 | Copyright © 1996 Eugene Roshal 12 | Copyright © 2000 Far Group 13 | All rights reserved. 14 | 15 | Redistribution and use in source and binary forms, with or without 16 | modification, are permitted provided that the following conditions 17 | are met: 18 | 1. Redistributions of source code must retain the above copyright 19 | notice, this list of conditions and the following disclaimer. 20 | 2. Redistributions in binary form must reproduce the above copyright 21 | notice, this list of conditions and the following disclaimer in the 22 | documentation and/or other materials provided with the distribution. 23 | 3. The name of the authors may not be used to endorse or promote products 24 | derived from this software without specific prior written permission. 25 | 26 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS' AND ANY EXPRESS OR 27 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 28 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 29 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 30 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 35 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | 37 | EXCEPTION: 38 | Far Manager plugins that use this header file can be distributed under any 39 | other possible license with no implications from the above license on them. 40 | */ 41 | 42 | 43 | 44 | enum PaletteColors 45 | { 46 | COL_MENUTEXT, 47 | COL_MENUSELECTEDTEXT, 48 | COL_MENUHIGHLIGHT, 49 | COL_MENUSELECTEDHIGHLIGHT, 50 | COL_MENUBOX, 51 | COL_MENUTITLE, 52 | 53 | COL_HMENUTEXT, 54 | COL_HMENUSELECTEDTEXT, 55 | COL_HMENUHIGHLIGHT, 56 | COL_HMENUSELECTEDHIGHLIGHT, 57 | 58 | COL_PANELTEXT, 59 | COL_PANELSELECTEDTEXT, 60 | COL_PANELHIGHLIGHTTEXT, 61 | COL_PANELINFOTEXT, 62 | COL_PANELCURSOR, 63 | COL_PANELSELECTEDCURSOR, 64 | COL_PANELTITLE, 65 | COL_PANELSELECTEDTITLE, 66 | COL_PANELCOLUMNTITLE, 67 | COL_PANELTOTALINFO, 68 | COL_PANELSELECTEDINFO, 69 | 70 | COL_DIALOGTEXT, 71 | COL_DIALOGHIGHLIGHTTEXT, 72 | COL_DIALOGBOX, 73 | COL_DIALOGBOXTITLE, 74 | COL_DIALOGHIGHLIGHTBOXTITLE, 75 | COL_DIALOGEDIT, 76 | COL_DIALOGBUTTON, 77 | COL_DIALOGSELECTEDBUTTON, 78 | COL_DIALOGHIGHLIGHTBUTTON, 79 | COL_DIALOGHIGHLIGHTSELECTEDBUTTON, 80 | 81 | COL_DIALOGLISTTEXT, 82 | COL_DIALOGLISTSELECTEDTEXT, 83 | COL_DIALOGLISTHIGHLIGHT, 84 | COL_DIALOGLISTSELECTEDHIGHLIGHT, 85 | 86 | COL_WARNDIALOGTEXT, 87 | COL_WARNDIALOGHIGHLIGHTTEXT, 88 | COL_WARNDIALOGBOX, 89 | COL_WARNDIALOGBOXTITLE, 90 | COL_WARNDIALOGHIGHLIGHTBOXTITLE, 91 | COL_WARNDIALOGEDIT, 92 | COL_WARNDIALOGBUTTON, 93 | COL_WARNDIALOGSELECTEDBUTTON, 94 | COL_WARNDIALOGHIGHLIGHTBUTTON, 95 | COL_WARNDIALOGHIGHLIGHTSELECTEDBUTTON, 96 | 97 | COL_KEYBARNUM, 98 | COL_KEYBARTEXT, 99 | COL_KEYBARBACKGROUND, 100 | 101 | COL_COMMANDLINE, 102 | 103 | COL_CLOCK, 104 | 105 | COL_VIEWERTEXT, 106 | COL_VIEWERSELECTEDTEXT, 107 | COL_VIEWERSTATUS, 108 | 109 | COL_EDITORTEXT, 110 | COL_EDITORSELECTEDTEXT, 111 | COL_EDITORSTATUS, 112 | 113 | COL_HELPTEXT, 114 | COL_HELPHIGHLIGHTTEXT, 115 | COL_HELPTOPIC, 116 | COL_HELPSELECTEDTOPIC, 117 | COL_HELPBOX, 118 | COL_HELPBOXTITLE, 119 | 120 | COL_PANELDRAGTEXT, 121 | COL_DIALOGEDITUNCHANGED, 122 | COL_PANELSCROLLBAR, 123 | COL_HELPSCROLLBAR, 124 | COL_PANELBOX, 125 | COL_PANELSCREENSNUMBER, 126 | COL_DIALOGEDITSELECTED, 127 | COL_COMMANDLINESELECTED, 128 | COL_VIEWERARROWS, 129 | 130 | COL_DIALOGLISTSCROLLBAR, 131 | COL_MENUSCROLLBAR, 132 | COL_VIEWERSCROLLBAR, 133 | COL_COMMANDLINEPREFIX, 134 | COL_DIALOGDISABLED, 135 | COL_DIALOGEDITDISABLED, 136 | COL_DIALOGLISTDISABLED, 137 | COL_WARNDIALOGDISABLED, 138 | COL_WARNDIALOGEDITDISABLED, 139 | COL_WARNDIALOGLISTDISABLED, 140 | 141 | COL_MENUDISABLEDTEXT, 142 | 143 | COL_EDITORCLOCK, 144 | COL_VIEWERCLOCK, 145 | 146 | COL_DIALOGLISTTITLE, 147 | COL_DIALOGLISTBOX, 148 | 149 | COL_WARNDIALOGEDITSELECTED, 150 | COL_WARNDIALOGEDITUNCHANGED, 151 | 152 | COL_DIALOGCOMBOTEXT, 153 | COL_DIALOGCOMBOSELECTEDTEXT, 154 | COL_DIALOGCOMBOHIGHLIGHT, 155 | COL_DIALOGCOMBOSELECTEDHIGHLIGHT, 156 | COL_DIALOGCOMBOBOX, 157 | COL_DIALOGCOMBOTITLE, 158 | COL_DIALOGCOMBODISABLED, 159 | COL_DIALOGCOMBOSCROLLBAR, 160 | 161 | COL_WARNDIALOGLISTTEXT, 162 | COL_WARNDIALOGLISTSELECTEDTEXT, 163 | COL_WARNDIALOGLISTHIGHLIGHT, 164 | COL_WARNDIALOGLISTSELECTEDHIGHLIGHT, 165 | COL_WARNDIALOGLISTBOX, 166 | COL_WARNDIALOGLISTTITLE, 167 | COL_WARNDIALOGLISTSCROLLBAR, 168 | 169 | COL_WARNDIALOGCOMBOTEXT, 170 | COL_WARNDIALOGCOMBOSELECTEDTEXT, 171 | COL_WARNDIALOGCOMBOHIGHLIGHT, 172 | COL_WARNDIALOGCOMBOSELECTEDHIGHLIGHT, 173 | COL_WARNDIALOGCOMBOBOX, 174 | COL_WARNDIALOGCOMBOTITLE, 175 | COL_WARNDIALOGCOMBODISABLED, 176 | COL_WARNDIALOGCOMBOSCROLLBAR, 177 | 178 | COL_DIALOGLISTARROWS, 179 | COL_DIALOGLISTARROWSDISABLED, 180 | COL_DIALOGLISTARROWSSELECTED, 181 | COL_DIALOGCOMBOARROWS, 182 | COL_DIALOGCOMBOARROWSDISABLED, 183 | COL_DIALOGCOMBOARROWSSELECTED, 184 | COL_WARNDIALOGLISTARROWS, 185 | COL_WARNDIALOGLISTARROWSDISABLED, 186 | COL_WARNDIALOGLISTARROWSSELECTED, 187 | COL_WARNDIALOGCOMBOARROWS, 188 | COL_WARNDIALOGCOMBOARROWSDISABLED, 189 | COL_WARNDIALOGCOMBOARROWSSELECTED, 190 | COL_MENUARROWS, 191 | COL_MENUARROWSDISABLED, 192 | COL_MENUARROWSSELECTED, 193 | COL_COMMANDLINEUSERSCREEN, 194 | COL_EDITORSCROLLBAR, 195 | 196 | COL_MENUGRAYTEXT, 197 | COL_MENUSELECTEDGRAYTEXT, 198 | COL_DIALOGCOMBOGRAY, 199 | COL_DIALOGCOMBOSELECTEDGRAYTEXT, 200 | COL_DIALOGLISTGRAY, 201 | COL_DIALOGLISTSELECTEDGRAYTEXT, 202 | COL_WARNDIALOGCOMBOGRAY, 203 | COL_WARNDIALOGCOMBOSELECTEDGRAYTEXT, 204 | COL_WARNDIALOGLISTGRAY, 205 | COL_WARNDIALOGLISTSELECTEDGRAYTEXT, 206 | 207 | COL_DIALOGDEFAULTBUTTON, 208 | COL_DIALOGSELECTEDDEFAULTBUTTON, 209 | COL_DIALOGHIGHLIGHTDEFAULTBUTTON, 210 | COL_DIALOGHIGHLIGHTSELECTEDDEFAULTBUTTON, 211 | COL_WARNDIALOGDEFAULTBUTTON, 212 | COL_WARNDIALOGSELECTEDDEFAULTBUTTON, 213 | COL_WARNDIALOGHIGHLIGHTDEFAULTBUTTON, 214 | COL_WARNDIALOGHIGHLIGHTSELECTEDDEFAULTBUTTON, 215 | 216 | COL_LASTPALETTECOLOR 217 | }; 218 | 219 | #endif // FARCOLOR_HPP_57151931_4591_44A5_92CF_8E51D1FBC57E 220 | -------------------------------------------------------------------------------- /far3sdk/include/farversion.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/excelsior-oss/far-git-autocomplete/bc13ab4ed718f5ac35d429f35b7e740ffeb43a4d/far3sdk/include/farversion.hpp -------------------------------------------------------------------------------- /far3sdk/include/plugin.hpp: -------------------------------------------------------------------------------- 1 | // validator: no-bom 2 | #ifndef PLUGIN_HPP_3FC978E9_63BE_4FC2_8F96_8188B0AF8363 3 | #define PLUGIN_HPP_3FC978E9_63BE_4FC2_8F96_8188B0AF8363 4 | #pragma once 5 | 6 | /* 7 | plugin.hpp 8 | 9 | Plugin API for Far Manager 3.0 build 4765 10 | */ 11 | /* 12 | Copyright © 1996 Eugene Roshal 13 | Copyright © 2000 Far Group 14 | All rights reserved. 15 | 16 | Redistribution and use in source and binary forms, with or without 17 | modification, are permitted provided that the following conditions 18 | are met: 19 | 1. Redistributions of source code must retain the above copyright 20 | notice, this list of conditions and the following disclaimer. 21 | 2. Redistributions in binary form must reproduce the above copyright 22 | notice, this list of conditions and the following disclaimer in the 23 | documentation and/or other materials provided with the distribution. 24 | 3. The name of the authors may not be used to endorse or promote products 25 | derived from this software without specific prior written permission. 26 | 27 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS' AND ANY EXPRESS OR 28 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 29 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 30 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 31 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 32 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 36 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | 38 | EXCEPTION: 39 | Far Manager plugins that use this header file can be distributed under any 40 | other possible license with no implications from the above license on them. 41 | */ 42 | 43 | 44 | #define FARMANAGERVERSION_MAJOR 3 45 | #define FARMANAGERVERSION_MINOR 0 46 | #define FARMANAGERVERSION_REVISION 0 47 | #define FARMANAGERVERSION_BUILD 4765 48 | #define FARMANAGERVERSION_STAGE VS_RELEASE 49 | 50 | #ifndef RC_INVOKED 51 | 52 | #include 53 | #include 54 | 55 | #undef DefDlgProc 56 | 57 | 58 | #define CP_UNICODE ((uintptr_t)1200) 59 | #define CP_REVERSEBOM ((uintptr_t)1201) 60 | #define CP_DEFAULT ((uintptr_t)-1) 61 | #define CP_REDETECT ((uintptr_t)-2) 62 | 63 | typedef unsigned __int64 FARCOLORFLAGS; 64 | static const FARCOLORFLAGS 65 | FCF_FG_4BIT = 0x0000000000000001ULL, 66 | FCF_BG_4BIT = 0x0000000000000002ULL, 67 | FCF_4BITMASK = 0x0000000000000003ULL, // FCF_FG_4BIT|FCF_BG_4BIT 68 | 69 | FCF_RAWATTR_MASK = 0x000000000000FF00ULL, // stored console attributes 70 | 71 | FCF_EXTENDEDFLAGS = 0xFFFFFFFFFFFFFFFCULL, // ~FCF_4BITMASK 72 | 73 | FCF_FG_BOLD = 0x1000000000000000ULL, 74 | FCF_FG_ITALIC = 0x2000000000000000ULL, 75 | FCF_FG_UNDERLINE = 0x4000000000000000ULL, 76 | FCF_STYLEMASK = 0x7000000000000000ULL, // FCF_FG_BOLD|FCF_FG_ITALIC|FCF_FG_UNDERLINE 77 | 78 | FCF_NONE = 0; 79 | 80 | struct rgba { unsigned char r, g, b, a; }; 81 | 82 | struct FarColor 83 | { 84 | FARCOLORFLAGS Flags; 85 | union 86 | { 87 | COLORREF ForegroundColor; 88 | struct rgba ForegroundRGBA; 89 | } 90 | #ifndef __cplusplus 91 | Foreground 92 | #endif 93 | ; 94 | union 95 | { 96 | COLORREF BackgroundColor; 97 | struct rgba BackgroundRGBA; 98 | } 99 | #ifndef __cplusplus 100 | Background 101 | #endif 102 | ; 103 | void* Reserved; 104 | 105 | #ifdef __cplusplus 106 | bool operator ==(const FarColor& rhs) const 107 | { 108 | return Flags == rhs.Flags 109 | && ForegroundColor == rhs.ForegroundColor 110 | && BackgroundColor == rhs.BackgroundColor 111 | && Reserved == rhs.Reserved; 112 | } 113 | 114 | bool operator !=(const FarColor& rhs) const 115 | { 116 | return !(*this == rhs); 117 | } 118 | #endif 119 | }; 120 | 121 | #define INDEXMASK 0x0000000f 122 | #define COLORMASK 0x00ffffff 123 | #define ALPHAMASK 0xff000000 124 | 125 | #define INDEXVALUE(x) ((x)&INDEXMASK) 126 | #define COLORVALUE(x) ((x)&COLORMASK) 127 | #define ALPHAVALUE(x) ((x)&ALPHAMASK) 128 | 129 | #define IS_OPAQUE(x) (ALPHAVALUE(x)==ALPHAMASK) 130 | #define IS_TRANSPARENT(x) (!ALPHAVALUE(x)) 131 | #define MAKE_OPAQUE(x) (x|=ALPHAMASK) 132 | #define MAKE_TRANSPARENT(x) (x&=COLORMASK) 133 | 134 | typedef unsigned __int64 COLORDIALOGFLAGS; 135 | static const COLORDIALOGFLAGS 136 | CDF_NONE = 0; 137 | 138 | typedef BOOL (WINAPI *FARAPICOLORDIALOG)( 139 | const GUID* PluginId, 140 | COLORDIALOGFLAGS Flags, 141 | struct FarColor *Color 142 | ); 143 | 144 | typedef unsigned __int64 FARMESSAGEFLAGS; 145 | static const FARMESSAGEFLAGS 146 | FMSG_WARNING = 0x0000000000000001ULL, 147 | FMSG_ERRORTYPE = 0x0000000000000002ULL, 148 | FMSG_KEEPBACKGROUND = 0x0000000000000004ULL, 149 | FMSG_LEFTALIGN = 0x0000000000000008ULL, 150 | FMSG_ALLINONE = 0x0000000000000010ULL, 151 | FMSG_MB_OK = 0x0000000000010000ULL, 152 | FMSG_MB_OKCANCEL = 0x0000000000020000ULL, 153 | FMSG_MB_ABORTRETRYIGNORE = 0x0000000000030000ULL, 154 | FMSG_MB_YESNO = 0x0000000000040000ULL, 155 | FMSG_MB_YESNOCANCEL = 0x0000000000050000ULL, 156 | FMSG_MB_RETRYCANCEL = 0x0000000000060000ULL, 157 | FMSG_NONE = 0; 158 | 159 | typedef intptr_t (WINAPI *FARAPIMESSAGE)( 160 | const GUID* PluginId, 161 | const GUID* Id, 162 | FARMESSAGEFLAGS Flags, 163 | const wchar_t *HelpTopic, 164 | const wchar_t * const *Items, 165 | size_t ItemsNumber, 166 | intptr_t ButtonsNumber 167 | ); 168 | 169 | enum FARDIALOGITEMTYPES 170 | { 171 | DI_TEXT = 0, 172 | DI_VTEXT = 1, 173 | DI_SINGLEBOX = 2, 174 | DI_DOUBLEBOX = 3, 175 | DI_EDIT = 4, 176 | DI_PSWEDIT = 5, 177 | DI_FIXEDIT = 6, 178 | DI_BUTTON = 7, 179 | DI_CHECKBOX = 8, 180 | DI_RADIOBUTTON = 9, 181 | DI_COMBOBOX = 10, 182 | DI_LISTBOX = 11, 183 | 184 | DI_USERCONTROL =255, 185 | }; 186 | 187 | /* 188 | Check diagol element type has inputstring? 189 | (DI_EDIT, DI_FIXEDIT, DI_PSWEDIT, etc) 190 | */ 191 | static __inline BOOL IsEdit(enum FARDIALOGITEMTYPES Type) 192 | { 193 | switch (Type) 194 | { 195 | case DI_EDIT: 196 | case DI_FIXEDIT: 197 | case DI_PSWEDIT: 198 | case DI_COMBOBOX: 199 | return TRUE; 200 | default: 201 | return FALSE; 202 | } 203 | } 204 | 205 | typedef unsigned __int64 FARDIALOGITEMFLAGS; 206 | static const FARDIALOGITEMFLAGS 207 | DIF_BOXCOLOR = 0x0000000000000200ULL, 208 | DIF_GROUP = 0x0000000000000400ULL, 209 | DIF_LEFTTEXT = 0x0000000000000800ULL, 210 | DIF_MOVESELECT = 0x0000000000001000ULL, 211 | DIF_SHOWAMPERSAND = 0x0000000000002000ULL, 212 | DIF_CENTERGROUP = 0x0000000000004000ULL, 213 | DIF_NOBRACKETS = 0x0000000000008000ULL, 214 | DIF_MANUALADDHISTORY = 0x0000000000008000ULL, 215 | DIF_SEPARATOR = 0x0000000000010000ULL, 216 | DIF_SEPARATOR2 = 0x0000000000020000ULL, 217 | DIF_EDITOR = 0x0000000000020000ULL, 218 | DIF_LISTNOAMPERSAND = 0x0000000000020000ULL, 219 | DIF_LISTNOBOX = 0x0000000000040000ULL, 220 | DIF_HISTORY = 0x0000000000040000ULL, 221 | DIF_BTNNOCLOSE = 0x0000000000040000ULL, 222 | DIF_CENTERTEXT = 0x0000000000040000ULL, 223 | DIF_SEPARATORUSER = 0x0000000000080000ULL, 224 | DIF_SETSHIELD = 0x0000000000080000ULL, 225 | DIF_EDITEXPAND = 0x0000000000080000ULL, 226 | DIF_DROPDOWNLIST = 0x0000000000100000ULL, 227 | DIF_USELASTHISTORY = 0x0000000000200000ULL, 228 | DIF_MASKEDIT = 0x0000000000400000ULL, 229 | DIF_LISTTRACKMOUSE = 0x0000000000400000ULL, 230 | DIF_LISTTRACKMOUSEINFOCUS = 0x0000000000800000ULL, 231 | DIF_SELECTONENTRY = 0x0000000000800000ULL, 232 | DIF_3STATE = 0x0000000000800000ULL, 233 | DIF_EDITPATH = 0x0000000001000000ULL, 234 | DIF_LISTWRAPMODE = 0x0000000001000000ULL, 235 | DIF_NOAUTOCOMPLETE = 0x0000000002000000ULL, 236 | DIF_LISTAUTOHIGHLIGHT = 0x0000000002000000ULL, 237 | DIF_LISTNOCLOSE = 0x0000000004000000ULL, 238 | DIF_EDITPATHEXEC = 0x0000000004000000ULL, 239 | DIF_HIDDEN = 0x0000000010000000ULL, 240 | DIF_READONLY = 0x0000000020000000ULL, 241 | DIF_NOFOCUS = 0x0000000040000000ULL, 242 | DIF_DISABLE = 0x0000000080000000ULL, 243 | DIF_DEFAULTBUTTON = 0x0000000100000000ULL, 244 | DIF_FOCUS = 0x0000000200000000ULL, 245 | DIF_RIGHTTEXT = 0x0000000400000000ULL, 246 | DIF_WORDWRAP = 0x0000000800000000ULL, 247 | DIF_NONE = 0; 248 | 249 | enum FARMESSAGE 250 | { 251 | DM_FIRST = 0, 252 | DM_CLOSE = 1, 253 | DM_ENABLE = 2, 254 | DM_ENABLEREDRAW = 3, 255 | DM_GETDLGDATA = 4, 256 | DM_GETDLGITEM = 5, 257 | DM_GETDLGRECT = 6, 258 | DM_GETTEXT = 7, 259 | DM_KEY = 9, 260 | DM_MOVEDIALOG = 10, 261 | DM_SETDLGDATA = 11, 262 | DM_SETDLGITEM = 12, 263 | DM_SETFOCUS = 13, 264 | DM_REDRAW = 14, 265 | DM_SETTEXT = 15, 266 | DM_SETMAXTEXTLENGTH = 16, 267 | DM_SHOWDIALOG = 17, 268 | DM_GETFOCUS = 18, 269 | DM_GETCURSORPOS = 19, 270 | DM_SETCURSORPOS = 20, 271 | DM_SETTEXTPTR = 22, 272 | DM_SHOWITEM = 23, 273 | DM_ADDHISTORY = 24, 274 | 275 | DM_GETCHECK = 25, 276 | DM_SETCHECK = 26, 277 | DM_SET3STATE = 27, 278 | 279 | DM_LISTSORT = 28, 280 | DM_LISTGETITEM = 29, 281 | DM_LISTGETCURPOS = 30, 282 | DM_LISTSETCURPOS = 31, 283 | DM_LISTDELETE = 32, 284 | DM_LISTADD = 33, 285 | DM_LISTADDSTR = 34, 286 | DM_LISTUPDATE = 35, 287 | DM_LISTINSERT = 36, 288 | DM_LISTFINDSTRING = 37, 289 | DM_LISTINFO = 38, 290 | DM_LISTGETDATA = 39, 291 | DM_LISTSETDATA = 40, 292 | DM_LISTSETTITLES = 41, 293 | DM_LISTGETTITLES = 42, 294 | 295 | DM_RESIZEDIALOG = 43, 296 | DM_SETITEMPOSITION = 44, 297 | 298 | DM_GETDROPDOWNOPENED = 45, 299 | DM_SETDROPDOWNOPENED = 46, 300 | 301 | DM_SETHISTORY = 47, 302 | 303 | DM_GETITEMPOSITION = 48, 304 | DM_SETINPUTNOTIFY = 49, 305 | DM_SETMOUSEEVENTNOTIFY = DM_SETINPUTNOTIFY, 306 | 307 | DM_EDITUNCHANGEDFLAG = 50, 308 | 309 | DM_GETITEMDATA = 51, 310 | DM_SETITEMDATA = 52, 311 | 312 | DM_LISTSET = 53, 313 | 314 | DM_GETCURSORSIZE = 54, 315 | DM_SETCURSORSIZE = 55, 316 | 317 | DM_LISTGETDATASIZE = 56, 318 | 319 | DM_GETSELECTION = 57, 320 | DM_SETSELECTION = 58, 321 | 322 | DM_GETEDITPOSITION = 59, 323 | DM_SETEDITPOSITION = 60, 324 | 325 | DM_SETCOMBOBOXEVENT = 61, 326 | DM_GETCOMBOBOXEVENT = 62, 327 | 328 | DM_GETCONSTTEXTPTR = 63, 329 | DM_GETDLGITEMSHORT = 64, 330 | DM_SETDLGITEMSHORT = 65, 331 | 332 | DM_GETDIALOGINFO = 66, 333 | 334 | DM_GETDIALOGTITLE = 67, 335 | 336 | DN_FIRST = 4096, 337 | DN_BTNCLICK = 4097, 338 | DN_CTLCOLORDIALOG = 4098, 339 | DN_CTLCOLORDLGITEM = 4099, 340 | DN_CTLCOLORDLGLIST = 4100, 341 | DN_DRAWDIALOG = 4101, 342 | DN_DRAWDLGITEM = 4102, 343 | DN_EDITCHANGE = 4103, 344 | DN_ENTERIDLE = 4104, 345 | DN_GOTFOCUS = 4105, 346 | DN_HELP = 4106, 347 | DN_HOTKEY = 4107, 348 | DN_INITDIALOG = 4108, 349 | DN_KILLFOCUS = 4109, 350 | DN_LISTCHANGE = 4110, 351 | DN_DRAGGED = 4111, 352 | DN_RESIZECONSOLE = 4112, 353 | DN_DRAWDIALOGDONE = 4113, 354 | DN_LISTHOTKEY = 4114, 355 | DN_INPUT = 4115, 356 | DN_CONTROLINPUT = 4116, 357 | DN_CLOSE = 4117, 358 | DN_GETVALUE = 4118, 359 | DN_DROPDOWNOPENED = 4119, 360 | DN_DRAWDLGITEMDONE = 4120, 361 | 362 | DM_USER = 0x4000, 363 | 364 | }; 365 | 366 | enum FARCHECKEDSTATE 367 | { 368 | BSTATE_UNCHECKED = 0, 369 | BSTATE_CHECKED = 1, 370 | BSTATE_3STATE = 2, 371 | BSTATE_TOGGLE = 3, 372 | }; 373 | 374 | enum FARCOMBOBOXEVENTTYPE 375 | { 376 | CBET_KEY = 0x00000001, 377 | CBET_MOUSE = 0x00000002, 378 | }; 379 | 380 | typedef unsigned __int64 LISTITEMFLAGS; 381 | static const LISTITEMFLAGS 382 | LIF_SELECTED = 0x0000000000010000ULL, 383 | LIF_CHECKED = 0x0000000000020000ULL, 384 | LIF_SEPARATOR = 0x0000000000040000ULL, 385 | LIF_DISABLE = 0x0000000000080000ULL, 386 | LIF_GRAYED = 0x0000000000100000ULL, 387 | LIF_HIDDEN = 0x0000000000200000ULL, 388 | LIF_DELETEUSERDATA = 0x0000000080000000ULL, 389 | LIF_NONE = 0; 390 | 391 | 392 | 393 | struct FarListItem 394 | { 395 | LISTITEMFLAGS Flags; 396 | const wchar_t *Text; 397 | intptr_t Reserved[2]; 398 | }; 399 | 400 | struct FarListUpdate 401 | { 402 | size_t StructSize; 403 | intptr_t Index; 404 | struct FarListItem Item; 405 | }; 406 | 407 | struct FarListInsert 408 | { 409 | size_t StructSize; 410 | intptr_t Index; 411 | struct FarListItem Item; 412 | }; 413 | 414 | struct FarListGetItem 415 | { 416 | size_t StructSize; 417 | intptr_t ItemIndex; 418 | struct FarListItem Item; 419 | }; 420 | 421 | struct FarListPos 422 | { 423 | size_t StructSize; 424 | intptr_t SelectPos; 425 | intptr_t TopPos; 426 | }; 427 | 428 | typedef unsigned __int64 FARLISTFINDFLAGS; 429 | static const FARLISTFINDFLAGS 430 | LIFIND_EXACTMATCH = 0x0000000000000001ULL, 431 | LIFIND_NONE = 0; 432 | 433 | 434 | struct FarListFind 435 | { 436 | size_t StructSize; 437 | intptr_t StartIndex; 438 | const wchar_t *Pattern; 439 | FARLISTFINDFLAGS Flags; 440 | }; 441 | 442 | struct FarListDelete 443 | { 444 | size_t StructSize; 445 | intptr_t StartIndex; 446 | intptr_t Count; 447 | }; 448 | 449 | typedef unsigned __int64 FARLISTINFOFLAGS; 450 | static const FARLISTINFOFLAGS 451 | LINFO_SHOWNOBOX = 0x0000000000000400ULL, 452 | LINFO_AUTOHIGHLIGHT = 0x0000000000000800ULL, 453 | LINFO_REVERSEHIGHLIGHT = 0x0000000000001000ULL, 454 | LINFO_WRAPMODE = 0x0000000000008000ULL, 455 | LINFO_SHOWAMPERSAND = 0x0000000000010000ULL, 456 | LINFO_NONE = 0; 457 | 458 | struct FarListInfo 459 | { 460 | size_t StructSize; 461 | FARLISTINFOFLAGS Flags; 462 | size_t ItemsNumber; 463 | intptr_t SelectPos; 464 | intptr_t TopPos; 465 | intptr_t MaxHeight; 466 | intptr_t MaxLength; 467 | }; 468 | 469 | struct FarListItemData 470 | { 471 | size_t StructSize; 472 | intptr_t Index; 473 | size_t DataSize; 474 | void *Data; 475 | }; 476 | 477 | struct FarList 478 | { 479 | size_t StructSize; 480 | size_t ItemsNumber; 481 | struct FarListItem *Items; 482 | }; 483 | 484 | struct FarListTitles 485 | { 486 | size_t StructSize; 487 | size_t TitleSize; 488 | const wchar_t *Title; 489 | size_t BottomSize; 490 | const wchar_t *Bottom; 491 | }; 492 | 493 | struct FarDialogItemColors 494 | { 495 | size_t StructSize; 496 | unsigned __int64 Flags; 497 | size_t ColorsCount; 498 | struct FarColor* Colors; 499 | }; 500 | 501 | struct FAR_CHAR_INFO 502 | { 503 | WCHAR Char; 504 | struct FarColor Attributes; 505 | 506 | #ifdef __cplusplus 507 | static FAR_CHAR_INFO make(wchar_t Char, const FarColor& Attributes) 508 | { 509 | FAR_CHAR_INFO info = { Char, Attributes }; 510 | return info; 511 | } 512 | 513 | bool operator ==(const FAR_CHAR_INFO& rhs) const 514 | { 515 | return Char == rhs.Char && Attributes == rhs.Attributes; 516 | } 517 | 518 | bool operator !=(const FAR_CHAR_INFO& rhs) const 519 | { 520 | return !(*this == rhs); 521 | } 522 | #endif 523 | }; 524 | 525 | struct FarDialogItem 526 | { 527 | enum FARDIALOGITEMTYPES Type; 528 | intptr_t X1,Y1,X2,Y2; 529 | union 530 | { 531 | intptr_t Selected; 532 | struct FarList *ListItems; 533 | struct FAR_CHAR_INFO *VBuf; 534 | intptr_t Reserved0; 535 | } 536 | #ifndef __cplusplus 537 | Param 538 | #endif 539 | ; 540 | const wchar_t *History; 541 | const wchar_t *Mask; 542 | FARDIALOGITEMFLAGS Flags; 543 | const wchar_t *Data; 544 | size_t MaxLength; // terminate 0 not included (if == 0 string size is unlimited) 545 | intptr_t UserData; 546 | intptr_t Reserved[2]; 547 | }; 548 | 549 | struct FarDialogItemData 550 | { 551 | size_t StructSize; 552 | size_t PtrLength; 553 | wchar_t *PtrData; 554 | }; 555 | 556 | struct FarDialogEvent 557 | { 558 | size_t StructSize; 559 | HANDLE hDlg; 560 | intptr_t Msg; 561 | intptr_t Param1; 562 | void* Param2; 563 | intptr_t Result; 564 | }; 565 | 566 | struct OpenDlgPluginData 567 | { 568 | size_t StructSize; 569 | HANDLE hDlg; 570 | }; 571 | 572 | struct DialogInfo 573 | { 574 | size_t StructSize; 575 | GUID Id; 576 | GUID Owner; 577 | }; 578 | 579 | struct FarGetDialogItem 580 | { 581 | size_t StructSize; 582 | size_t Size; 583 | struct FarDialogItem* Item; 584 | }; 585 | 586 | typedef unsigned __int64 FARDIALOGFLAGS; 587 | static const FARDIALOGFLAGS 588 | FDLG_WARNING = 0x0000000000000001ULL, 589 | FDLG_SMALLDIALOG = 0x0000000000000002ULL, 590 | FDLG_NODRAWSHADOW = 0x0000000000000004ULL, 591 | FDLG_NODRAWPANEL = 0x0000000000000008ULL, 592 | FDLG_KEEPCONSOLETITLE = 0x0000000000000010ULL, 593 | FDLG_NONE = 0; 594 | 595 | typedef intptr_t(WINAPI *FARWINDOWPROC)( 596 | HANDLE hDlg, 597 | intptr_t Msg, 598 | intptr_t Param1, 599 | void* Param2 600 | ); 601 | 602 | typedef intptr_t(WINAPI *FARAPISENDDLGMESSAGE)( 603 | HANDLE hDlg, 604 | intptr_t Msg, 605 | intptr_t Param1, 606 | void* Param2 607 | ); 608 | 609 | typedef intptr_t(WINAPI *FARAPIDEFDLGPROC)( 610 | HANDLE hDlg, 611 | intptr_t Msg, 612 | intptr_t Param1, 613 | void* Param2 614 | ); 615 | 616 | typedef HANDLE(WINAPI *FARAPIDIALOGINIT)( 617 | const GUID* PluginId, 618 | const GUID* Id, 619 | intptr_t X1, 620 | intptr_t Y1, 621 | intptr_t X2, 622 | intptr_t Y2, 623 | const wchar_t *HelpTopic, 624 | const struct FarDialogItem *Item, 625 | size_t ItemsNumber, 626 | intptr_t Reserved, 627 | FARDIALOGFLAGS Flags, 628 | FARWINDOWPROC DlgProc, 629 | void* Param 630 | ); 631 | 632 | typedef intptr_t (WINAPI *FARAPIDIALOGRUN)( 633 | HANDLE hDlg 634 | ); 635 | 636 | typedef void (WINAPI *FARAPIDIALOGFREE)( 637 | HANDLE hDlg 638 | ); 639 | 640 | struct FarKey 641 | { 642 | WORD VirtualKeyCode; 643 | DWORD ControlKeyState; 644 | }; 645 | 646 | typedef unsigned __int64 MENUITEMFLAGS; 647 | static const MENUITEMFLAGS 648 | MIF_SELECTED = 0x000000000010000ULL, 649 | MIF_CHECKED = 0x000000000020000ULL, 650 | MIF_SEPARATOR = 0x000000000040000ULL, 651 | MIF_DISABLE = 0x000000000080000ULL, 652 | MIF_GRAYED = 0x000000000100000ULL, 653 | MIF_HIDDEN = 0x000000000200000ULL, 654 | MIF_NONE = 0; 655 | 656 | struct FarMenuItem 657 | { 658 | MENUITEMFLAGS Flags; 659 | const wchar_t *Text; 660 | struct FarKey AccelKey; 661 | intptr_t UserData; 662 | intptr_t Reserved[2]; 663 | }; 664 | 665 | typedef unsigned __int64 FARMENUFLAGS; 666 | static const FARMENUFLAGS 667 | FMENU_SHOWAMPERSAND = 0x0000000000000001ULL, 668 | FMENU_WRAPMODE = 0x0000000000000002ULL, 669 | FMENU_AUTOHIGHLIGHT = 0x0000000000000004ULL, 670 | FMENU_REVERSEAUTOHIGHLIGHT = 0x0000000000000008ULL, 671 | FMENU_CHANGECONSOLETITLE = 0x0000000000000010ULL, 672 | FMENU_NONE = 0; 673 | 674 | typedef intptr_t (WINAPI *FARAPIMENU)( 675 | const GUID* PluginId, 676 | const GUID* Id, 677 | intptr_t X, 678 | intptr_t Y, 679 | intptr_t MaxHeight, 680 | FARMENUFLAGS Flags, 681 | const wchar_t *Title, 682 | const wchar_t *Bottom, 683 | const wchar_t *HelpTopic, 684 | const struct FarKey *BreakKeys, 685 | intptr_t *BreakCode, 686 | const struct FarMenuItem *Item, 687 | size_t ItemsNumber 688 | ); 689 | 690 | 691 | typedef unsigned __int64 PLUGINPANELITEMFLAGS; 692 | static const PLUGINPANELITEMFLAGS 693 | PPIF_SELECTED = 0x0000000040000000ULL, 694 | PPIF_PROCESSDESCR = 0x0000000080000000ULL, 695 | PPIF_NONE = 0; 696 | 697 | struct FarPanelItemFreeInfo 698 | { 699 | size_t StructSize; 700 | HANDLE hPlugin; 701 | }; 702 | 703 | typedef void (WINAPI *FARPANELITEMFREECALLBACK)(void* UserData, const struct FarPanelItemFreeInfo* Info); 704 | 705 | struct UserDataItem 706 | { 707 | void* Data; 708 | FARPANELITEMFREECALLBACK FreeData; 709 | }; 710 | 711 | 712 | struct PluginPanelItem 713 | { 714 | FILETIME CreationTime; 715 | FILETIME LastAccessTime; 716 | FILETIME LastWriteTime; 717 | FILETIME ChangeTime; 718 | unsigned __int64 FileSize; 719 | unsigned __int64 AllocationSize; 720 | const wchar_t *FileName; 721 | const wchar_t *AlternateFileName; 722 | const wchar_t *Description; 723 | const wchar_t *Owner; 724 | const wchar_t * const *CustomColumnData; 725 | size_t CustomColumnNumber; 726 | PLUGINPANELITEMFLAGS Flags; 727 | struct UserDataItem UserData; 728 | uintptr_t FileAttributes; 729 | uintptr_t NumberOfLinks; 730 | uintptr_t CRC32; 731 | intptr_t Reserved[2]; 732 | }; 733 | 734 | struct FarGetPluginPanelItem 735 | { 736 | size_t StructSize; 737 | size_t Size; 738 | struct PluginPanelItem* Item; 739 | }; 740 | 741 | struct SortingPanelItem 742 | { 743 | FILETIME CreationTime; 744 | FILETIME LastAccessTime; 745 | FILETIME LastWriteTime; 746 | FILETIME ChangeTime; 747 | unsigned __int64 FileSize; 748 | unsigned __int64 AllocationSize; 749 | const wchar_t *FileName; 750 | const wchar_t *AlternateFileName; 751 | const wchar_t *Description; 752 | const wchar_t *Owner; 753 | const wchar_t * const *CustomColumnData; 754 | size_t CustomColumnNumber; 755 | PLUGINPANELITEMFLAGS Flags; 756 | struct UserDataItem UserData; 757 | uintptr_t FileAttributes; 758 | uintptr_t NumberOfLinks; 759 | uintptr_t CRC32; 760 | intptr_t Position; 761 | intptr_t SortGroup; 762 | uintptr_t NumberOfStreams; 763 | unsigned __int64 StreamsSize; 764 | }; 765 | 766 | typedef unsigned __int64 PANELINFOFLAGS; 767 | static const PANELINFOFLAGS 768 | PFLAGS_SHOWHIDDEN = 0x0000000000000001ULL, 769 | PFLAGS_HIGHLIGHT = 0x0000000000000002ULL, 770 | PFLAGS_REVERSESORTORDER = 0x0000000000000004ULL, 771 | PFLAGS_USESORTGROUPS = 0x0000000000000008ULL, 772 | PFLAGS_SELECTEDFIRST = 0x0000000000000010ULL, 773 | PFLAGS_REALNAMES = 0x0000000000000020ULL, 774 | PFLAGS_NUMERICSORT = 0x0000000000000040ULL, 775 | PFLAGS_PANELLEFT = 0x0000000000000080ULL, 776 | PFLAGS_DIRECTORIESFIRST = 0x0000000000000100ULL, 777 | PFLAGS_USECRC32 = 0x0000000000000200ULL, 778 | PFLAGS_CASESENSITIVESORT = 0x0000000000000400ULL, 779 | PFLAGS_PLUGIN = 0x0000000000000800ULL, 780 | PFLAGS_VISIBLE = 0x0000000000001000ULL, 781 | PFLAGS_FOCUS = 0x0000000000002000ULL, 782 | PFLAGS_ALTERNATIVENAMES = 0x0000000000004000ULL, 783 | PFLAGS_SHORTCUT = 0x0000000000008000ULL, 784 | PFLAGS_NONE = 0; 785 | 786 | enum PANELINFOTYPE 787 | { 788 | PTYPE_FILEPANEL = 0, 789 | PTYPE_TREEPANEL = 1, 790 | PTYPE_QVIEWPANEL = 2, 791 | PTYPE_INFOPANEL = 3, 792 | }; 793 | 794 | enum OPENPANELINFO_SORTMODES 795 | { 796 | SM_DEFAULT = 0, 797 | SM_UNSORTED = 1, 798 | SM_NAME = 2, 799 | SM_EXT = 3, 800 | SM_MTIME = 4, 801 | SM_CTIME = 5, 802 | SM_ATIME = 6, 803 | SM_SIZE = 7, 804 | SM_DESCR = 8, 805 | SM_OWNER = 9, 806 | SM_COMPRESSEDSIZE = 10, 807 | SM_NUMLINKS = 11, 808 | SM_NUMSTREAMS = 12, 809 | SM_STREAMSSIZE = 13, 810 | SM_FULLNAME = 14, 811 | SM_CHTIME = 15, 812 | 813 | SM_COUNT 814 | }; 815 | 816 | struct PanelInfo 817 | { 818 | size_t StructSize; 819 | HANDLE PluginHandle; 820 | GUID OwnerGuid; 821 | PANELINFOFLAGS Flags; 822 | size_t ItemsNumber; 823 | size_t SelectedItemsNumber; 824 | RECT PanelRect; 825 | size_t CurrentItem; 826 | size_t TopPanelItem; 827 | intptr_t ViewMode; 828 | enum PANELINFOTYPE PanelType; 829 | enum OPENPANELINFO_SORTMODES SortMode; 830 | }; 831 | 832 | 833 | struct PanelRedrawInfo 834 | { 835 | size_t StructSize; 836 | size_t CurrentItem; 837 | size_t TopPanelItem; 838 | }; 839 | 840 | struct CmdLineSelect 841 | { 842 | size_t StructSize; 843 | intptr_t SelStart; 844 | intptr_t SelEnd; 845 | }; 846 | 847 | struct FarPanelDirectory 848 | { 849 | size_t StructSize; 850 | const wchar_t* Name; 851 | const wchar_t* Param; 852 | GUID PluginId; 853 | const wchar_t* File; 854 | }; 855 | 856 | #define PANEL_NONE ((HANDLE)(-1)) 857 | #define PANEL_ACTIVE ((HANDLE)(-1)) 858 | #define PANEL_PASSIVE ((HANDLE)(-2)) 859 | #define PANEL_STOP ((HANDLE)(-1)) 860 | 861 | enum FILE_CONTROL_COMMANDS 862 | { 863 | FCTL_CLOSEPANEL = 0, 864 | FCTL_GETPANELINFO = 1, 865 | FCTL_UPDATEPANEL = 2, 866 | FCTL_REDRAWPANEL = 3, 867 | FCTL_GETCMDLINE = 4, 868 | FCTL_SETCMDLINE = 5, 869 | FCTL_SETSELECTION = 6, 870 | FCTL_SETVIEWMODE = 7, 871 | FCTL_INSERTCMDLINE = 8, 872 | FCTL_SETUSERSCREEN = 9, 873 | FCTL_SETPANELDIRECTORY = 10, 874 | FCTL_SETCMDLINEPOS = 11, 875 | FCTL_GETCMDLINEPOS = 12, 876 | FCTL_SETSORTMODE = 13, 877 | FCTL_SETSORTORDER = 14, 878 | FCTL_SETCMDLINESELECTION = 15, 879 | FCTL_GETCMDLINESELECTION = 16, 880 | FCTL_CHECKPANELSEXIST = 17, 881 | FCTL_SETNUMERICSORT = 18, 882 | FCTL_GETUSERSCREEN = 19, 883 | FCTL_ISACTIVEPANEL = 20, 884 | FCTL_GETPANELITEM = 21, 885 | FCTL_GETSELECTEDPANELITEM = 22, 886 | FCTL_GETCURRENTPANELITEM = 23, 887 | FCTL_GETPANELDIRECTORY = 24, 888 | FCTL_GETCOLUMNTYPES = 25, 889 | FCTL_GETCOLUMNWIDTHS = 26, 890 | FCTL_BEGINSELECTION = 27, 891 | FCTL_ENDSELECTION = 28, 892 | FCTL_CLEARSELECTION = 29, 893 | FCTL_SETDIRECTORIESFIRST = 30, 894 | FCTL_GETPANELFORMAT = 31, 895 | FCTL_GETPANELHOSTFILE = 32, 896 | FCTL_SETCASESENSITIVESORT = 33, 897 | FCTL_GETPANELPREFIX = 34, 898 | FCTL_SETACTIVEPANEL = 35, 899 | }; 900 | 901 | typedef void (WINAPI *FARAPITEXT)( 902 | intptr_t X, 903 | intptr_t Y, 904 | const struct FarColor* Color, 905 | const wchar_t *Str 906 | ); 907 | 908 | typedef HANDLE(WINAPI *FARAPISAVESCREEN)(intptr_t X1, intptr_t Y1, intptr_t X2, intptr_t Y2); 909 | 910 | typedef void (WINAPI *FARAPIRESTORESCREEN)(HANDLE hScreen); 911 | 912 | 913 | typedef intptr_t (WINAPI *FARAPIGETDIRLIST)( 914 | const wchar_t *Dir, 915 | struct PluginPanelItem **pPanelItem, 916 | size_t *pItemsNumber 917 | ); 918 | 919 | typedef intptr_t (WINAPI *FARAPIGETPLUGINDIRLIST)( 920 | const GUID* PluginId, 921 | HANDLE hPanel, 922 | const wchar_t *Dir, 923 | struct PluginPanelItem **pPanelItem, 924 | size_t *pItemsNumber 925 | ); 926 | 927 | typedef void (WINAPI *FARAPIFREEDIRLIST)(struct PluginPanelItem *PanelItem, size_t nItemsNumber); 928 | typedef void (WINAPI *FARAPIFREEPLUGINDIRLIST)(HANDLE hPanel, struct PluginPanelItem *PanelItem, size_t nItemsNumber); 929 | 930 | typedef unsigned __int64 VIEWER_FLAGS; 931 | static const VIEWER_FLAGS 932 | VF_NONMODAL = 0x0000000000000001ULL, 933 | VF_DELETEONCLOSE = 0x0000000000000002ULL, 934 | VF_ENABLE_F6 = 0x0000000000000004ULL, 935 | VF_DISABLEHISTORY = 0x0000000000000008ULL, 936 | VF_IMMEDIATERETURN = 0x0000000000000100ULL, 937 | VF_DELETEONLYFILEONCLOSE = 0x0000000000000200ULL, 938 | VF_NONE = 0; 939 | 940 | typedef intptr_t (WINAPI *FARAPIVIEWER)( 941 | const wchar_t *FileName, 942 | const wchar_t *Title, 943 | intptr_t X1, 944 | intptr_t Y1, 945 | intptr_t X2, 946 | intptr_t Y2, 947 | VIEWER_FLAGS Flags, 948 | uintptr_t CodePage 949 | ); 950 | 951 | typedef unsigned __int64 EDITOR_FLAGS; 952 | static const EDITOR_FLAGS 953 | EF_NONMODAL = 0x0000000000000001ULL, 954 | EF_CREATENEW = 0x0000000000000002ULL, 955 | EF_ENABLE_F6 = 0x0000000000000004ULL, 956 | EF_DISABLEHISTORY = 0x0000000000000008ULL, 957 | EF_DELETEONCLOSE = 0x0000000000000010ULL, 958 | EF_IMMEDIATERETURN = 0x0000000000000100ULL, 959 | EF_DELETEONLYFILEONCLOSE = 0x0000000000000200ULL, 960 | EF_LOCKED = 0x0000000000000400ULL, 961 | EF_DISABLESAVEPOS = 0x0000000000000800ULL, 962 | EF_OPENMODE_MASK = 0x00000000F0000000ULL, 963 | EF_OPENMODE_QUERY = 0x0000000000000000ULL, 964 | EF_OPENMODE_NEWIFOPEN = 0x0000000010000000ULL, 965 | EF_OPENMODE_USEEXISTING = 0x0000000020000000ULL, 966 | EF_OPENMODE_BREAKIFOPEN = 0x0000000030000000ULL, 967 | EF_OPENMODE_RELOADIFOPEN = 0x0000000040000000ULL, 968 | EN_NONE = 0; 969 | 970 | enum EDITOR_EXITCODE 971 | { 972 | EEC_OPEN_ERROR = 0, 973 | EEC_MODIFIED = 1, 974 | EEC_NOT_MODIFIED = 2, 975 | EEC_LOADING_INTERRUPTED = 3, 976 | }; 977 | 978 | typedef intptr_t (WINAPI *FARAPIEDITOR)( 979 | const wchar_t *FileName, 980 | const wchar_t *Title, 981 | intptr_t X1, 982 | intptr_t Y1, 983 | intptr_t X2, 984 | intptr_t Y2, 985 | EDITOR_FLAGS Flags, 986 | intptr_t StartLine, 987 | intptr_t StartChar, 988 | uintptr_t CodePage 989 | ); 990 | 991 | typedef const wchar_t*(WINAPI *FARAPIGETMSG)( 992 | const GUID* PluginId, 993 | intptr_t MsgId 994 | ); 995 | 996 | typedef unsigned __int64 FARHELPFLAGS; 997 | static const FARHELPFLAGS 998 | FHELP_NOSHOWERROR = 0x0000000080000000ULL, 999 | FHELP_SELFHELP = 0x0000000000000000ULL, 1000 | FHELP_FARHELP = 0x0000000000000001ULL, 1001 | FHELP_CUSTOMFILE = 0x0000000000000002ULL, 1002 | FHELP_CUSTOMPATH = 0x0000000000000004ULL, 1003 | FHELP_GUID = 0x0000000000000008ULL, 1004 | FHELP_USECONTENTS = 0x0000000040000000ULL, 1005 | FHELP_NONE = 0; 1006 | 1007 | typedef BOOL (WINAPI *FARAPISHOWHELP)( 1008 | const wchar_t *ModuleName, 1009 | const wchar_t *Topic, 1010 | FARHELPFLAGS Flags 1011 | ); 1012 | 1013 | enum ADVANCED_CONTROL_COMMANDS 1014 | { 1015 | ACTL_GETFARMANAGERVERSION = 0, 1016 | ACTL_WAITKEY = 2, 1017 | ACTL_GETCOLOR = 3, 1018 | ACTL_GETARRAYCOLOR = 4, 1019 | ACTL_GETWINDOWINFO = 6, 1020 | ACTL_GETWINDOWCOUNT = 7, 1021 | ACTL_SETCURRENTWINDOW = 8, 1022 | ACTL_COMMIT = 9, 1023 | ACTL_GETFARHWND = 10, 1024 | ACTL_SETARRAYCOLOR = 16, 1025 | ACTL_REDRAWALL = 19, 1026 | ACTL_SYNCHRO = 20, 1027 | ACTL_SETPROGRESSSTATE = 21, 1028 | ACTL_SETPROGRESSVALUE = 22, 1029 | ACTL_QUIT = 23, 1030 | ACTL_GETFARRECT = 24, 1031 | ACTL_GETCURSORPOS = 25, 1032 | ACTL_SETCURSORPOS = 26, 1033 | ACTL_PROGRESSNOTIFY = 27, 1034 | ACTL_GETWINDOWTYPE = 28, 1035 | 1036 | 1037 | }; 1038 | 1039 | 1040 | 1041 | 1042 | enum FAR_MACRO_CONTROL_COMMANDS 1043 | { 1044 | MCTL_LOADALL = 0, 1045 | MCTL_SAVEALL = 1, 1046 | MCTL_SENDSTRING = 2, 1047 | MCTL_GETSTATE = 5, 1048 | MCTL_GETAREA = 6, 1049 | MCTL_ADDMACRO = 7, 1050 | MCTL_DELMACRO = 8, 1051 | MCTL_GETLASTERROR = 9, 1052 | MCTL_EXECSTRING = 10, 1053 | }; 1054 | 1055 | typedef unsigned __int64 FARKEYMACROFLAGS; 1056 | static const FARKEYMACROFLAGS 1057 | KMFLAGS_SILENTCHECK = 0x0000000000000001, 1058 | KMFLAGS_NOSENDKEYSTOPLUGINS = 0x0000000000000002, 1059 | KMFLAGS_ENABLEOUTPUT = 0x0000000000000004, 1060 | KMFLAGS_LANGMASK = 0x0000000000000070, // 3 bits reserved for 8 languages 1061 | KMFLAGS_LUA = 0x0000000000000000, 1062 | KMFLAGS_MOONSCRIPT = 0x0000000000000010, 1063 | KMFLAGS_NONE = 0; 1064 | 1065 | enum FARMACROSENDSTRINGCOMMAND 1066 | { 1067 | MSSC_POST =0, 1068 | MSSC_CHECK =2, 1069 | }; 1070 | 1071 | enum FARMACROAREA 1072 | { 1073 | MACROAREA_OTHER = 0, // Mode of copying text from the screen; vertical menus 1074 | MACROAREA_SHELL = 1, // File panels 1075 | MACROAREA_VIEWER = 2, // Internal viewer program 1076 | MACROAREA_EDITOR = 3, // Editor 1077 | MACROAREA_DIALOG = 4, // Dialogs 1078 | MACROAREA_SEARCH = 5, // Quick search in panels 1079 | MACROAREA_DISKS = 6, // Menu of disk selection 1080 | MACROAREA_MAINMENU = 7, // Main menu 1081 | MACROAREA_MENU = 8, // Other menus 1082 | MACROAREA_HELP = 9, // Help system 1083 | MACROAREA_INFOPANEL = 10, // Info panel 1084 | MACROAREA_QVIEWPANEL = 11, // Quick view panel 1085 | MACROAREA_TREEPANEL = 12, // Folders tree panel 1086 | MACROAREA_FINDFOLDER = 13, // Find folder 1087 | MACROAREA_USERMENU = 14, // User menu 1088 | MACROAREA_SHELLAUTOCOMPLETION = 15, // Autocompletion list in command line 1089 | MACROAREA_DIALOGAUTOCOMPLETION = 16, // Autocompletion list in dialogs 1090 | 1091 | MACROAREA_COMMON = 255, 1092 | }; 1093 | 1094 | enum FARMACROSTATE 1095 | { 1096 | MACROSTATE_NOMACRO = 0, 1097 | MACROSTATE_EXECUTING = 1, 1098 | MACROSTATE_EXECUTING_COMMON = 2, 1099 | MACROSTATE_RECORDING = 3, 1100 | MACROSTATE_RECORDING_COMMON = 4, 1101 | }; 1102 | 1103 | enum FARMACROPARSEERRORCODE 1104 | { 1105 | MPEC_SUCCESS = 0, 1106 | MPEC_ERROR = 1, 1107 | }; 1108 | 1109 | struct MacroParseResult 1110 | { 1111 | size_t StructSize; 1112 | DWORD ErrCode; 1113 | COORD ErrPos; 1114 | const wchar_t *ErrSrc; 1115 | }; 1116 | 1117 | 1118 | struct MacroSendMacroText 1119 | { 1120 | size_t StructSize; 1121 | FARKEYMACROFLAGS Flags; 1122 | INPUT_RECORD AKey; 1123 | const wchar_t *SequenceText; 1124 | }; 1125 | 1126 | typedef unsigned __int64 FARADDKEYMACROFLAGS; 1127 | static const FARADDKEYMACROFLAGS 1128 | AKMFLAGS_NONE = 0; 1129 | 1130 | typedef intptr_t (WINAPI *FARMACROCALLBACK)(void* Id,FARADDKEYMACROFLAGS Flags); 1131 | 1132 | struct MacroAddMacro 1133 | { 1134 | size_t StructSize; 1135 | void* Id; 1136 | const wchar_t *SequenceText; 1137 | const wchar_t *Description; 1138 | FARKEYMACROFLAGS Flags; 1139 | INPUT_RECORD AKey; 1140 | enum FARMACROAREA Area; 1141 | FARMACROCALLBACK Callback; 1142 | }; 1143 | 1144 | enum FARMACROVARTYPE 1145 | { 1146 | FMVT_UNKNOWN = 0, 1147 | FMVT_INTEGER = 1, 1148 | FMVT_STRING = 2, 1149 | FMVT_DOUBLE = 3, 1150 | FMVT_BOOLEAN = 4, 1151 | FMVT_BINARY = 5, 1152 | FMVT_POINTER = 6, 1153 | FMVT_NIL = 7, 1154 | FMVT_ARRAY = 8, 1155 | FMVT_PANEL = 9, 1156 | }; 1157 | 1158 | struct FarMacroValue 1159 | { 1160 | enum FARMACROVARTYPE Type; 1161 | union 1162 | { 1163 | __int64 Integer; 1164 | __int64 Boolean; 1165 | double Double; 1166 | const wchar_t *String; 1167 | void *Pointer; 1168 | struct 1169 | { 1170 | void *Data; 1171 | size_t Size; 1172 | } Binary; 1173 | struct 1174 | { 1175 | struct FarMacroValue *Values; 1176 | size_t Count; 1177 | } Array; 1178 | } 1179 | #ifndef __cplusplus 1180 | Value 1181 | #endif 1182 | ; 1183 | #ifdef __cplusplus 1184 | FarMacroValue() { Type=FMVT_NIL; } 1185 | FarMacroValue(int v) { Type=FMVT_INTEGER; Integer=v; } 1186 | FarMacroValue(unsigned int v) { Type=FMVT_INTEGER; Integer=v; } 1187 | FarMacroValue(__int64 v) { Type=FMVT_INTEGER; Integer=v; } 1188 | FarMacroValue(unsigned __int64 v) { Type=FMVT_INTEGER; Integer=v; } 1189 | FarMacroValue(bool v) { Type=FMVT_BOOLEAN; Boolean=v; } 1190 | FarMacroValue(double v) { Type=FMVT_DOUBLE; Double=v; } 1191 | FarMacroValue(const wchar_t* v) { Type=FMVT_STRING; String=v; } 1192 | FarMacroValue(void* v) { Type=FMVT_POINTER; Pointer=v; } 1193 | FarMacroValue(const GUID& v) { Type=FMVT_BINARY; Binary.Data=&const_cast(v); Binary.Size=sizeof(GUID); } 1194 | FarMacroValue(FarMacroValue* arr,size_t count) { Type=FMVT_ARRAY; Array.Values=arr; Array.Count=count; } 1195 | #endif 1196 | }; 1197 | 1198 | struct FarMacroCall 1199 | { 1200 | size_t StructSize; 1201 | size_t Count; 1202 | struct FarMacroValue *Values; 1203 | void (WINAPI *Callback)(void *CallbackData, struct FarMacroValue *Values, size_t Count); 1204 | void *CallbackData; 1205 | }; 1206 | 1207 | struct FarGetValue 1208 | { 1209 | size_t StructSize; 1210 | intptr_t Type; 1211 | struct FarMacroValue Value; 1212 | }; 1213 | 1214 | struct MacroExecuteString 1215 | { 1216 | size_t StructSize; 1217 | FARKEYMACROFLAGS Flags; 1218 | const wchar_t *SequenceText; 1219 | size_t InCount; 1220 | struct FarMacroValue *InValues; 1221 | size_t OutCount; 1222 | const struct FarMacroValue *OutValues; 1223 | }; 1224 | 1225 | struct FarMacroLoad 1226 | { 1227 | size_t StructSize; 1228 | const wchar_t *Path; 1229 | unsigned __int64 Flags; 1230 | }; 1231 | 1232 | typedef unsigned __int64 FARSETCOLORFLAGS; 1233 | static const FARSETCOLORFLAGS 1234 | FSETCLR_REDRAW = 0x0000000000000001ULL, 1235 | FSETCLR_NONE = 0; 1236 | 1237 | struct FarSetColors 1238 | { 1239 | size_t StructSize; 1240 | FARSETCOLORFLAGS Flags; 1241 | size_t StartIndex; 1242 | size_t ColorsCount; 1243 | struct FarColor* Colors; 1244 | }; 1245 | 1246 | enum WINDOWINFO_TYPE 1247 | { 1248 | WTYPE_DESKTOP = 0, 1249 | WTYPE_PANELS = 1, 1250 | WTYPE_VIEWER = 2, 1251 | WTYPE_EDITOR = 3, 1252 | WTYPE_DIALOG = 4, 1253 | WTYPE_VMENU = 5, 1254 | WTYPE_HELP = 6, 1255 | WTYPE_COMBOBOX = 7, 1256 | }; 1257 | 1258 | typedef unsigned __int64 WINDOWINFO_FLAGS; 1259 | static const WINDOWINFO_FLAGS 1260 | WIF_MODIFIED = 0x0000000000000001ULL, 1261 | WIF_CURRENT = 0x0000000000000002ULL, 1262 | WIF_MODAL = 0x0000000000000004ULL, 1263 | WIF_NONE = 0; 1264 | 1265 | struct WindowInfo 1266 | { 1267 | size_t StructSize; 1268 | intptr_t Id; 1269 | wchar_t *TypeName; 1270 | wchar_t *Name; 1271 | intptr_t TypeNameSize; 1272 | intptr_t NameSize; 1273 | intptr_t Pos; 1274 | enum WINDOWINFO_TYPE Type; 1275 | WINDOWINFO_FLAGS Flags; 1276 | }; 1277 | 1278 | struct WindowType 1279 | { 1280 | size_t StructSize; 1281 | enum WINDOWINFO_TYPE Type; 1282 | }; 1283 | 1284 | enum TASKBARPROGRESSTATE 1285 | { 1286 | TBPS_NOPROGRESS =0x0, 1287 | TBPS_INDETERMINATE=0x1, 1288 | TBPS_NORMAL =0x2, 1289 | TBPS_ERROR =0x4, 1290 | TBPS_PAUSED =0x8, 1291 | }; 1292 | 1293 | struct ProgressValue 1294 | { 1295 | size_t StructSize; 1296 | unsigned __int64 Completed; 1297 | unsigned __int64 Total; 1298 | }; 1299 | 1300 | enum VIEWER_CONTROL_COMMANDS 1301 | { 1302 | VCTL_GETINFO = 0, 1303 | VCTL_QUIT = 1, 1304 | VCTL_REDRAW = 2, 1305 | VCTL_SETKEYBAR = 3, 1306 | VCTL_SETPOSITION = 4, 1307 | VCTL_SELECT = 5, 1308 | VCTL_SETMODE = 6, 1309 | VCTL_GETFILENAME = 7, 1310 | }; 1311 | 1312 | typedef unsigned __int64 VIEWER_OPTIONS; 1313 | static const VIEWER_OPTIONS 1314 | VOPT_SAVEFILEPOSITION = 0x0000000000000001ULL, 1315 | VOPT_AUTODETECTCODEPAGE = 0x0000000000000002ULL, 1316 | VOPT_SHOWTITLEBAR = 0x0000000000000004ULL, 1317 | VOPT_SHOWKEYBAR = 0x0000000000000008ULL, 1318 | VOPT_SHOWSCROLLBAR = 0x0000000000000010ULL, 1319 | VOPT_QUICKVIEW = 0x0000000000000020ULL, 1320 | VOPT_NONE = 0; 1321 | 1322 | enum VIEWER_SETMODE_TYPES 1323 | { 1324 | VSMT_VIEWMODE = 0, 1325 | VSMT_WRAP = 1, 1326 | VSMT_WORDWRAP = 2, 1327 | }; 1328 | 1329 | typedef unsigned __int64 VIEWER_SETMODEFLAGS_TYPES; 1330 | static const VIEWER_SETMODEFLAGS_TYPES 1331 | VSMFL_REDRAW = 0x0000000000000001ULL, 1332 | VSMFL_NONE = 0; 1333 | 1334 | struct ViewerSetMode 1335 | { 1336 | size_t StructSize; 1337 | enum VIEWER_SETMODE_TYPES Type; 1338 | union 1339 | { 1340 | intptr_t iParam; 1341 | wchar_t *wszParam; 1342 | } 1343 | #ifndef __cplusplus 1344 | Param 1345 | #endif 1346 | ; 1347 | VIEWER_SETMODEFLAGS_TYPES Flags; 1348 | }; 1349 | 1350 | struct ViewerSelect 1351 | { 1352 | size_t StructSize; 1353 | __int64 BlockStartPos; 1354 | __int64 BlockLen; 1355 | }; 1356 | 1357 | typedef unsigned __int64 VIEWER_SETPOS_FLAGS; 1358 | static const VIEWER_SETPOS_FLAGS 1359 | VSP_NOREDRAW = 0x0000000000000001ULL, 1360 | VSP_PERCENT = 0x0000000000000002ULL, 1361 | VSP_RELATIVE = 0x0000000000000004ULL, 1362 | VSP_NORETNEWPOS = 0x0000000000000008ULL, 1363 | VSP_NONE = 0; 1364 | 1365 | struct ViewerSetPosition 1366 | { 1367 | size_t StructSize; 1368 | VIEWER_SETPOS_FLAGS Flags; 1369 | __int64 StartPos; 1370 | __int64 LeftPos; 1371 | }; 1372 | 1373 | typedef unsigned __int64 VIEWER_MODE_FLAGS; 1374 | static const VIEWER_MODE_FLAGS 1375 | VMF_WRAP = 0x0000000000000001ULL, 1376 | VMF_WORDWRAP = 0x0000000000000002ULL, 1377 | VMF_NONE = 0; 1378 | 1379 | enum VIEWER_MODE_TYPE 1380 | { 1381 | VMT_TEXT =0, 1382 | VMT_HEX =1, 1383 | VMT_DUMP =2, 1384 | }; 1385 | 1386 | struct ViewerMode 1387 | { 1388 | uintptr_t CodePage; 1389 | VIEWER_MODE_FLAGS Flags; 1390 | enum VIEWER_MODE_TYPE ViewMode; 1391 | }; 1392 | 1393 | struct ViewerInfo 1394 | { 1395 | size_t StructSize; 1396 | intptr_t ViewerID; 1397 | intptr_t TabSize; 1398 | struct ViewerMode CurMode; 1399 | __int64 FileSize; 1400 | __int64 FilePos; 1401 | __int64 LeftPos; 1402 | VIEWER_OPTIONS Options; 1403 | intptr_t WindowSizeX; 1404 | intptr_t WindowSizeY; 1405 | }; 1406 | 1407 | enum VIEWER_EVENTS 1408 | { 1409 | VE_READ =0, 1410 | VE_CLOSE =1, 1411 | 1412 | VE_GOTFOCUS =6, 1413 | VE_KILLFOCUS =7, 1414 | }; 1415 | 1416 | 1417 | enum EDITOR_EVENTS 1418 | { 1419 | EE_READ =0, 1420 | EE_SAVE =1, 1421 | EE_REDRAW =2, 1422 | EE_CLOSE =3, 1423 | 1424 | EE_GOTFOCUS =6, 1425 | EE_KILLFOCUS =7, 1426 | EE_CHANGE =8, 1427 | }; 1428 | 1429 | enum DIALOG_EVENTS 1430 | { 1431 | DE_DLGPROCINIT =0, 1432 | DE_DEFDLGPROCINIT =1, 1433 | DE_DLGPROCEND =2, 1434 | }; 1435 | 1436 | enum SYNCHRO_EVENTS 1437 | { 1438 | SE_COMMONSYNCHRO =0, 1439 | }; 1440 | 1441 | #define EEREDRAW_ALL (void*)0 1442 | 1443 | #define CURRENT_EDITOR -1 1444 | 1445 | enum EDITOR_CONTROL_COMMANDS 1446 | { 1447 | ECTL_GETSTRING = 0, 1448 | ECTL_SETSTRING = 1, 1449 | ECTL_INSERTSTRING = 2, 1450 | ECTL_DELETESTRING = 3, 1451 | ECTL_DELETECHAR = 4, 1452 | ECTL_INSERTTEXT = 5, 1453 | ECTL_GETINFO = 6, 1454 | ECTL_SETPOSITION = 7, 1455 | ECTL_SELECT = 8, 1456 | ECTL_REDRAW = 9, 1457 | ECTL_TABTOREAL = 10, 1458 | ECTL_REALTOTAB = 11, 1459 | ECTL_EXPANDTABS = 12, 1460 | ECTL_SETTITLE = 13, 1461 | ECTL_READINPUT = 14, 1462 | ECTL_PROCESSINPUT = 15, 1463 | ECTL_ADDCOLOR = 16, 1464 | ECTL_GETCOLOR = 17, 1465 | ECTL_SAVEFILE = 18, 1466 | ECTL_QUIT = 19, 1467 | ECTL_SETKEYBAR = 20, 1468 | 1469 | ECTL_SETPARAM = 22, 1470 | ECTL_GETBOOKMARKS = 23, 1471 | ECTL_DELETEBLOCK = 25, 1472 | ECTL_ADDSESSIONBOOKMARK = 26, 1473 | ECTL_PREVSESSIONBOOKMARK = 27, 1474 | ECTL_NEXTSESSIONBOOKMARK = 28, 1475 | ECTL_CLEARSESSIONBOOKMARKS = 29, 1476 | ECTL_DELETESESSIONBOOKMARK = 30, 1477 | ECTL_GETSESSIONBOOKMARKS = 31, 1478 | ECTL_UNDOREDO = 32, 1479 | ECTL_GETFILENAME = 33, 1480 | ECTL_DELCOLOR = 34, 1481 | ECTL_SUBSCRIBECHANGEEVENT = 36, 1482 | ECTL_UNSUBSCRIBECHANGEEVENT = 37, 1483 | ECTL_GETTITLE = 38, 1484 | }; 1485 | 1486 | enum EDITOR_SETPARAMETER_TYPES 1487 | { 1488 | ESPT_TABSIZE = 0, 1489 | ESPT_EXPANDTABS = 1, 1490 | ESPT_AUTOINDENT = 2, 1491 | ESPT_CURSORBEYONDEOL = 3, 1492 | ESPT_CHARCODEBASE = 4, 1493 | ESPT_CODEPAGE = 5, 1494 | ESPT_SAVEFILEPOSITION = 6, 1495 | ESPT_LOCKMODE = 7, 1496 | ESPT_SETWORDDIV = 8, 1497 | ESPT_GETWORDDIV = 9, 1498 | ESPT_SHOWWHITESPACE = 10, 1499 | ESPT_SETBOM = 11, 1500 | }; 1501 | 1502 | 1503 | 1504 | struct EditorSetParameter 1505 | { 1506 | size_t StructSize; 1507 | enum EDITOR_SETPARAMETER_TYPES Type; 1508 | union 1509 | { 1510 | intptr_t iParam; 1511 | wchar_t *wszParam; 1512 | intptr_t Reserved; 1513 | } 1514 | #ifndef __cplusplus 1515 | Param 1516 | #endif 1517 | ; 1518 | unsigned __int64 Flags; 1519 | size_t Size; 1520 | }; 1521 | 1522 | 1523 | enum EDITOR_UNDOREDO_COMMANDS 1524 | { 1525 | EUR_BEGIN = 0, 1526 | EUR_END = 1, 1527 | EUR_UNDO = 2, 1528 | EUR_REDO = 3, 1529 | }; 1530 | 1531 | 1532 | struct EditorUndoRedo 1533 | { 1534 | size_t StructSize; 1535 | enum EDITOR_UNDOREDO_COMMANDS Command; 1536 | }; 1537 | 1538 | struct EditorGetString 1539 | { 1540 | size_t StructSize; 1541 | intptr_t StringNumber; 1542 | intptr_t StringLength; 1543 | const wchar_t *StringText; 1544 | const wchar_t *StringEOL; 1545 | intptr_t SelStart; 1546 | intptr_t SelEnd; 1547 | }; 1548 | 1549 | 1550 | struct EditorSetString 1551 | { 1552 | size_t StructSize; 1553 | intptr_t StringNumber; 1554 | intptr_t StringLength; 1555 | const wchar_t *StringText; 1556 | const wchar_t *StringEOL; 1557 | }; 1558 | 1559 | enum EXPAND_TABS 1560 | { 1561 | EXPAND_NOTABS = 0, 1562 | EXPAND_ALLTABS = 1, 1563 | EXPAND_NEWTABS = 2, 1564 | }; 1565 | 1566 | 1567 | enum EDITOR_OPTIONS 1568 | { 1569 | EOPT_EXPANDALLTABS = 0x00000001, 1570 | EOPT_PERSISTENTBLOCKS = 0x00000002, 1571 | EOPT_DELREMOVESBLOCKS = 0x00000004, 1572 | EOPT_AUTOINDENT = 0x00000008, 1573 | EOPT_SAVEFILEPOSITION = 0x00000010, 1574 | EOPT_AUTODETECTCODEPAGE= 0x00000020, 1575 | EOPT_CURSORBEYONDEOL = 0x00000040, 1576 | EOPT_EXPANDONLYNEWTABS = 0x00000080, 1577 | EOPT_SHOWWHITESPACE = 0x00000100, 1578 | EOPT_BOM = 0x00000200, 1579 | EOPT_SHOWLINEBREAK = 0x00000400, 1580 | EOPT_SHOWTITLEBAR = 0x00000800, 1581 | EOPT_SHOWKEYBAR = 0x00001000, 1582 | EOPT_SHOWSCROLLBAR = 0x00002000, 1583 | }; 1584 | 1585 | 1586 | enum EDITOR_BLOCK_TYPES 1587 | { 1588 | BTYPE_NONE = 0, 1589 | BTYPE_STREAM = 1, 1590 | BTYPE_COLUMN = 2, 1591 | }; 1592 | 1593 | enum EDITOR_CURRENTSTATE 1594 | { 1595 | ECSTATE_MODIFIED = 0x00000001, 1596 | ECSTATE_SAVED = 0x00000002, 1597 | ECSTATE_LOCKED = 0x00000004, 1598 | }; 1599 | 1600 | 1601 | struct EditorInfo 1602 | { 1603 | size_t StructSize; 1604 | intptr_t EditorID; 1605 | intptr_t WindowSizeX; 1606 | intptr_t WindowSizeY; 1607 | intptr_t TotalLines; 1608 | intptr_t CurLine; 1609 | intptr_t CurPos; 1610 | intptr_t CurTabPos; 1611 | intptr_t TopScreenLine; 1612 | intptr_t LeftPos; 1613 | intptr_t Overtype; 1614 | intptr_t BlockType; 1615 | intptr_t BlockStartLine; 1616 | uintptr_t Options; 1617 | intptr_t TabSize; 1618 | size_t BookmarkCount; 1619 | size_t SessionBookmarkCount; 1620 | uintptr_t CurState; 1621 | uintptr_t CodePage; 1622 | }; 1623 | 1624 | struct EditorBookmarks 1625 | { 1626 | size_t StructSize; 1627 | size_t Size; 1628 | size_t Count; 1629 | intptr_t *Line; 1630 | intptr_t *Cursor; 1631 | intptr_t *ScreenLine; 1632 | intptr_t *LeftPos; 1633 | }; 1634 | 1635 | struct EditorSetPosition 1636 | { 1637 | size_t StructSize; 1638 | intptr_t CurLine; 1639 | intptr_t CurPos; 1640 | intptr_t CurTabPos; 1641 | intptr_t TopScreenLine; 1642 | intptr_t LeftPos; 1643 | intptr_t Overtype; 1644 | }; 1645 | 1646 | 1647 | struct EditorSelect 1648 | { 1649 | size_t StructSize; 1650 | intptr_t BlockType; 1651 | intptr_t BlockStartLine; 1652 | intptr_t BlockStartPos; 1653 | intptr_t BlockWidth; 1654 | intptr_t BlockHeight; 1655 | }; 1656 | 1657 | 1658 | struct EditorConvertPos 1659 | { 1660 | size_t StructSize; 1661 | intptr_t StringNumber; 1662 | intptr_t SrcPos; 1663 | intptr_t DestPos; 1664 | }; 1665 | 1666 | typedef unsigned __int64 EDITORCOLORFLAGS; 1667 | static const EDITORCOLORFLAGS 1668 | ECF_TABMARKFIRST = 0x0000000000000001ULL, 1669 | ECF_TABMARKCURRENT = 0x0000000000000002ULL, 1670 | ECF_AUTODELETE = 0x0000000000000004ULL, 1671 | ECF_NONE = 0; 1672 | 1673 | struct EditorColor 1674 | { 1675 | size_t StructSize; 1676 | intptr_t StringNumber; 1677 | intptr_t ColorItem; 1678 | intptr_t StartPos; 1679 | intptr_t EndPos; 1680 | uintptr_t Priority; 1681 | EDITORCOLORFLAGS Flags; 1682 | struct FarColor Color; 1683 | GUID Owner; 1684 | }; 1685 | 1686 | struct EditorDeleteColor 1687 | { 1688 | size_t StructSize; 1689 | GUID Owner; 1690 | intptr_t StringNumber; 1691 | intptr_t StartPos; 1692 | }; 1693 | 1694 | #define EDITOR_COLOR_NORMAL_PRIORITY 0x80000000U 1695 | 1696 | struct EditorSaveFile 1697 | { 1698 | size_t StructSize; 1699 | const wchar_t *FileName; 1700 | const wchar_t *FileEOL; 1701 | uintptr_t CodePage; 1702 | }; 1703 | 1704 | enum EDITOR_CHANGETYPE 1705 | { 1706 | ECTYPE_CHANGED = 0, 1707 | ECTYPE_ADDED = 1, 1708 | ECTYPE_DELETED = 2, 1709 | }; 1710 | 1711 | struct EditorChange 1712 | { 1713 | size_t StructSize; 1714 | enum EDITOR_CHANGETYPE Type; 1715 | intptr_t StringNumber; 1716 | }; 1717 | 1718 | struct EditorSubscribeChangeEvent 1719 | { 1720 | size_t StructSize; 1721 | GUID PluginId; 1722 | }; 1723 | 1724 | typedef unsigned __int64 INPUTBOXFLAGS; 1725 | static const INPUTBOXFLAGS 1726 | FIB_ENABLEEMPTY = 0x0000000000000001ULL, 1727 | FIB_PASSWORD = 0x0000000000000002ULL, 1728 | FIB_EXPANDENV = 0x0000000000000004ULL, 1729 | FIB_NOUSELASTHISTORY = 0x0000000000000008ULL, 1730 | FIB_BUTTONS = 0x0000000000000010ULL, 1731 | FIB_NOAMPERSAND = 0x0000000000000020ULL, 1732 | FIB_EDITPATH = 0x0000000000000040ULL, 1733 | FIB_EDITPATHEXEC = 0x0000000000000080ULL, 1734 | FIB_NONE = 0; 1735 | 1736 | typedef intptr_t (WINAPI *FARAPIINPUTBOX)( 1737 | const GUID* PluginId, 1738 | const GUID* Id, 1739 | const wchar_t *Title, 1740 | const wchar_t *SubTitle, 1741 | const wchar_t *HistoryName, 1742 | const wchar_t *SrcText, 1743 | wchar_t *DestText, 1744 | size_t DestSize, 1745 | const wchar_t *HelpTopic, 1746 | INPUTBOXFLAGS Flags 1747 | ); 1748 | 1749 | enum FAR_PLUGINS_CONTROL_COMMANDS 1750 | { 1751 | PCTL_LOADPLUGIN = 0, 1752 | PCTL_UNLOADPLUGIN = 1, 1753 | PCTL_FORCEDLOADPLUGIN = 2, 1754 | PCTL_FINDPLUGIN = 3, 1755 | PCTL_GETPLUGININFORMATION = 4, 1756 | PCTL_GETPLUGINS = 5, 1757 | }; 1758 | 1759 | enum FAR_PLUGIN_LOAD_TYPE 1760 | { 1761 | PLT_PATH = 0, 1762 | }; 1763 | 1764 | enum FAR_PLUGIN_FIND_TYPE 1765 | { 1766 | PFM_GUID = 0, 1767 | PFM_MODULENAME = 1, 1768 | }; 1769 | 1770 | typedef unsigned __int64 FAR_PLUGIN_FLAGS; 1771 | static const FAR_PLUGIN_FLAGS 1772 | FPF_LOADED = 0x0000000000000001ULL, 1773 | FPF_ANSI = 0x1000000000000000ULL, 1774 | FPF_NONE = 0; 1775 | 1776 | enum FAR_FILE_FILTER_CONTROL_COMMANDS 1777 | { 1778 | FFCTL_CREATEFILEFILTER = 0, 1779 | FFCTL_FREEFILEFILTER = 1, 1780 | FFCTL_OPENFILTERSMENU = 2, 1781 | FFCTL_STARTINGTOFILTER = 3, 1782 | FFCTL_ISFILEINFILTER = 4, 1783 | }; 1784 | 1785 | enum FAR_FILE_FILTER_TYPE 1786 | { 1787 | FFT_PANEL = 0, 1788 | FFT_FINDFILE = 1, 1789 | FFT_COPY = 2, 1790 | FFT_SELECT = 3, 1791 | FFT_CUSTOM = 4, 1792 | }; 1793 | 1794 | enum FAR_REGEXP_CONTROL_COMMANDS 1795 | { 1796 | RECTL_CREATE = 0, 1797 | RECTL_FREE = 1, 1798 | RECTL_COMPILE = 2, 1799 | RECTL_OPTIMIZE = 3, 1800 | RECTL_MATCHEX = 4, 1801 | RECTL_SEARCHEX = 5, 1802 | RECTL_BRACKETSCOUNT = 6, 1803 | }; 1804 | 1805 | struct RegExpMatch 1806 | { 1807 | intptr_t start,end; 1808 | }; 1809 | 1810 | struct RegExpSearch 1811 | { 1812 | const wchar_t* Text; 1813 | intptr_t Position; 1814 | intptr_t Length; 1815 | struct RegExpMatch* Match; 1816 | intptr_t Count; 1817 | void* Reserved; 1818 | }; 1819 | 1820 | enum FAR_SETTINGS_CONTROL_COMMANDS 1821 | { 1822 | SCTL_CREATE = 0, 1823 | SCTL_FREE = 1, 1824 | SCTL_SET = 2, 1825 | SCTL_GET = 3, 1826 | SCTL_ENUM = 4, 1827 | SCTL_DELETE = 5, 1828 | SCTL_CREATESUBKEY = 6, 1829 | SCTL_OPENSUBKEY = 7, 1830 | }; 1831 | 1832 | enum FARSETTINGSTYPES 1833 | { 1834 | FST_UNKNOWN = 0, 1835 | FST_SUBKEY = 1, 1836 | FST_QWORD = 2, 1837 | FST_STRING = 3, 1838 | FST_DATA = 4, 1839 | }; 1840 | 1841 | enum FARSETTINGS_SUBFOLDERS 1842 | { 1843 | FSSF_ROOT = 0, 1844 | FSSF_HISTORY_CMD = 1, 1845 | FSSF_HISTORY_FOLDER = 2, 1846 | FSSF_HISTORY_VIEW = 3, 1847 | FSSF_HISTORY_EDIT = 4, 1848 | FSSF_HISTORY_EXTERNAL = 5, 1849 | FSSF_FOLDERSHORTCUT_0 = 6, 1850 | FSSF_FOLDERSHORTCUT_1 = 7, 1851 | FSSF_FOLDERSHORTCUT_2 = 8, 1852 | FSSF_FOLDERSHORTCUT_3 = 9, 1853 | FSSF_FOLDERSHORTCUT_4 = 10, 1854 | FSSF_FOLDERSHORTCUT_5 = 11, 1855 | FSSF_FOLDERSHORTCUT_6 = 12, 1856 | FSSF_FOLDERSHORTCUT_7 = 13, 1857 | FSSF_FOLDERSHORTCUT_8 = 14, 1858 | FSSF_FOLDERSHORTCUT_9 = 15, 1859 | FSSF_CONFIRMATIONS = 16, 1860 | FSSF_SYSTEM = 17, 1861 | FSSF_PANEL = 18, 1862 | FSSF_EDITOR = 19, 1863 | FSSF_SCREEN = 20, 1864 | FSSF_DIALOG = 21, 1865 | FSSF_INTERFACE = 22, 1866 | FSSF_PANELLAYOUT = 23, 1867 | }; 1868 | 1869 | enum FAR_PLUGIN_SETTINGS_LOCATION 1870 | { 1871 | PSL_ROAMING = 0, 1872 | PSL_LOCAL = 1, 1873 | }; 1874 | 1875 | struct FarSettingsCreate 1876 | { 1877 | size_t StructSize; 1878 | GUID Guid; 1879 | HANDLE Handle; 1880 | }; 1881 | 1882 | struct FarSettingsItem 1883 | { 1884 | size_t StructSize; 1885 | size_t Root; 1886 | const wchar_t* Name; 1887 | enum FARSETTINGSTYPES Type; 1888 | union 1889 | { 1890 | unsigned __int64 Number; 1891 | const wchar_t* String; 1892 | struct 1893 | { 1894 | size_t Size; 1895 | const void* Data; 1896 | } Data; 1897 | } 1898 | #ifndef __cplusplus 1899 | Value 1900 | #endif 1901 | ; 1902 | }; 1903 | 1904 | struct FarSettingsName 1905 | { 1906 | const wchar_t* Name; 1907 | enum FARSETTINGSTYPES Type; 1908 | }; 1909 | 1910 | struct FarSettingsHistory 1911 | { 1912 | const wchar_t* Name; 1913 | const wchar_t* Param; 1914 | GUID PluginId; 1915 | const wchar_t* File; 1916 | FILETIME Time; 1917 | BOOL Lock; 1918 | }; 1919 | 1920 | struct FarSettingsEnum 1921 | { 1922 | size_t StructSize; 1923 | size_t Root; 1924 | size_t Count; 1925 | union 1926 | { 1927 | const struct FarSettingsName* Items; 1928 | const struct FarSettingsHistory* Histories; 1929 | } 1930 | #ifndef __cplusplus 1931 | Value 1932 | #endif 1933 | ; 1934 | }; 1935 | 1936 | struct FarSettingsValue 1937 | { 1938 | size_t StructSize; 1939 | size_t Root; 1940 | const wchar_t* Value; 1941 | }; 1942 | 1943 | typedef intptr_t (WINAPI *FARAPIPANELCONTROL)( 1944 | HANDLE hPanel, 1945 | enum FILE_CONTROL_COMMANDS Command, 1946 | intptr_t Param1, 1947 | void* Param2 1948 | ); 1949 | 1950 | typedef intptr_t(WINAPI *FARAPIADVCONTROL)( 1951 | const GUID* PluginId, 1952 | enum ADVANCED_CONTROL_COMMANDS Command, 1953 | intptr_t Param1, 1954 | void* Param2 1955 | ); 1956 | 1957 | typedef intptr_t (WINAPI *FARAPIVIEWERCONTROL)( 1958 | intptr_t ViewerID, 1959 | enum VIEWER_CONTROL_COMMANDS Command, 1960 | intptr_t Param1, 1961 | void* Param2 1962 | ); 1963 | 1964 | typedef intptr_t (WINAPI *FARAPIEDITORCONTROL)( 1965 | intptr_t EditorID, 1966 | enum EDITOR_CONTROL_COMMANDS Command, 1967 | intptr_t Param1, 1968 | void* Param2 1969 | ); 1970 | 1971 | typedef intptr_t (WINAPI *FARAPIMACROCONTROL)( 1972 | const GUID* PluginId, 1973 | enum FAR_MACRO_CONTROL_COMMANDS Command, 1974 | intptr_t Param1, 1975 | void* Param2 1976 | ); 1977 | 1978 | typedef intptr_t (WINAPI *FARAPIPLUGINSCONTROL)( 1979 | HANDLE hHandle, 1980 | enum FAR_PLUGINS_CONTROL_COMMANDS Command, 1981 | intptr_t Param1, 1982 | void* Param2 1983 | ); 1984 | 1985 | typedef intptr_t (WINAPI *FARAPIFILEFILTERCONTROL)( 1986 | HANDLE hHandle, 1987 | enum FAR_FILE_FILTER_CONTROL_COMMANDS Command, 1988 | intptr_t Param1, 1989 | void* Param2 1990 | ); 1991 | 1992 | typedef intptr_t (WINAPI *FARAPIREGEXPCONTROL)( 1993 | HANDLE hHandle, 1994 | enum FAR_REGEXP_CONTROL_COMMANDS Command, 1995 | intptr_t Param1, 1996 | void* Param2 1997 | ); 1998 | 1999 | typedef intptr_t (WINAPI *FARAPISETTINGSCONTROL)( 2000 | HANDLE hHandle, 2001 | enum FAR_SETTINGS_CONTROL_COMMANDS Command, 2002 | intptr_t Param1, 2003 | void* Param2 2004 | ); 2005 | 2006 | enum FARCLIPBOARD_TYPE 2007 | { 2008 | FCT_ANY=0, 2009 | FCT_STREAM=1, 2010 | FCT_COLUMN=2 2011 | }; 2012 | 2013 | // 2014 | typedef int (WINAPIV *FARSTDSPRINTF)(wchar_t *Buffer,const wchar_t *Format,...); 2015 | typedef int (WINAPIV *FARSTDSNPRINTF)(wchar_t *Buffer,size_t Sizebuf,const wchar_t *Format,...); 2016 | typedef int (WINAPIV *FARSTDSSCANF)(const wchar_t *Buffer, const wchar_t *Format,...); 2017 | // 2018 | typedef void (WINAPI *FARSTDQSORT)(void *base, size_t nelem, size_t width, int (WINAPI *fcmp)(const void *, const void *,void *userparam),void *userparam); 2019 | typedef void *(WINAPI *FARSTDBSEARCH)(const void *key, const void *base, size_t nelem, size_t width, int (WINAPI *fcmp)(const void *, const void *,void *userparam),void *userparam); 2020 | typedef size_t (WINAPI *FARSTDGETFILEOWNER)(const wchar_t *Computer,const wchar_t *Name,wchar_t *Owner,size_t Size); 2021 | typedef size_t (WINAPI *FARSTDGETNUMBEROFLINKS)(const wchar_t *Name); 2022 | typedef int (WINAPI *FARSTDATOI)(const wchar_t *s); 2023 | typedef __int64 (WINAPI *FARSTDATOI64)(const wchar_t *s); 2024 | typedef wchar_t *(WINAPI *FARSTDITOA64)(__int64 value, wchar_t *Str, int radix); 2025 | typedef wchar_t *(WINAPI *FARSTDITOA)(int value, wchar_t *Str, int radix); 2026 | typedef wchar_t *(WINAPI *FARSTDLTRIM)(wchar_t *Str); 2027 | typedef wchar_t *(WINAPI *FARSTDRTRIM)(wchar_t *Str); 2028 | typedef wchar_t *(WINAPI *FARSTDTRIM)(wchar_t *Str); 2029 | typedef wchar_t *(WINAPI *FARSTDTRUNCSTR)(wchar_t *Str,intptr_t MaxLength); 2030 | typedef wchar_t *(WINAPI *FARSTDTRUNCPATHSTR)(wchar_t *Str,intptr_t MaxLength); 2031 | typedef wchar_t *(WINAPI *FARSTDQUOTESPACEONLY)(wchar_t *Str); 2032 | typedef const wchar_t*(WINAPI *FARSTDPOINTTONAME)(const wchar_t *Path); 2033 | typedef BOOL (WINAPI *FARSTDADDENDSLASH)(wchar_t *Path); 2034 | typedef BOOL (WINAPI *FARSTDCOPYTOCLIPBOARD)(enum FARCLIPBOARD_TYPE Type, const wchar_t *Data); 2035 | typedef size_t (WINAPI *FARSTDPASTEFROMCLIPBOARD)(enum FARCLIPBOARD_TYPE Type, wchar_t *Data, size_t Size); 2036 | typedef int (WINAPI *FARSTDLOCALISLOWER)(wchar_t Ch); 2037 | typedef int (WINAPI *FARSTDLOCALISUPPER)(wchar_t Ch); 2038 | typedef int (WINAPI *FARSTDLOCALISALPHA)(wchar_t Ch); 2039 | typedef int (WINAPI *FARSTDLOCALISALPHANUM)(wchar_t Ch); 2040 | typedef wchar_t (WINAPI *FARSTDLOCALUPPER)(wchar_t LowerChar); 2041 | typedef wchar_t (WINAPI *FARSTDLOCALLOWER)(wchar_t UpperChar); 2042 | typedef void (WINAPI *FARSTDLOCALUPPERBUF)(wchar_t *Buf,intptr_t Length); 2043 | typedef void (WINAPI *FARSTDLOCALLOWERBUF)(wchar_t *Buf,intptr_t Length); 2044 | typedef void (WINAPI *FARSTDLOCALSTRUPR)(wchar_t *s1); 2045 | typedef void (WINAPI *FARSTDLOCALSTRLWR)(wchar_t *s1); 2046 | typedef int (WINAPI *FARSTDLOCALSTRICMP)(const wchar_t *s1,const wchar_t *s2); 2047 | typedef int (WINAPI *FARSTDLOCALSTRNICMP)(const wchar_t *s1,const wchar_t *s2,intptr_t n); 2048 | typedef unsigned __int64 (WINAPI *FARSTDFARCLOCK)(); 2049 | 2050 | typedef unsigned __int64 PROCESSNAME_FLAGS; 2051 | static const PROCESSNAME_FLAGS 2052 | // 0xFFFF - length 2053 | // 0xFF0000 - mode 2054 | // 0xFFFFFFFFFF000000 - flags 2055 | PN_CMPNAME = 0x0000000000000000ULL, 2056 | PN_CMPNAMELIST = 0x0000000000010000ULL, 2057 | PN_GENERATENAME = 0x0000000000020000ULL, 2058 | PN_CHECKMASK = 0x0000000000030000ULL, 2059 | 2060 | PN_SKIPPATH = 0x0000000001000000ULL, 2061 | PN_SHOWERRORMESSAGE = 0x0000000002000000ULL, 2062 | PN_NONE = 0; 2063 | 2064 | typedef size_t (WINAPI *FARSTDPROCESSNAME)(const wchar_t *param1, wchar_t *param2, size_t size, PROCESSNAME_FLAGS flags); 2065 | 2066 | typedef void (WINAPI *FARSTDUNQUOTE)(wchar_t *Str); 2067 | 2068 | typedef unsigned __int64 XLAT_FLAGS; 2069 | static const XLAT_FLAGS 2070 | XLAT_SWITCHKEYBLAYOUT = 0x0000000000000001ULL, 2071 | XLAT_SWITCHKEYBBEEP = 0x0000000000000002ULL, 2072 | XLAT_USEKEYBLAYOUTNAME = 0x0000000000000004ULL, 2073 | XLAT_CONVERTALLCMDLINE = 0x0000000000010000ULL, 2074 | XLAT_NONE = 0; 2075 | 2076 | typedef size_t (WINAPI *FARSTDINPUTRECORDTOKEYNAME)(const INPUT_RECORD* Key, wchar_t *KeyText, size_t Size); 2077 | 2078 | typedef wchar_t*(WINAPI *FARSTDXLAT)(wchar_t *Line,intptr_t StartPos,intptr_t EndPos,XLAT_FLAGS Flags); 2079 | 2080 | typedef BOOL (WINAPI *FARSTDKEYNAMETOINPUTRECORD)(const wchar_t *Name,INPUT_RECORD* Key); 2081 | 2082 | typedef int (WINAPI *FRSUSERFUNC)( 2083 | const struct PluginPanelItem *FData, 2084 | const wchar_t *FullName, 2085 | void *Param 2086 | ); 2087 | 2088 | typedef unsigned __int64 FRSMODE; 2089 | static const FRSMODE 2090 | FRS_RETUPDIR = 0x0000000000000001ULL, 2091 | FRS_RECUR = 0x0000000000000002ULL, 2092 | FRS_SCANSYMLINK = 0x0000000000000004ULL, 2093 | FRS_NONE = 0; 2094 | 2095 | typedef void (WINAPI *FARSTDRECURSIVESEARCH)(const wchar_t *InitDir,const wchar_t *Mask,FRSUSERFUNC Func,FRSMODE Flags,void *Param); 2096 | typedef size_t (WINAPI *FARSTDMKTEMP)(wchar_t *Dest, size_t DestSize, const wchar_t *Prefix); 2097 | typedef size_t (WINAPI *FARSTDGETPATHROOT)(const wchar_t *Path,wchar_t *Root, size_t DestSize); 2098 | 2099 | enum LINK_TYPE 2100 | { 2101 | LINK_HARDLINK = 1, 2102 | LINK_JUNCTION = 2, 2103 | LINK_VOLMOUNT = 3, 2104 | LINK_SYMLINKFILE = 4, 2105 | LINK_SYMLINKDIR = 5, 2106 | LINK_SYMLINK = 6, 2107 | }; 2108 | 2109 | typedef unsigned __int64 MKLINK_FLAGS; 2110 | static const MKLINK_FLAGS 2111 | MLF_SHOWERRMSG = 0x0000000000010000ULL, 2112 | MLF_DONOTUPDATEPANEL = 0x0000000000020000ULL, 2113 | MLF_HOLDTARGET = 0x0000000000040000ULL, 2114 | MLF_NONE = 0; 2115 | 2116 | typedef BOOL (WINAPI *FARSTDMKLINK)(const wchar_t *Src,const wchar_t *Dest,enum LINK_TYPE Type, MKLINK_FLAGS Flags); 2117 | typedef size_t (WINAPI *FARGETREPARSEPOINTINFO)(const wchar_t *Src, wchar_t *Dest, size_t DestSize); 2118 | 2119 | enum CONVERTPATHMODES 2120 | { 2121 | CPM_FULL = 0, 2122 | CPM_REAL = 1, 2123 | CPM_NATIVE = 2, 2124 | }; 2125 | 2126 | typedef size_t (WINAPI *FARCONVERTPATH)(enum CONVERTPATHMODES Mode, const wchar_t *Src, wchar_t *Dest, size_t DestSize); 2127 | 2128 | typedef size_t (WINAPI *FARGETCURRENTDIRECTORY)(size_t Size, wchar_t* Buffer); 2129 | 2130 | typedef unsigned __int64 FARFORMATFILESIZEFLAGS; 2131 | static const FARFORMATFILESIZEFLAGS 2132 | FFFS_COMMAS = 0x0100000000000000LL, 2133 | FFFS_FLOATSIZE = 0x0200000000000000LL, 2134 | FFFS_SHOWBYTESINDEX = 0x0400000000000000LL, 2135 | FFFS_ECONOMIC = 0x0800000000000000LL, 2136 | FFFS_THOUSAND = 0x1000000000000000LL, 2137 | FFFS_MINSIZEINDEX = 0x2000000000000000LL, 2138 | FFFS_MINSIZEINDEX_MASK = 0x0000000000000003LL, 2139 | FFFS_NONE = 0; 2140 | 2141 | typedef size_t (WINAPI *FARFORMATFILESIZE)(unsigned __int64 Size, intptr_t Width, FARFORMATFILESIZEFLAGS Flags, wchar_t *Dest, size_t DestSize); 2142 | 2143 | typedef struct FarStandardFunctions 2144 | { 2145 | size_t StructSize; 2146 | 2147 | FARSTDATOI atoi; 2148 | FARSTDATOI64 atoi64; 2149 | FARSTDITOA itoa; 2150 | FARSTDITOA64 itoa64; 2151 | // 2152 | FARSTDSPRINTF sprintf; 2153 | FARSTDSSCANF sscanf; 2154 | // 2155 | FARSTDQSORT qsort; 2156 | FARSTDBSEARCH bsearch; 2157 | // 2158 | FARSTDSNPRINTF snprintf; 2159 | // 2160 | 2161 | FARSTDLOCALISLOWER LIsLower; 2162 | FARSTDLOCALISUPPER LIsUpper; 2163 | FARSTDLOCALISALPHA LIsAlpha; 2164 | FARSTDLOCALISALPHANUM LIsAlphanum; 2165 | FARSTDLOCALUPPER LUpper; 2166 | FARSTDLOCALLOWER LLower; 2167 | FARSTDLOCALUPPERBUF LUpperBuf; 2168 | FARSTDLOCALLOWERBUF LLowerBuf; 2169 | FARSTDLOCALSTRUPR LStrupr; 2170 | FARSTDLOCALSTRLWR LStrlwr; 2171 | FARSTDLOCALSTRICMP LStricmp; 2172 | FARSTDLOCALSTRNICMP LStrnicmp; 2173 | 2174 | FARSTDUNQUOTE Unquote; 2175 | FARSTDLTRIM LTrim; 2176 | FARSTDRTRIM RTrim; 2177 | FARSTDTRIM Trim; 2178 | FARSTDTRUNCSTR TruncStr; 2179 | FARSTDTRUNCPATHSTR TruncPathStr; 2180 | FARSTDQUOTESPACEONLY QuoteSpaceOnly; 2181 | FARSTDPOINTTONAME PointToName; 2182 | FARSTDGETPATHROOT GetPathRoot; 2183 | FARSTDADDENDSLASH AddEndSlash; 2184 | FARSTDCOPYTOCLIPBOARD CopyToClipboard; 2185 | FARSTDPASTEFROMCLIPBOARD PasteFromClipboard; 2186 | FARSTDINPUTRECORDTOKEYNAME FarInputRecordToName; 2187 | FARSTDKEYNAMETOINPUTRECORD FarNameToInputRecord; 2188 | FARSTDXLAT XLat; 2189 | FARSTDGETFILEOWNER GetFileOwner; 2190 | FARSTDGETNUMBEROFLINKS GetNumberOfLinks; 2191 | FARSTDRECURSIVESEARCH FarRecursiveSearch; 2192 | FARSTDMKTEMP MkTemp; 2193 | FARSTDPROCESSNAME ProcessName; 2194 | FARSTDMKLINK MkLink; 2195 | FARCONVERTPATH ConvertPath; 2196 | FARGETREPARSEPOINTINFO GetReparsePointInfo; 2197 | FARGETCURRENTDIRECTORY GetCurrentDirectory; 2198 | FARFORMATFILESIZE FormatFileSize; 2199 | FARSTDFARCLOCK FarClock; 2200 | } FARSTANDARDFUNCTIONS; 2201 | 2202 | struct PluginStartupInfo 2203 | { 2204 | size_t StructSize; 2205 | const wchar_t *ModuleName; 2206 | FARAPIMENU Menu; 2207 | FARAPIMESSAGE Message; 2208 | FARAPIGETMSG GetMsg; 2209 | FARAPIPANELCONTROL PanelControl; 2210 | FARAPISAVESCREEN SaveScreen; 2211 | FARAPIRESTORESCREEN RestoreScreen; 2212 | FARAPIGETDIRLIST GetDirList; 2213 | FARAPIGETPLUGINDIRLIST GetPluginDirList; 2214 | FARAPIFREEDIRLIST FreeDirList; 2215 | FARAPIFREEPLUGINDIRLIST FreePluginDirList; 2216 | FARAPIVIEWER Viewer; 2217 | FARAPIEDITOR Editor; 2218 | FARAPITEXT Text; 2219 | FARAPIEDITORCONTROL EditorControl; 2220 | 2221 | FARSTANDARDFUNCTIONS *FSF; 2222 | 2223 | FARAPISHOWHELP ShowHelp; 2224 | FARAPIADVCONTROL AdvControl; 2225 | FARAPIINPUTBOX InputBox; 2226 | FARAPICOLORDIALOG ColorDialog; 2227 | FARAPIDIALOGINIT DialogInit; 2228 | FARAPIDIALOGRUN DialogRun; 2229 | FARAPIDIALOGFREE DialogFree; 2230 | 2231 | FARAPISENDDLGMESSAGE SendDlgMessage; 2232 | FARAPIDEFDLGPROC DefDlgProc; 2233 | FARAPIVIEWERCONTROL ViewerControl; 2234 | FARAPIPLUGINSCONTROL PluginsControl; 2235 | FARAPIFILEFILTERCONTROL FileFilterControl; 2236 | FARAPIREGEXPCONTROL RegExpControl; 2237 | FARAPIMACROCONTROL MacroControl; 2238 | FARAPISETTINGSCONTROL SettingsControl; 2239 | void *Private; 2240 | void* Instance; 2241 | }; 2242 | 2243 | typedef HANDLE (WINAPI *FARAPICREATEFILE)(const wchar_t *Object,DWORD DesiredAccess,DWORD ShareMode,LPSECURITY_ATTRIBUTES SecurityAttributes,DWORD CreationDistribution,DWORD FlagsAndAttributes,HANDLE TemplateFile); 2244 | typedef DWORD (WINAPI *FARAPIGETFILEATTRIBUTES)(const wchar_t *FileName); 2245 | typedef BOOL (WINAPI *FARAPISETFILEATTRIBUTES)(const wchar_t *FileName,DWORD dwFileAttributes); 2246 | typedef BOOL (WINAPI *FARAPIMOVEFILEEX)(const wchar_t *ExistingFileName,const wchar_t *NewFileName,DWORD dwFlags); 2247 | typedef BOOL (WINAPI *FARAPIDELETEFILE)(const wchar_t *FileName); 2248 | typedef BOOL (WINAPI *FARAPIREMOVEDIRECTORY)(const wchar_t *DirName); 2249 | typedef BOOL (WINAPI *FARAPICREATEDIRECTORY)(const wchar_t *PathName,LPSECURITY_ATTRIBUTES lpSecurityAttributes); 2250 | 2251 | struct ArclitePrivateInfo 2252 | { 2253 | size_t StructSize; 2254 | FARAPICREATEFILE CreateFile; 2255 | FARAPIGETFILEATTRIBUTES GetFileAttributes; 2256 | FARAPISETFILEATTRIBUTES SetFileAttributes; 2257 | FARAPIMOVEFILEEX MoveFileEx; 2258 | FARAPIDELETEFILE DeleteFile; 2259 | FARAPIREMOVEDIRECTORY RemoveDirectory; 2260 | FARAPICREATEDIRECTORY CreateDirectory; 2261 | }; 2262 | 2263 | struct NetBoxPrivateInfo 2264 | { 2265 | size_t StructSize; 2266 | FARAPICREATEFILE CreateFile; 2267 | FARAPIGETFILEATTRIBUTES GetFileAttributes; 2268 | FARAPISETFILEATTRIBUTES SetFileAttributes; 2269 | FARAPIMOVEFILEEX MoveFileEx; 2270 | FARAPIDELETEFILE DeleteFile; 2271 | FARAPIREMOVEDIRECTORY RemoveDirectory; 2272 | FARAPICREATEDIRECTORY CreateDirectory; 2273 | }; 2274 | 2275 | struct MacroPluginReturn 2276 | { 2277 | intptr_t ReturnType; 2278 | size_t Count; 2279 | struct FarMacroValue *Values; 2280 | }; 2281 | 2282 | typedef intptr_t (WINAPI *FARAPICALLFAR)(intptr_t CheckCode, struct FarMacroCall* Data); 2283 | 2284 | struct MacroPrivateInfo 2285 | { 2286 | size_t StructSize; 2287 | FARAPICALLFAR CallFar; 2288 | }; 2289 | 2290 | typedef unsigned __int64 PLUGIN_FLAGS; 2291 | static const PLUGIN_FLAGS 2292 | PF_PRELOAD = 0x0000000000000001ULL, 2293 | PF_DISABLEPANELS = 0x0000000000000002ULL, 2294 | PF_EDITOR = 0x0000000000000004ULL, 2295 | PF_VIEWER = 0x0000000000000008ULL, 2296 | PF_FULLCMDLINE = 0x0000000000000010ULL, 2297 | PF_DIALOG = 0x0000000000000020ULL, 2298 | PF_NONE = 0; 2299 | 2300 | struct PluginMenuItem 2301 | { 2302 | const GUID *Guids; 2303 | const wchar_t * const *Strings; 2304 | size_t Count; 2305 | }; 2306 | 2307 | enum VERSION_STAGE 2308 | { 2309 | VS_RELEASE = 0, 2310 | VS_ALPHA = 1, 2311 | VS_BETA = 2, 2312 | VS_RC = 3, 2313 | }; 2314 | 2315 | struct VersionInfo 2316 | { 2317 | DWORD Major; 2318 | DWORD Minor; 2319 | DWORD Revision; 2320 | DWORD Build; 2321 | enum VERSION_STAGE Stage; 2322 | }; 2323 | 2324 | static __inline BOOL CheckVersion(const struct VersionInfo* Current, const struct VersionInfo* Required) 2325 | { 2326 | return (Current->Major > Required->Major) || (Current->Major == Required->Major && Current->Minor > Required->Minor) || (Current->Major == Required->Major && Current->Minor == Required->Minor && Current->Revision > Required->Revision) || (Current->Major == Required->Major && Current->Minor == Required->Minor && Current->Revision == Required->Revision && Current->Build >= Required->Build); 2327 | } 2328 | 2329 | static __inline struct VersionInfo MAKEFARVERSION(DWORD Major, DWORD Minor, DWORD Revision, DWORD Build, enum VERSION_STAGE Stage) 2330 | { 2331 | struct VersionInfo Info = {Major, Minor, Revision, Build, Stage}; 2332 | return Info; 2333 | } 2334 | 2335 | #define FARMANAGERVERSION MAKEFARVERSION(FARMANAGERVERSION_MAJOR,FARMANAGERVERSION_MINOR, FARMANAGERVERSION_REVISION, FARMANAGERVERSION_BUILD, FARMANAGERVERSION_STAGE) 2336 | 2337 | struct GlobalInfo 2338 | { 2339 | size_t StructSize; 2340 | struct VersionInfo MinFarVersion; 2341 | struct VersionInfo Version; 2342 | GUID Guid; 2343 | const wchar_t *Title; 2344 | const wchar_t *Description; 2345 | const wchar_t *Author; 2346 | void* Instance; 2347 | }; 2348 | 2349 | struct PluginInfo 2350 | { 2351 | size_t StructSize; 2352 | PLUGIN_FLAGS Flags; 2353 | struct PluginMenuItem DiskMenu; 2354 | struct PluginMenuItem PluginMenu; 2355 | struct PluginMenuItem PluginConfig; 2356 | const wchar_t *CommandPrefix; 2357 | void* Instance; 2358 | }; 2359 | 2360 | struct FarGetPluginInformation 2361 | { 2362 | size_t StructSize; 2363 | const wchar_t *ModuleName; 2364 | FAR_PLUGIN_FLAGS Flags; 2365 | struct PluginInfo *PInfo; 2366 | struct GlobalInfo *GInfo; 2367 | }; 2368 | 2369 | typedef unsigned __int64 INFOPANELLINE_FLAGS; 2370 | static const INFOPANELLINE_FLAGS 2371 | IPLFLAGS_SEPARATOR = 0x0000000000000001ULL, 2372 | IPLFLAGS_NONE = 0; 2373 | 2374 | struct InfoPanelLine 2375 | { 2376 | const wchar_t *Text; 2377 | const wchar_t *Data; 2378 | INFOPANELLINE_FLAGS Flags; 2379 | }; 2380 | 2381 | typedef unsigned __int64 PANELMODE_FLAGS; 2382 | static const PANELMODE_FLAGS 2383 | PMFLAGS_FULLSCREEN = 0x0000000000000001ULL, 2384 | PMFLAGS_DETAILEDSTATUS = 0x0000000000000002ULL, 2385 | PMFLAGS_ALIGNEXTENSIONS = 0x0000000000000004ULL, 2386 | PMFLAGS_CASECONVERSION = 0x0000000000000008ULL, 2387 | PMFLAGS_NONE = 0; 2388 | 2389 | struct PanelMode 2390 | { 2391 | const wchar_t *ColumnTypes; 2392 | const wchar_t *ColumnWidths; 2393 | const wchar_t * const *ColumnTitles; 2394 | const wchar_t *StatusColumnTypes; 2395 | const wchar_t *StatusColumnWidths; 2396 | PANELMODE_FLAGS Flags; 2397 | }; 2398 | 2399 | typedef unsigned __int64 OPENPANELINFO_FLAGS; 2400 | static const OPENPANELINFO_FLAGS 2401 | OPIF_DISABLEFILTER = 0x0000000000000001ULL, 2402 | OPIF_DISABLESORTGROUPS = 0x0000000000000002ULL, 2403 | OPIF_DISABLEHIGHLIGHTING = 0x0000000000000004ULL, 2404 | OPIF_ADDDOTS = 0x0000000000000008ULL, 2405 | OPIF_RAWSELECTION = 0x0000000000000010ULL, 2406 | OPIF_REALNAMES = 0x0000000000000020ULL, 2407 | OPIF_SHOWNAMESONLY = 0x0000000000000040ULL, 2408 | OPIF_SHOWRIGHTALIGNNAMES = 0x0000000000000080ULL, 2409 | OPIF_SHOWPRESERVECASE = 0x0000000000000100ULL, 2410 | OPIF_COMPAREFATTIME = 0x0000000000000400ULL, 2411 | OPIF_EXTERNALGET = 0x0000000000000800ULL, 2412 | OPIF_EXTERNALPUT = 0x0000000000001000ULL, 2413 | OPIF_EXTERNALDELETE = 0x0000000000002000ULL, 2414 | OPIF_EXTERNALMKDIR = 0x0000000000004000ULL, 2415 | OPIF_USEATTRHIGHLIGHTING = 0x0000000000008000ULL, 2416 | OPIF_USECRC32 = 0x0000000000010000ULL, 2417 | OPIF_USEFREESIZE = 0x0000000000020000ULL, 2418 | OPIF_SHORTCUT = 0x0000000000040000ULL, 2419 | OPIF_NONE = 0; 2420 | 2421 | struct KeyBarLabel 2422 | { 2423 | struct FarKey Key; 2424 | const wchar_t *Text; 2425 | const wchar_t *LongText; 2426 | }; 2427 | 2428 | struct KeyBarTitles 2429 | { 2430 | size_t CountLabels; 2431 | struct KeyBarLabel *Labels; 2432 | }; 2433 | 2434 | struct FarSetKeyBarTitles 2435 | { 2436 | size_t StructSize; 2437 | struct KeyBarTitles *Titles; 2438 | }; 2439 | 2440 | typedef unsigned __int64 OPERATION_MODES; 2441 | static const OPERATION_MODES 2442 | OPM_SILENT =0x0000000000000001ULL, 2443 | OPM_FIND =0x0000000000000002ULL, 2444 | OPM_VIEW =0x0000000000000004ULL, 2445 | OPM_EDIT =0x0000000000000008ULL, 2446 | OPM_TOPLEVEL =0x0000000000000010ULL, 2447 | OPM_DESCR =0x0000000000000020ULL, 2448 | OPM_QUICKVIEW =0x0000000000000040ULL, 2449 | OPM_PGDN =0x0000000000000080ULL, 2450 | OPM_COMMANDS =0x0000000000000100ULL, 2451 | OPM_NONE =0; 2452 | 2453 | struct OpenPanelInfo 2454 | { 2455 | size_t StructSize; 2456 | HANDLE hPanel; 2457 | OPENPANELINFO_FLAGS Flags; 2458 | const wchar_t *HostFile; 2459 | const wchar_t *CurDir; 2460 | const wchar_t *Format; 2461 | const wchar_t *PanelTitle; 2462 | const struct InfoPanelLine *InfoLines; 2463 | size_t InfoLinesNumber; 2464 | const wchar_t * const *DescrFiles; 2465 | size_t DescrFilesNumber; 2466 | const struct PanelMode *PanelModesArray; 2467 | size_t PanelModesNumber; 2468 | intptr_t StartPanelMode; 2469 | enum OPENPANELINFO_SORTMODES StartSortMode; 2470 | intptr_t StartSortOrder; 2471 | const struct KeyBarTitles *KeyBar; 2472 | const wchar_t *ShortcutData; 2473 | unsigned __int64 FreeSize; 2474 | struct UserDataItem UserData; 2475 | void* Instance; 2476 | }; 2477 | 2478 | struct AnalyseInfo 2479 | { 2480 | size_t StructSize; 2481 | const wchar_t *FileName; 2482 | void *Buffer; 2483 | size_t BufferSize; 2484 | OPERATION_MODES OpMode; 2485 | void* Instance; 2486 | }; 2487 | 2488 | struct OpenAnalyseInfo 2489 | { 2490 | size_t StructSize; 2491 | struct AnalyseInfo* Info; 2492 | HANDLE Handle; 2493 | }; 2494 | 2495 | struct OpenMacroInfo 2496 | { 2497 | size_t StructSize; 2498 | size_t Count; 2499 | struct FarMacroValue *Values; 2500 | }; 2501 | 2502 | typedef unsigned __int64 FAROPENSHORTCUTFLAGS; 2503 | static const FAROPENSHORTCUTFLAGS 2504 | FOSF_ACTIVE = 0x0000000000000001ULL, 2505 | FOSF_NONE = 0; 2506 | 2507 | struct OpenShortcutInfo 2508 | { 2509 | size_t StructSize; 2510 | const wchar_t *HostFile; 2511 | const wchar_t *ShortcutData; 2512 | FAROPENSHORTCUTFLAGS Flags; 2513 | }; 2514 | 2515 | struct OpenCommandLineInfo 2516 | { 2517 | size_t StructSize; 2518 | const wchar_t *CommandLine; 2519 | }; 2520 | 2521 | enum OPENFROM 2522 | { 2523 | OPEN_LEFTDISKMENU = 0, 2524 | OPEN_PLUGINSMENU = 1, 2525 | OPEN_FINDLIST = 2, 2526 | OPEN_SHORTCUT = 3, 2527 | OPEN_COMMANDLINE = 4, 2528 | OPEN_EDITOR = 5, 2529 | OPEN_VIEWER = 6, 2530 | OPEN_FILEPANEL = 7, 2531 | OPEN_DIALOG = 8, 2532 | OPEN_ANALYSE = 9, 2533 | OPEN_RIGHTDISKMENU = 10, 2534 | OPEN_FROMMACRO = 11, 2535 | OPEN_LUAMACRO = 100, 2536 | }; 2537 | 2538 | enum MACROCALLTYPE 2539 | { 2540 | MCT_MACROPARSE = 0, 2541 | MCT_LOADMACROS = 1, 2542 | MCT_ENUMMACROS = 2, 2543 | MCT_WRITEMACROS = 3, 2544 | MCT_GETMACRO = 4, 2545 | MCT_RECORDEDMACRO = 5, 2546 | MCT_DELMACRO = 6, 2547 | MCT_RUNSTARTMACRO = 7, 2548 | MCT_EXECSTRING = 8, 2549 | MCT_PANELSORT = 9, 2550 | MCT_GETCUSTOMSORTMODES = 10, 2551 | MCT_ADDMACRO = 11, 2552 | MCT_KEYMACRO = 12, 2553 | MCT_CANPANELSORT = 13, 2554 | }; 2555 | 2556 | enum MACROPLUGINRETURNTYPE 2557 | { 2558 | MPRT_NORMALFINISH = 0, 2559 | MPRT_ERRORFINISH = 1, 2560 | MPRT_ERRORPARSE = 2, 2561 | MPRT_KEYS = 3, 2562 | MPRT_PRINT = 4, 2563 | MPRT_PLUGINCALL = 5, 2564 | MPRT_PLUGINMENU = 6, 2565 | MPRT_PLUGINCONFIG = 7, 2566 | MPRT_PLUGINCOMMAND = 8, 2567 | MPRT_USERMENU = 9, 2568 | MPRT_HASNOMACRO = 10, 2569 | }; 2570 | 2571 | struct OpenMacroPluginInfo 2572 | { 2573 | enum MACROCALLTYPE CallType; 2574 | struct FarMacroCall *Data; 2575 | struct MacroPluginReturn Ret; 2576 | }; 2577 | 2578 | 2579 | enum FAR_EVENTS 2580 | { 2581 | FE_CHANGEVIEWMODE =0, 2582 | FE_REDRAW =1, 2583 | FE_IDLE =2, 2584 | FE_CLOSE =3, 2585 | FE_BREAK =4, 2586 | FE_COMMAND =5, 2587 | 2588 | FE_GOTFOCUS =6, 2589 | FE_KILLFOCUS =7, 2590 | FE_CHANGESORTPARAMS =8, 2591 | }; 2592 | 2593 | struct OpenInfo 2594 | { 2595 | size_t StructSize; 2596 | enum OPENFROM OpenFrom; 2597 | const GUID* Guid; 2598 | intptr_t Data; 2599 | void* Instance; 2600 | }; 2601 | 2602 | struct SetDirectoryInfo 2603 | { 2604 | size_t StructSize; 2605 | HANDLE hPanel; 2606 | const wchar_t *Dir; 2607 | intptr_t Reserved; 2608 | OPERATION_MODES OpMode; 2609 | struct UserDataItem UserData; 2610 | void* Instance; 2611 | }; 2612 | 2613 | struct SetFindListInfo 2614 | { 2615 | size_t StructSize; 2616 | HANDLE hPanel; 2617 | const struct PluginPanelItem *PanelItem; 2618 | size_t ItemsNumber; 2619 | void* Instance; 2620 | }; 2621 | 2622 | struct PutFilesInfo 2623 | { 2624 | size_t StructSize; 2625 | HANDLE hPanel; 2626 | struct PluginPanelItem *PanelItem; 2627 | size_t ItemsNumber; 2628 | BOOL Move; 2629 | const wchar_t *SrcPath; 2630 | OPERATION_MODES OpMode; 2631 | void* Instance; 2632 | }; 2633 | 2634 | struct ProcessHostFileInfo 2635 | { 2636 | size_t StructSize; 2637 | HANDLE hPanel; 2638 | struct PluginPanelItem *PanelItem; 2639 | size_t ItemsNumber; 2640 | OPERATION_MODES OpMode; 2641 | void* Instance; 2642 | }; 2643 | 2644 | struct MakeDirectoryInfo 2645 | { 2646 | size_t StructSize; 2647 | HANDLE hPanel; 2648 | const wchar_t *Name; 2649 | OPERATION_MODES OpMode; 2650 | void* Instance; 2651 | }; 2652 | 2653 | struct CompareInfo 2654 | { 2655 | size_t StructSize; 2656 | HANDLE hPanel; 2657 | const struct PluginPanelItem *Item1; 2658 | const struct PluginPanelItem *Item2; 2659 | enum OPENPANELINFO_SORTMODES Mode; 2660 | void* Instance; 2661 | }; 2662 | 2663 | struct GetFindDataInfo 2664 | { 2665 | size_t StructSize; 2666 | HANDLE hPanel; 2667 | struct PluginPanelItem *PanelItem; 2668 | size_t ItemsNumber; 2669 | OPERATION_MODES OpMode; 2670 | void* Instance; 2671 | }; 2672 | 2673 | 2674 | struct FreeFindDataInfo 2675 | { 2676 | size_t StructSize; 2677 | HANDLE hPanel; 2678 | struct PluginPanelItem *PanelItem; 2679 | size_t ItemsNumber; 2680 | void* Instance; 2681 | }; 2682 | 2683 | struct GetFilesInfo 2684 | { 2685 | size_t StructSize; 2686 | HANDLE hPanel; 2687 | struct PluginPanelItem *PanelItem; 2688 | size_t ItemsNumber; 2689 | BOOL Move; 2690 | const wchar_t *DestPath; 2691 | OPERATION_MODES OpMode; 2692 | void* Instance; 2693 | }; 2694 | 2695 | struct DeleteFilesInfo 2696 | { 2697 | size_t StructSize; 2698 | HANDLE hPanel; 2699 | struct PluginPanelItem *PanelItem; 2700 | size_t ItemsNumber; 2701 | OPERATION_MODES OpMode; 2702 | void* Instance; 2703 | }; 2704 | 2705 | struct ProcessPanelInputInfo 2706 | { 2707 | size_t StructSize; 2708 | HANDLE hPanel; 2709 | INPUT_RECORD Rec; 2710 | void* Instance; 2711 | }; 2712 | 2713 | struct ProcessEditorInputInfo 2714 | { 2715 | size_t StructSize; 2716 | INPUT_RECORD Rec; 2717 | void* Instance; 2718 | }; 2719 | 2720 | typedef unsigned __int64 PROCESSCONSOLEINPUT_FLAGS; 2721 | static const PROCESSCONSOLEINPUT_FLAGS 2722 | PCIF_FROMMAIN = 0x0000000000000001ULL, 2723 | PCIF_NONE = 0; 2724 | 2725 | struct ProcessConsoleInputInfo 2726 | { 2727 | size_t StructSize; 2728 | PROCESSCONSOLEINPUT_FLAGS Flags; 2729 | INPUT_RECORD Rec; 2730 | void* Instance; 2731 | }; 2732 | 2733 | struct ExitInfo 2734 | { 2735 | size_t StructSize; 2736 | void* Instance; 2737 | }; 2738 | 2739 | struct ProcessPanelEventInfo 2740 | { 2741 | size_t StructSize; 2742 | intptr_t Event; 2743 | void* Param; 2744 | HANDLE hPanel; 2745 | void* Instance; 2746 | }; 2747 | 2748 | struct ProcessEditorEventInfo 2749 | { 2750 | size_t StructSize; 2751 | intptr_t Event; 2752 | void* Param; 2753 | intptr_t EditorID; 2754 | void* Instance; 2755 | }; 2756 | 2757 | struct ProcessDialogEventInfo 2758 | { 2759 | size_t StructSize; 2760 | intptr_t Event; 2761 | struct FarDialogEvent* Param; 2762 | void* Instance; 2763 | }; 2764 | 2765 | struct ProcessSynchroEventInfo 2766 | { 2767 | size_t StructSize; 2768 | intptr_t Event; 2769 | void* Param; 2770 | void* Instance; 2771 | }; 2772 | 2773 | struct ProcessViewerEventInfo 2774 | { 2775 | size_t StructSize; 2776 | intptr_t Event; 2777 | void* Param; 2778 | intptr_t ViewerID; 2779 | void* Instance; 2780 | }; 2781 | 2782 | struct ClosePanelInfo 2783 | { 2784 | size_t StructSize; 2785 | HANDLE hPanel; 2786 | void* Instance; 2787 | }; 2788 | 2789 | struct CloseAnalyseInfo 2790 | { 2791 | size_t StructSize; 2792 | HANDLE Handle; 2793 | void* Instance; 2794 | }; 2795 | 2796 | struct ConfigureInfo 2797 | { 2798 | size_t StructSize; 2799 | const GUID* Guid; 2800 | void* Instance; 2801 | }; 2802 | 2803 | struct GetContentFieldsInfo 2804 | { 2805 | size_t StructSize; 2806 | size_t Count; 2807 | const wchar_t* const *Names; 2808 | void* Instance; 2809 | }; 2810 | 2811 | struct GetContentDataInfo 2812 | { 2813 | size_t StructSize; 2814 | const wchar_t *FilePath; 2815 | size_t Count; 2816 | const wchar_t* const *Names; 2817 | const wchar_t **Values; 2818 | void* Instance; 2819 | }; 2820 | 2821 | static const GUID FarGuid = 2822 | {0x00000000, 0x0000, 0x0000, {0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00}}; 2823 | 2824 | #ifdef __cplusplus 2825 | extern "C" 2826 | { 2827 | #endif 2828 | // Exported Functions 2829 | 2830 | HANDLE WINAPI AnalyseW(const struct AnalyseInfo *Info); 2831 | void WINAPI CloseAnalyseW(const struct CloseAnalyseInfo *Info); 2832 | void WINAPI ClosePanelW(const struct ClosePanelInfo *Info); 2833 | intptr_t WINAPI CompareW(const struct CompareInfo *Info); 2834 | intptr_t WINAPI ConfigureW(const struct ConfigureInfo *Info); 2835 | intptr_t WINAPI DeleteFilesW(const struct DeleteFilesInfo *Info); 2836 | void WINAPI ExitFARW(const struct ExitInfo *Info); 2837 | void WINAPI FreeFindDataW(const struct FreeFindDataInfo *Info); 2838 | intptr_t WINAPI GetFilesW(struct GetFilesInfo *Info); 2839 | intptr_t WINAPI GetFindDataW(struct GetFindDataInfo *Info); 2840 | void WINAPI GetGlobalInfoW(struct GlobalInfo *Info); 2841 | void WINAPI GetOpenPanelInfoW(struct OpenPanelInfo *Info); 2842 | void WINAPI GetPluginInfoW(struct PluginInfo *Info); 2843 | intptr_t WINAPI MakeDirectoryW(struct MakeDirectoryInfo *Info); 2844 | HANDLE WINAPI OpenW(const struct OpenInfo *Info); 2845 | intptr_t WINAPI ProcessDialogEventW(const struct ProcessDialogEventInfo *Info); 2846 | intptr_t WINAPI ProcessEditorEventW(const struct ProcessEditorEventInfo *Info); 2847 | intptr_t WINAPI ProcessEditorInputW(const struct ProcessEditorInputInfo *Info); 2848 | intptr_t WINAPI ProcessPanelEventW(const struct ProcessPanelEventInfo *Info); 2849 | intptr_t WINAPI ProcessHostFileW(const struct ProcessHostFileInfo *Info); 2850 | intptr_t WINAPI ProcessPanelInputW(const struct ProcessPanelInputInfo *Info); 2851 | intptr_t WINAPI ProcessConsoleInputW(struct ProcessConsoleInputInfo *Info); 2852 | intptr_t WINAPI ProcessSynchroEventW(const struct ProcessSynchroEventInfo *Info); 2853 | intptr_t WINAPI ProcessViewerEventW(const struct ProcessViewerEventInfo *Info); 2854 | intptr_t WINAPI PutFilesW(const struct PutFilesInfo *Info); 2855 | intptr_t WINAPI SetDirectoryW(const struct SetDirectoryInfo *Info); 2856 | intptr_t WINAPI SetFindListW(const struct SetFindListInfo *Info); 2857 | void WINAPI SetStartupInfoW(const struct PluginStartupInfo *Info); 2858 | intptr_t WINAPI GetContentFieldsW(const struct GetContentFieldsInfo *Info); 2859 | intptr_t WINAPI GetContentDataW(struct GetContentDataInfo *Info); 2860 | void WINAPI FreeContentDataW(const struct GetContentDataInfo *Info); 2861 | 2862 | #ifdef __cplusplus 2863 | }; 2864 | #endif 2865 | 2866 | #endif /* RC_INVOKED */ 2867 | 2868 | #endif // PLUGIN_HPP_3FC978E9_63BE_4FC2_8F96_8188B0AF8363 2869 | -------------------------------------------------------------------------------- /far3sdk/vc_crt_fix/vc_crt_fix.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/excelsior-oss/far-git-autocomplete/bc13ab4ed718f5ac35d429f35b7e740ffeb43a4d/far3sdk/vc_crt_fix/vc_crt_fix.asm -------------------------------------------------------------------------------- /far3sdk/vc_crt_fix/vc_crt_fix_impl.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | vc_crt_fix_impl.cpp 3 | 4 | Workaround for Visual C++ CRT incompatibility with old Windows versions 5 | */ 6 | /* 7 | Copyright © 2011 Far Group 8 | All rights reserved. 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. The name of the authors may not be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS' AND ANY EXPRESS OR 22 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #include 34 | 35 | template 36 | T GetFunctionPointer(const wchar_t* ModuleName, const char* FunctionName, T Replacement) 37 | { 38 | const auto Address = GetProcAddress(GetModuleHandleW(ModuleName), FunctionName); 39 | return Address? reinterpret_cast(Address) : Replacement; 40 | } 41 | 42 | #define CREATE_FUNCTION_POINTER(ModuleName, FunctionName)\ 43 | static const auto Function = GetFunctionPointer(ModuleName, #FunctionName, &implementation::FunctionName) 44 | 45 | static const wchar_t kernel32[] = L"kernel32"; 46 | 47 | // EncodePointer (VC2010) 48 | extern "C" PVOID WINAPI EncodePointerWrapper(PVOID Ptr) 49 | { 50 | struct implementation 51 | { 52 | static PVOID WINAPI EncodePointer(PVOID Ptr) { return Ptr; } 53 | }; 54 | 55 | CREATE_FUNCTION_POINTER(kernel32, EncodePointer); 56 | return Function(Ptr); 57 | } 58 | 59 | // DecodePointer(VC2010) 60 | extern "C" PVOID WINAPI DecodePointerWrapper(PVOID Ptr) 61 | { 62 | struct implementation 63 | { 64 | static PVOID WINAPI DecodePointer(PVOID Ptr) { return Ptr; } 65 | }; 66 | 67 | CREATE_FUNCTION_POINTER(kernel32, DecodePointer); 68 | return Function(Ptr); 69 | } 70 | 71 | // GetModuleHandleExW (VC2012) 72 | extern "C" BOOL WINAPI GetModuleHandleExWWrapper(DWORD Flags, LPCWSTR ModuleName, HMODULE *Module) 73 | { 74 | struct implementation 75 | { 76 | static BOOL WINAPI GetModuleHandleExW(DWORD Flags, LPCWSTR ModuleName, HMODULE *Module) 77 | { 78 | BOOL Result = FALSE; 79 | if (Flags) 80 | { 81 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 82 | } 83 | else 84 | { 85 | *Module = GetModuleHandleW(ModuleName); 86 | if (*Module) 87 | { 88 | Result = TRUE; 89 | } 90 | } 91 | return Result; 92 | } 93 | }; 94 | 95 | CREATE_FUNCTION_POINTER(kernel32, GetModuleHandleExW); 96 | return Function(Flags, ModuleName, Module); 97 | } 98 | 99 | // InitializeSListHead (VC2015) 100 | extern "C" void WINAPI InitializeSListHeadWrapper(PSLIST_HEADER ListHead) 101 | { 102 | struct implementation 103 | { 104 | static void WINAPI InitializeSListHead(PSLIST_HEADER ListHead) 105 | { 106 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 107 | } 108 | }; 109 | 110 | CREATE_FUNCTION_POINTER(kernel32, InitializeSListHead); 111 | return Function(ListHead); 112 | } 113 | 114 | // InterlockedFlushSList (VC2015) 115 | extern "C" PSLIST_ENTRY WINAPI InterlockedFlushSListWrapper(PSLIST_HEADER ListHead) 116 | { 117 | struct implementation 118 | { 119 | static PSLIST_ENTRY WINAPI InterlockedFlushSList(PSLIST_HEADER ListHead) 120 | { 121 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 122 | return nullptr; 123 | } 124 | }; 125 | 126 | CREATE_FUNCTION_POINTER(kernel32, InterlockedFlushSList); 127 | return Function(ListHead); 128 | } 129 | 130 | // InterlockedPopEntrySList (VC2015) 131 | extern "C" PSLIST_ENTRY WINAPI InterlockedPopEntrySListWrapper(PSLIST_HEADER ListHead) 132 | { 133 | struct implementation 134 | { 135 | static PSLIST_ENTRY WINAPI InterlockedPopEntrySList(PSLIST_HEADER ListHead) 136 | { 137 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 138 | return nullptr; 139 | } 140 | }; 141 | 142 | CREATE_FUNCTION_POINTER(kernel32, InterlockedPopEntrySList); 143 | return Function(ListHead); 144 | } 145 | 146 | // InterlockedPushEntrySList (VC2015) 147 | extern "C" PSLIST_ENTRY WINAPI InterlockedPushEntrySListWrapper(PSLIST_HEADER ListHead, PSLIST_ENTRY ListEntry) 148 | { 149 | struct implementation 150 | { 151 | static PSLIST_ENTRY WINAPI InterlockedPushEntrySList(PSLIST_HEADER ListHead, PSLIST_ENTRY ListEntry) 152 | { 153 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 154 | return nullptr; 155 | } 156 | }; 157 | 158 | CREATE_FUNCTION_POINTER(kernel32, InterlockedPushEntrySList); 159 | return Function(ListHead, ListEntry); 160 | } 161 | 162 | // InterlockedPushListSList (VC2015) 163 | extern "C" PSLIST_ENTRY WINAPI InterlockedPushListSListExWrapper(PSLIST_HEADER ListHead, PSLIST_ENTRY List, PSLIST_ENTRY ListEnd, ULONG Count) 164 | { 165 | struct implementation 166 | { 167 | static PSLIST_ENTRY WINAPI InterlockedPushListSListEx(PSLIST_HEADER ListHead, PSLIST_ENTRY List, PSLIST_ENTRY ListEnd, ULONG Count) 168 | { 169 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 170 | return nullptr; 171 | } 172 | }; 173 | 174 | CREATE_FUNCTION_POINTER(kernel32, InterlockedPushListSListEx); 175 | return Function(ListHead, List, ListEnd, Count); 176 | } 177 | 178 | // RtlFirstEntrySList (VC2015) 179 | extern "C" PSLIST_ENTRY WINAPI RtlFirstEntrySListWrapper(PSLIST_HEADER ListHead) 180 | { 181 | struct implementation 182 | { 183 | static PSLIST_ENTRY WINAPI RtlFirstEntrySList(PSLIST_HEADER ListHead) 184 | { 185 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 186 | return nullptr; 187 | } 188 | }; 189 | 190 | CREATE_FUNCTION_POINTER(kernel32, RtlFirstEntrySList); 191 | return Function(ListHead); 192 | } 193 | 194 | // QueryDepthSList (VC2015) 195 | extern "C" USHORT WINAPI QueryDepthSListWrapper(PSLIST_HEADER ListHead) 196 | { 197 | struct implementation 198 | { 199 | static USHORT WINAPI QueryDepthSList(PSLIST_HEADER ListHead) 200 | { 201 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 202 | return 0; 203 | } 204 | }; 205 | 206 | CREATE_FUNCTION_POINTER(kernel32, QueryDepthSList); 207 | return Function(ListHead); 208 | } 209 | 210 | // disable VS2015 telemetry 211 | extern "C" 212 | { 213 | void __vcrt_initialize_telemetry_provider() {} 214 | void __telemetry_main_invoke_trigger() {} 215 | void __telemetry_main_return_trigger() {} 216 | void __vcrt_uninitialize_telemetry_provider() {} 217 | }; 218 | -------------------------------------------------------------------------------- /far3sdk/vc_crt_fix/vc_crt_fix_ulink.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | vc_crt_fix_ulink.cpp 3 | 4 | Workaround for Visual C++ CRT incompatibility with old Windows versions (ulink version) 5 | */ 6 | /* 7 | Copyright © 2010 Far Group 8 | All rights reserved. 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. The name of the authors may not be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #include 34 | #include 35 | 36 | //---------------------------------------------------------------------------- 37 | static LPVOID WINAPI no_recode_pointer(LPVOID p) 38 | { 39 | return p; 40 | } 41 | 42 | //---------------------------------------------------------------------------- 43 | static FARPROC WINAPI delayFailureHook(/*dliNotification*/unsigned dliNotify, 44 | PDelayLoadInfo pdli) 45 | { 46 | if( dliNotify == /*dliFailGetProcAddress*/dliFailGetProc 47 | && pdli && pdli->cb == sizeof(*pdli) 48 | && pdli->hmodCur == GetModuleHandleA("kernel32") 49 | && pdli->dlp.fImportByName && pdli->dlp.szProcName 50 | && ( !lstrcmpA(pdli->dlp.szProcName, "EncodePointer") 51 | || !lstrcmpA(pdli->dlp.szProcName, "DecodePointer"))) 52 | { 53 | return (FARPROC)no_recode_pointer; 54 | } 55 | return nullptr; 56 | } 57 | 58 | //---------------------------------------------------------------------------- 59 | PfnDliHook __pfnDliFailureHook2 = (PfnDliHook)delayFailureHook; 60 | 61 | //---------------------------------------------------------------------------- 62 | 63 | // TODO: Add GetModuleHandleExW 64 | -------------------------------------------------------------------------------- /src/CmdLine.cpp: -------------------------------------------------------------------------------- 1 | #include "CmdLine.hpp" 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | typedef pair Range; 8 | 9 | CmdLine CmdLineCreate(const std::wstring &line, int curPos, int selectionStart, int selectionEnd) { 10 | if (selectionStart == -1) { 11 | assert(selectionEnd == 0); 12 | selectionEnd = -1; 13 | } 14 | CmdLine result = {line, curPos, selectionStart, selectionEnd}; 15 | return result; 16 | } 17 | 18 | static int RangeLength(Range r) { 19 | return r.second - r.first; 20 | } 21 | 22 | 23 | static Range GetSuggestedSuffixRange(const CmdLine &cmdLine) { 24 | if (cmdLine.curPos == cmdLine.selectionEnd) { 25 | assert(cmdLine.selectionStart >= 0); 26 | return Range(cmdLine.selectionStart, cmdLine.selectionEnd); 27 | } else { 28 | // mimic potential location of suggested suffix 29 | return Range(cmdLine.curPos, cmdLine.curPos); 30 | } 31 | } 32 | 33 | static pair GetUserPrefixRange(const CmdLine &cmdLine) { 34 | int start = 0; 35 | int end = cmdLine.curPos - RangeLength(GetSuggestedSuffixRange(cmdLine)); 36 | for (int i = end - 1; i >= 0; --i) { 37 | if (iswspace(cmdLine.line.at(i))) { 38 | start = i + 1; 39 | break; 40 | } 41 | } 42 | return pair(start, end); 43 | } 44 | 45 | static wstring GetRange(const CmdLine &cmdLine, Range range) { 46 | return cmdLine.line.substr(range.first, RangeLength(range)); 47 | } 48 | 49 | wstring GetUserPrefix(const CmdLine &cmdLine) { 50 | return GetRange(cmdLine, GetUserPrefixRange(cmdLine)); 51 | } 52 | 53 | wstring GetSuggestedSuffix(const CmdLine &cmdLine) { 54 | return GetRange(cmdLine, GetSuggestedSuffixRange(cmdLine)); 55 | } 56 | 57 | static Range ReplaceRange(CmdLine &cmdLine, Range range, const wstring &str) { 58 | cmdLine.line.replace(range.first, RangeLength(range), str); 59 | Range newRange = Range(range.first, range.first + (int)str.length()); 60 | return newRange; 61 | } 62 | 63 | void ReplaceUserPrefix(CmdLine &cmdLine, const wstring &newPrefix) { 64 | Range range = ReplaceRange(cmdLine, GetUserPrefixRange(cmdLine), newPrefix); 65 | cmdLine.curPos = range.second; 66 | cmdLine.selectionStart = -1; 67 | cmdLine.selectionEnd = -1; 68 | } 69 | 70 | void ReplaceSuggestedSuffix(CmdLine &cmdLine, const wstring &newSuffix) { 71 | Range range = ReplaceRange(cmdLine, GetSuggestedSuffixRange(cmdLine), newSuffix); 72 | cmdLine.curPos = range.second; 73 | if (RangeLength(range) > 0) { 74 | cmdLine.selectionStart = range.first; 75 | cmdLine.selectionEnd = range.second; 76 | } else { 77 | cmdLine.selectionStart = -1; 78 | cmdLine.selectionEnd = -1; 79 | } 80 | } 81 | 82 | #ifdef DEBUG 83 | void CmdLineTest() { 84 | CmdLine cmdLine = CmdLineCreate(wstring(L"foo ba baz"), 6, -1, 0); 85 | assert(-1 == cmdLine.selectionStart); 86 | assert(-1 == cmdLine.selectionEnd); 87 | 88 | assert(wstring(L"ba") == GetUserPrefix(cmdLine)); 89 | assert(wstring(L"") == GetSuggestedSuffix(cmdLine)); 90 | 91 | ReplaceUserPrefix(cmdLine, wstring(L"ijk")); 92 | assert(wstring(L"foo ijk baz") == cmdLine.line); 93 | assert(7 == cmdLine.curPos); 94 | assert(-1 == cmdLine.selectionStart); 95 | assert(-1 == cmdLine.selectionEnd); 96 | 97 | ReplaceSuggestedSuffix(cmdLine, wstring(L"xyz")); 98 | assert(wstring(L"foo ijkxyz baz") == cmdLine.line); 99 | assert(10 == cmdLine.curPos); 100 | assert(7 == cmdLine.selectionStart); 101 | assert(10 == cmdLine.selectionEnd); 102 | 103 | ReplaceSuggestedSuffix(cmdLine, wstring(L"zz")); 104 | assert(wstring(L"foo ijkzz baz") == cmdLine.line); 105 | assert(9 == cmdLine.curPos); 106 | assert(7 == cmdLine.selectionStart); 107 | assert(9 == cmdLine.selectionEnd); 108 | 109 | ReplaceSuggestedSuffix(cmdLine, wstring(L"")); 110 | assert(wstring(L"foo ijk baz") == cmdLine.line); 111 | assert(7 == cmdLine.curPos); 112 | assert(-1 == cmdLine.selectionStart); 113 | assert(-1 == cmdLine.selectionEnd); 114 | } 115 | #endif 116 | -------------------------------------------------------------------------------- /src/CmdLine.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef struct tCmdLine { 6 | std::wstring line; 7 | int curPos; 8 | int selectionStart, selectionEnd; 9 | } CmdLine; 10 | 11 | CmdLine CmdLineCreate(const std::wstring &line, int curPos, int selectionStart, int selectionEnd); 12 | 13 | std::wstring GetUserPrefix(const CmdLine &cmdLine); 14 | 15 | std::wstring GetSuggestedSuffix(const CmdLine &cmdLine); 16 | 17 | void ReplaceUserPrefix(CmdLine &cmdLine, const std::wstring &newPrefix); 18 | 19 | void ReplaceSuggestedSuffix(CmdLine &cmdLine, const std::wstring &newSuffix); 20 | 21 | #ifdef DEBUG 22 | void CmdLineTest(); 23 | #endif 24 | -------------------------------------------------------------------------------- /src/GitAutocomplete.cpp: -------------------------------------------------------------------------------- 1 | #include "GitAutocomplete.hpp" 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "GitAutocompleteLng.hpp" 13 | #include "Version.hpp" 14 | #include "Guid.hpp" 15 | #include "CmdLine.hpp" 16 | #include "Logic.hpp" 17 | #include "Trie.hpp" 18 | #include "Utils.hpp" 19 | 20 | using namespace std; 21 | 22 | wostream *logFile; 23 | 24 | struct PluginStartupInfo Info; 25 | 26 | static Options globalOptions; 27 | 28 | void WINAPI GetGlobalInfoW(struct GlobalInfo *GInfo) { 29 | GInfo->StructSize = sizeof(struct GlobalInfo); 30 | GInfo->MinFarVersion = PLUGIN_MIN_FAR_VERSION; 31 | GInfo->Version = PLUGIN_VERSION; 32 | GInfo->Guid = MainGuid; 33 | GInfo->Title = PLUGIN_NAME; 34 | GInfo->Description = PLUGIN_DESC; 35 | GInfo->Author = PLUGIN_AUTHOR; 36 | 37 | #ifdef DEBUG 38 | logFile = new wofstream("plugin_log.txt"); 39 | #else 40 | logFile = new wostream(nullptr); 41 | #endif 42 | *logFile << "I am started" << endl; 43 | // TODO: add time 44 | 45 | git_libgit2_init(); 46 | 47 | #ifdef DEBUG 48 | UtilsTest(); 49 | trie_test(); 50 | CmdLineTest(); 51 | LogicTest(); 52 | #endif 53 | 54 | } 55 | 56 | void WINAPI ExitFARW(const struct ExitInfo *EInfo) { 57 | git_libgit2_shutdown(); 58 | 59 | *logFile << L"I am closed" << endl; 60 | #ifdef DEBUG 61 | dynamic_cast(logFile)->close(); 62 | #endif 63 | delete logFile; 64 | } 65 | 66 | const wchar_t *GetMsg(int MsgId) { 67 | return Info.GetMsg(&MainGuid,MsgId); 68 | } 69 | 70 | static const wchar_t *OPT_SHOW_DIALOG = L"ShowDialog"; 71 | static const wchar_t *OPT_STRIP_REMOTE_NAME = L"StripRemoteName"; 72 | 73 | static void LoadGlobalOptionsFromPluginSettings() { 74 | PluginSettings settings(MainGuid, Info.SettingsControl); 75 | globalOptions.showDialog = settings.Get(0, OPT_SHOW_DIALOG, true); 76 | globalOptions.stripRemoteName = settings.Get(0, OPT_STRIP_REMOTE_NAME, true); 77 | globalOptions.suggestNextSuffix = true; // it is always true in global options 78 | } 79 | 80 | static void StoreGlobalOptionsToPluginSettings() { 81 | PluginSettings settings(MainGuid, Info.SettingsControl); 82 | settings.Set(0, OPT_SHOW_DIALOG, globalOptions.showDialog); 83 | settings.Set(0, OPT_STRIP_REMOTE_NAME, globalOptions.stripRemoteName); 84 | } 85 | 86 | void WINAPI SetStartupInfoW(const struct PluginStartupInfo *psi) { 87 | Info = *psi; 88 | 89 | LoadGlobalOptionsFromPluginSettings(); 90 | } 91 | 92 | intptr_t WINAPI ConfigureW(const ConfigureInfo* CfgInfo) { 93 | PluginDialogBuilder Builder(Info, MainGuid, ConfigDialogGuid, MTitle, L"Config"); 94 | 95 | Builder.AddCheckbox(MShowDialog, &globalOptions.showDialog); 96 | Builder.AddCheckbox(MStripRemoteName, &globalOptions.stripRemoteName); 97 | 98 | Builder.AddOKCancel(MOk, MCancel); 99 | 100 | if (Builder.ShowDialog()) { 101 | StoreGlobalOptionsToPluginSettings(); 102 | return true; 103 | } 104 | 105 | return false; 106 | } 107 | 108 | void WINAPI GetPluginInfoW(struct PluginInfo *PInfo) { 109 | PInfo->StructSize = sizeof(*PInfo); 110 | PInfo->Flags = PF_NONE; 111 | 112 | static const wchar_t *PluginMenuStrings[1]; 113 | PluginMenuStrings[0] = GetMsg(MTitle); 114 | PInfo->PluginMenu.Guids = &MenuGuid; 115 | PInfo->PluginMenu.Strings = PluginMenuStrings; 116 | PInfo->PluginMenu.Count = ARRAYSIZE(PluginMenuStrings); 117 | 118 | static const wchar_t *PluginConfigStrings[1]; 119 | PluginConfigStrings[0] = GetMsg(MTitle); 120 | PInfo->PluginConfig.Guids = &ConfigMenuGuid; 121 | PInfo->PluginConfig.Strings = PluginConfigStrings; 122 | PInfo->PluginConfig.Count = ARRAYSIZE(PluginConfigStrings); 123 | } 124 | 125 | static CmdLine GetCmdLine() { 126 | int lineLen = (int)Info.PanelControl(PANEL_ACTIVE, FCTL_GETCMDLINE, 0, nullptr); 127 | assert(lineLen >= 0); 128 | wchar_t *lineRaw = (wchar_t*)malloc(sizeof(wchar_t) * lineLen); 129 | assert(lineRaw != nullptr); 130 | Info.PanelControl(PANEL_ACTIVE, FCTL_GETCMDLINE, lineLen, lineRaw); 131 | wstring line(lineRaw); 132 | 133 | int curPos; 134 | Info.PanelControl(PANEL_ACTIVE, FCTL_GETCMDLINEPOS, 0, &curPos); 135 | 136 | struct CmdLineSelect selection; 137 | selection.StructSize = sizeof(selection); 138 | Info.PanelControl(PANEL_ACTIVE, FCTL_GETCMDLINESELECTION, 0, &selection); 139 | 140 | return CmdLineCreate(line, curPos, (int)selection.SelStart, (int)selection.SelEnd); 141 | } 142 | 143 | static void SetCmdLine(const CmdLine &cmdLine) { 144 | Info.PanelControl(PANEL_ACTIVE, FCTL_SETCMDLINE, 0, (void*)cmdLine.line.c_str()); 145 | Info.PanelControl(PANEL_ACTIVE, FCTL_SETCMDLINEPOS, cmdLine.curPos, nullptr); 146 | struct CmdLineSelect selection = { sizeof(selection), cmdLine.selectionStart, cmdLine.selectionEnd }; 147 | Info.PanelControl(PANEL_ACTIVE, FCTL_SETCMDLINESELECTION, 0, &selection); 148 | } 149 | 150 | static wstring GetActivePanelDir() { 151 | int fpdSize = (int)Info.PanelControl(PANEL_ACTIVE, FCTL_GETPANELDIRECTORY, 0, nullptr); 152 | assert(fpdSize >= 0); 153 | 154 | FarPanelDirectory* dir = (FarPanelDirectory*)malloc(fpdSize); 155 | dir->StructSize = sizeof(FarPanelDirectory); 156 | 157 | Info.PanelControl(PANEL_ACTIVE, FCTL_GETPANELDIRECTORY, fpdSize, dir); 158 | 159 | if (wcslen(dir->File) != 0) { 160 | *logFile << "GetActivePanelDir, FCTL_GETPANELDIRECTORY()->File = " << dir->File << endl; 161 | return wstring(L""); 162 | } 163 | 164 | wstring result = wstring(dir->Name); 165 | free(dir); 166 | return result; 167 | } 168 | 169 | static void ParseOption(Options &options, const wstring &str) { 170 | if (wstring(L"SuggestionsDialog") == str) { 171 | options.showDialog = true; 172 | } else if (wstring(L"InlineSuggestions") == str) { 173 | options.showDialog = false; 174 | } else if (wstring(L"ShortRemoteName") == str) { 175 | options.stripRemoteName = true; 176 | } else if (wstring(L"FullRemoteName") == str) { 177 | options.stripRemoteName = false; 178 | } else if (wstring(L"ShowPreviousInlineSuggestion") == str) { 179 | options.suggestNextSuffix = false; 180 | } else { 181 | *logFile << "Unknown option \"" << str << "\"" << endl; 182 | } 183 | } 184 | 185 | static void ParseOptionsFromMacro(Options &options, OpenMacroInfo *MInfo) { 186 | for (size_t i = 0; i < MInfo->Count; i++) { 187 | FarMacroValue value = MInfo->Values[i]; 188 | if (value.Type != FMVT_STRING) { 189 | *logFile << "Unexpected macro argument of type " << value.Type << endl; 190 | continue; 191 | } 192 | ParseOption(options, wstring(value.String)); 193 | } 194 | } 195 | 196 | HANDLE WINAPI OpenW(const struct OpenInfo *OInfo) { 197 | *logFile << "=====================================================" << endl; 198 | 199 | Options options = globalOptions; 200 | switch (OInfo->OpenFrom) { 201 | case OPEN_PLUGINSMENU: 202 | *logFile << "I am opened from plugins menu" << endl; 203 | break; 204 | 205 | case OPEN_FROMMACRO: { 206 | // To record such macro: Ctrl + .; a; Ctrl + Shift + .; ; enter one of following: 207 | // Plugin.Call("89DF1D5B-F5BB-415B-993D-D34C5FFE049F", "SuggestionsDialog", "ShortRemoteName", "SortByName") 208 | // Plugin.Call("89DF1D5B-F5BB-415B-993D-D34C5FFE049F", "InlineSuggestions", "FullRemoteName", "SortByTime") 209 | *logFile << "I am opened from macro" << endl; 210 | ParseOptionsFromMacro(options, (OpenMacroInfo*)OInfo->Data); 211 | break; 212 | } 213 | 214 | default: 215 | *logFile << "OpenW, bad OpenFrom" << endl; 216 | return INVALID_HANDLE_VALUE; 217 | } 218 | *logFile << "options: " 219 | << "showDialog = " << options.showDialog << " " 220 | << "stripRemoteName = " << options.stripRemoteName << " " 221 | << "suggestNextSuffix = " << options.suggestNextSuffix << endl; 222 | 223 | wstring curDir = GetActivePanelDir(); 224 | if (curDir.empty()) { 225 | *logFile << "Bad current dir" << endl; 226 | return nullptr; 227 | } 228 | *logFile << "curDir = " << curDir.c_str() << endl; 229 | 230 | git_repository *repo = OpenGitRepo(curDir); 231 | if (repo == nullptr) { 232 | *logFile << "Git repo is not opened" << endl; 233 | return nullptr; 234 | } 235 | 236 | CmdLine cmdLine = GetCmdLine(); 237 | 238 | *logFile << "Before transformation:" << endl; 239 | *logFile << "cmdLine = \"" << cmdLine.line.c_str() << "\"" << endl; 240 | *logFile << "cursor pos = " << cmdLine.curPos << endl; 241 | *logFile << "selection start = " << cmdLine.selectionStart << endl; 242 | *logFile << "selection end = " << cmdLine.selectionEnd << endl; 243 | 244 | TransformCmdLine(options, cmdLine, repo); 245 | git_repository_free(repo); 246 | 247 | *logFile << "After transformation:" << endl; 248 | *logFile << "cmdLine = \"" << cmdLine.line.c_str() << "\"" << endl; 249 | *logFile << "cursor pos = " << cmdLine.curPos << endl; 250 | *logFile << "selection start = " << cmdLine.selectionStart << endl; 251 | *logFile << "selection end = " << cmdLine.selectionEnd << endl; 252 | 253 | SetCmdLine(cmdLine); 254 | 255 | return nullptr; 256 | } 257 | 258 | -------------------------------------------------------------------------------- /src/GitAutocomplete.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | extern struct PluginStartupInfo Info; 7 | 8 | extern std::wostream *logFile; 9 | 10 | const wchar_t *GetMsg(int MsgId); 11 | -------------------------------------------------------------------------------- /src/GitAutocomplete.rc: -------------------------------------------------------------------------------- 1 | #include "Version.hpp" 2 | 3 | 1 VERSIONINFO 4 | FILEVERSION PLUGIN_VERSION_MAJOR, PLUGIN_VERSION_MINOR, PLUGIN_VERSION_BUILD, 0 5 | PRODUCTVERSION PLUGIN_VERSION_MAJOR, PLUGIN_VERSION_MINOR, PLUGIN_VERSION_BUILD, 0 6 | FILEOS 4 7 | FILETYPE 2 8 | { 9 | BLOCK "StringFileInfo" 10 | { 11 | BLOCK "000004E4" 12 | { 13 | VALUE "CompanyName", PLUGIN_AUTHOR "\000\000" 14 | VALUE "FileDescription", PLUGIN_DESC "\000" 15 | VALUE "FileVersion", MAKEPRODUCTVERSION(PLUGIN_VERSION_MAJOR, PLUGIN_VERSION_MINOR, PLUGIN_VERSION_BUILD) "\000" 16 | VALUE "InternalName", PLUGIN_NAME "\000" 17 | VALUE "LegalCopyright", PLUGIN_COPYRIGHT "\000\000" 18 | VALUE "OriginalFilename", PLUGIN_FILENAME "\000" 19 | VALUE "ProductName", PLUGIN_NAME "\000" 20 | VALUE "ProductVersion", MAKEPRODUCTVERSION(PLUGIN_VERSION_MAJOR, PLUGIN_VERSION_MINOR, PLUGIN_VERSION_BUILD) "\000" 21 | } 22 | 23 | } 24 | 25 | BLOCK "VarFileInfo" 26 | { 27 | VALUE "Translation", 0, 0x4e4 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/GitAutocomplete.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GitAutocomplete", "GitAutocomplete.vcxproj", "{A0EEDB6F-87F0-459A-94FF-C683CE2CE8C1}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|Win32 = Debug|Win32 12 | Release|x64 = Release|x64 13 | Release|Win32 = Release|Win32 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {A0EEDB6F-87F0-459A-94FF-C683CE2CE8C1}.Debug|x64.ActiveCfg = Debug|x64 17 | {A0EEDB6F-87F0-459A-94FF-C683CE2CE8C1}.Debug|x64.Build.0 = Debug|x64 18 | {A0EEDB6F-87F0-459A-94FF-C683CE2CE8C1}.Debug|Win32.ActiveCfg = Debug|Win32 19 | {A0EEDB6F-87F0-459A-94FF-C683CE2CE8C1}.Debug|Win32.Build.0 = Debug|Win32 20 | {A0EEDB6F-87F0-459A-94FF-C683CE2CE8C1}.Release|x64.ActiveCfg = Release|x64 21 | {A0EEDB6F-87F0-459A-94FF-C683CE2CE8C1}.Release|x64.Build.0 = Release|x64 22 | {A0EEDB6F-87F0-459A-94FF-C683CE2CE8C1}.Release|Win32.ActiveCfg = Release|Win32 23 | {A0EEDB6F-87F0-459A-94FF-C683CE2CE8C1}.Release|Win32.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /src/GitAutocomplete.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Debug 7 | Win32 8 | 9 | 10 | Debug 11 | x64 12 | 13 | 14 | Release 15 | Win32 16 | 17 | 18 | Release 19 | x64 20 | 21 | 22 | 23 | 32 24 | 25 | 26 | 64 27 | 28 | 29 | GitAutocomplete 30 | {A0EEDB6F-87F0-459A-94FF-C683CE2CE8C1} 31 | DynamicLibrary 32 | plugins\$(ProjectName) 33 | $(ProjectName)_$(Bitness) 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | $(ProjectDir)..\libgit2\include 42 | 43 | 44 | $(ProjectDir)..\libgit2\build_$(Bitness)\$(Configuration) 45 | git2_$(Bitness).lib 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | Copy libgit2 54 | xcopy /y "$(ProjectDir)..\libgit2\build_$(Bitness)\$(Configuration)\git2_$(Bitness).dll" "$(OutDir)" 55 | 56 | 57 | 4530;4577;%(DisableSpecificWarnings) 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /src/GitAutocomplete.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/GitAutocompleteLng.hpp: -------------------------------------------------------------------------------- 1 | enum { 2 | MTitle, 3 | 4 | MShowDialog, 5 | MStripRemoteName, 6 | 7 | MOk, 8 | MCancel, 9 | }; 10 | -------------------------------------------------------------------------------- /src/GitAutocompleteW.vc.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | GetGlobalInfoW 3 | SetStartupInfoW 4 | GetPluginInfoW 5 | OpenW 6 | ExitFARW 7 | ConfigureW 8 | -------------------------------------------------------------------------------- /src/GitAutocomplete_en.hlf: -------------------------------------------------------------------------------- 1 | .Language=English,English (English) 2 | .PluginContents=GitAutocomplete 3 | .Options CtrlStartPosChar=^ 4 | 5 | @Contents 6 | $ #Git Autocomplete# 7 | This plugin completes names of Git branches and tags in the command line. 8 | 9 | Let's assume that you have branches: 10 | 11 | #master# 12 | #feature/inline-suggestions# 13 | #feature/suggestions-dialog# 14 | #origin/fix/help-typo# 15 | 16 | The plugin completes: 17 | 18 | #m# -> #master# 19 | #fe# -> #feature/# 20 | 21 | And even this (punctuation and upper case are treated like anchors): 22 | 23 | #f/h# -> #fix/help-typo# 24 | 25 | If there is no single completion (e.g. #feature/#) the plugin shows a dialog with the list of all possible references. Note that you could easily filter this list using ~standard command~@:MenuCmd@ #Ctrl-Alt-F#. 26 | 27 | 28 | See also: ~Configuring~@Config@ the plugin 29 | 30 | 31 | @Config 32 | $ #Configuring Git Autocomplete# 33 | There are following options: 34 | 35 | #Show dialog# ^Show dialog with the list of all possible references. 36 | #with references# Otherwise they are suggested right in the command line. 37 | 38 | #Complete remote references# ^Complete remote references (e.g. "origin/fix/help-typo") 39 | #by their short name# by their short name without remote name prefix (e.g. "fix/help-typo"). 40 | 41 | Note that you can override these options for the single plugin invocation via #Plugin.Call# function in ~macro command~@:KeyMacroSetting@: 42 | 43 | #Plugin.Call("89DF1D5B-F5BB-415B-993D-D34C5FFE049F", "Option 1", "Option 2", ...)# 44 | 45 | Option names (enabled/disabled variant): 46 | 47 | #SuggestionsDialog# / #InlineSuggestions# 48 | #ShortRemoteName# / #FullRemoteName# 49 | 50 | Also there is a handy option to iterate inline suggestions backwards: #ShowPreviousInlineSuggestion#. 51 | 52 | 53 | See also: ~Contents~@Contents@ 54 | -------------------------------------------------------------------------------- /src/GitAutocomplete_en.lng: -------------------------------------------------------------------------------- 1 | .Language=English,English 2 | 3 | "Git Autocomplete" 4 | 5 | "Show &dialog with references" 6 | "Complete &remote references by their short name" 7 | 8 | "&Ok" 9 | "Cancel" -------------------------------------------------------------------------------- /src/GitAutocomplete_ru.hlf: -------------------------------------------------------------------------------- 1 | .Language=Russian,Russian (Русский) 2 | .PluginContents=GitAutocomplete 3 | .Options CtrlStartPosChar=^ 4 | 5 | @Contents 6 | $ #Git Автодополнение# 7 | Этот плагин дополняет имена Git веток и тегов в командной строке. 8 | 9 | Предположим у вас есть ветки: 10 | 11 | #master# 12 | #feature/inline-suggestions# 13 | #feature/suggestions-dialog# 14 | #origin/fix/help-typo# 15 | 16 | Плагин дополнит: 17 | 18 | #m# -> #master# 19 | #fe# -> #feature/# 20 | 21 | И даже так (пунктуация и прописные буквы играют роль якорей): 22 | 23 | #f/h# -> #fix/help-typo# 24 | 25 | Если не существует однозначного дополнения (например, #feature/#), то плагин показывает диалог со списком всех возможных ссылок. Заметьте, что вы можете легко фильтровать этот список с помощью ~стандартной команды~@:MenuCmd@ #Ctrl-Alt-F#. 26 | 27 | 28 | См. также: ~Настройка плагина~@Config@ 29 | 30 | 31 | @Config 32 | $ #Настройка Git Автодополнение# 33 | Присутствуют следующие опции: 34 | 35 | #Показывать диалог# ^Показывать диалог со списком всех возможных ссылок. 36 | #со ссылками# Иначе они подставляются прямо в командной строке. 37 | 38 | #Дополнять имена удаленных ссылок# ^Дополнять имена удаленных ссылок (например, "origin/fix/help-typo") 39 | #по их короткому имени# по их короткому имени без имени удаленного сервера (например, "fix/help-typo"). 40 | 41 | Эти опции можно переопределять для одиночного запуска плагина с помощью функции #Plugin.Call# в ~макрокоманде~@:KeyMacroSetting@: 42 | 43 | #Plugin.Call("89DF1D5B-F5BB-415B-993D-D34C5FFE049F", "Опция 1", "Опция 2", ...)# 44 | 45 | Имена опций (включенный/выключенный вариант): 46 | 47 | #SuggestionsDialog# / #InlineSuggestions# 48 | #ShortRemoteName# / #FullRemoteName# 49 | 50 | Также имеется удобная опция для итерации ссылок в командной строке в обратном порядке: #ShowPreviousInlineSuggestion#. 51 | 52 | 53 | См. также: ~Содержание~@Contents@ 54 | -------------------------------------------------------------------------------- /src/GitAutocomplete_ru.lng: -------------------------------------------------------------------------------- 1 | .Language=Russian,Russian (Русский) 2 | 3 | "Git Автодополнение" 4 | 5 | "Показывать &диалог со ссылками" 6 | "Дополнять имена &удаленных ссылок по их короткому имени" 7 | 8 | "&OK" 9 | "Отмена" 10 | -------------------------------------------------------------------------------- /src/Guid.hpp: -------------------------------------------------------------------------------- 1 | // {89DF1D5B-F5BB-415B-993D-D34C5FFE049F} 2 | DEFINE_GUID(MainGuid, 0x89df1d5b, 0xf5bb, 0x415b, 0x99, 0x3d, 0xd3, 0x4c, 0x5f, 0xfe, 0x04, 0x9f); 3 | 4 | // {39518AEC-DCC1-4E98-8453-6BD80F362002} 5 | DEFINE_GUID(MenuGuid, 0x39518aec, 0xdcc1, 0x4e98, 0x84, 0x53, 0x6b, 0xd8, 0x0f, 0x36, 0x20, 0x02); 6 | 7 | // {7ED6B1A4-9100-439E-BFBE-56322171459C} 8 | DEFINE_GUID(ConfigMenuGuid, 0x7ed6b1a4, 0x9100, 0x439e, 0xbf, 0xbe, 0x56, 0x32, 0x21, 0x71, 0x45, 0x9c); 9 | 10 | // {F8FD2D64-0D35-481D-BD85-06F5315B9935} 11 | DEFINE_GUID(ConfigDialogGuid, 0xf8fd2d64, 0x0d35, 0x481d, 0xbd, 0x85, 0x06, 0xf5, 0x31, 0x5b, 0x99, 0x35); 12 | 13 | // {5390359D-C885-4531-8565-379E59754F13} 14 | DEFINE_GUID(RefsDialogGuid, 0x5390359d, 0xc885, 0x4531, 0x85, 0x65, 0x37, 0x9e, 0x59, 0x75, 0x4f, 0x13); -------------------------------------------------------------------------------- /src/Logic.cpp: -------------------------------------------------------------------------------- 1 | #include "Logic.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "GitAutocomplete.hpp" 9 | #include "Utils.hpp" 10 | #include "Trie.hpp" 11 | #include "RefsDialog.h" 12 | 13 | using namespace std; 14 | 15 | git_repository* OpenGitRepo(wstring dir) { 16 | string dirForGit = w2mb(dir); 17 | if (dirForGit.length() == 0) { 18 | *logFile << "Bad dir for Git: " << dir.c_str() << endl; 19 | return nullptr; 20 | } 21 | 22 | git_repository *repo; 23 | int error = git_repository_open_ext(&repo, dirForGit.c_str(), 0, nullptr); 24 | if (error < 0) { 25 | const git_error *e = giterr_last(); 26 | *logFile << "libgit2 error " << error << "/" << e->klass << ": " << e->message << endl; 27 | return nullptr; 28 | } 29 | 30 | return repo; 31 | } 32 | 33 | static void FilterReferences(const Options &options, const char *ref, function filterOneRef) { 34 | const char *prefixes[] = { "refs/heads/", "refs/tags/" }; 35 | for (int i = 0; i < sizeof(prefixes) / sizeof(prefixes[0]); ++i) { 36 | if (StartsWith(ref, prefixes[i])) { 37 | filterOneRef(ref + strlen(prefixes[i])); 38 | return; 39 | } 40 | } 41 | const char *remotePrefix = "refs/remotes/"; 42 | if (StartsWith(ref, remotePrefix)) { 43 | const char *remoteRef = ref + strlen(remotePrefix); 44 | filterOneRef(remoteRef); 45 | 46 | if (options.stripRemoteName) { 47 | const char *slashPtr = strchr(remoteRef, '/'); 48 | assert(slashPtr != nullptr); 49 | filterOneRef(slashPtr + 1); 50 | } 51 | return; 52 | } 53 | // there are also "refs/stash", "refs/notes" 54 | *logFile << "Ignored ref = " << ref << endl; 55 | } 56 | 57 | static void ObtainSuitableRefsBy(const Options &options, git_repository *repo, vector &suitableRefs, function isSuitableRef) { 58 | git_reference_iterator *iter = NULL; 59 | int error = git_reference_iterator_new(&iter, repo); 60 | 61 | git_reference *ref; 62 | while (!(error = git_reference_next(&ref, iter))) { 63 | FilterReferences(options, git_reference_name(ref), [&suitableRefs, isSuitableRef](const char *refName) { 64 | if (isSuitableRef(refName)) { 65 | suitableRefs.push_back(string(refName)); 66 | } 67 | }); 68 | } 69 | assert(error == GIT_ITEROVER); 70 | } 71 | 72 | static void ObtainSuitableRefsByStrictPrefix(const Options &options, git_repository *repo, string currentPrefix, vector &suitableRefs) { 73 | ObtainSuitableRefsBy(options, repo, suitableRefs, [¤tPrefix](const char *refName) -> bool { 74 | return StartsWith(refName, currentPrefix.c_str()); 75 | }); 76 | } 77 | 78 | /** Returns true for pairs like "cypok/arm/master" with prefix "cy/a/m". */ 79 | static bool RefMayBeEncodedByPartialPrefix(const char *ref, const char *prefix) { 80 | const char *p = prefix; 81 | const char *r = ref; 82 | for (;;) { 83 | if (*p == '\0') { 84 | return true; 85 | } else if (ispunct(*p) || isupper(*p)) { 86 | r = strchr(r, *p); 87 | if (r == nullptr) { 88 | return false; 89 | } 90 | } else { 91 | if (*p != *r) { 92 | return false; 93 | } 94 | } 95 | 96 | p++; 97 | r++; 98 | } 99 | } 100 | 101 | static void ObtainSuitableRefsByPartialPrefixes(const Options &options, git_repository *repo, string currentPrefix, vector &suitableRefs) { 102 | ObtainSuitableRefsBy(options, repo, suitableRefs, [¤tPrefix](const char *refName) -> bool { 103 | return RefMayBeEncodedByPartialPrefix(refName, currentPrefix.c_str()); 104 | }); 105 | } 106 | 107 | static string FindCommonPrefix(vector &suitableRefs) { 108 | Trie *trie = trie_create(); 109 | for_each(suitableRefs.begin(), suitableRefs.end(), [trie](string s) { 110 | trie_add(trie, s); 111 | }); 112 | string maxCommonPrefix = trie_get_common_prefix(trie); 113 | trie_free(trie); 114 | return maxCommonPrefix; 115 | } 116 | 117 | static string ObtainNextSuggestedSuffix(bool forwardSearch, string currentPrefix, string currentSuffix, vector &suitableRefs) { 118 | size_t size = suitableRefs.size(); 119 | size_t idx = distance(suitableRefs.begin(), find(suitableRefs.begin(), suitableRefs.end(), currentPrefix + currentSuffix)); 120 | if (idx == size) { 121 | idx = forwardSearch ? 0 : (size - 1); 122 | } else { 123 | idx = (idx + (forwardSearch ? 1 : -1) + size) % size; 124 | } 125 | return DropPrefix(suitableRefs[idx], currentPrefix); 126 | } 127 | 128 | void TransformCmdLine(const Options &options, CmdLine &cmdLine, git_repository *repo) { 129 | string currentPrefix = w2mb(GetUserPrefix(cmdLine)); 130 | *logFile << "User prefix = \"" << currentPrefix.c_str() << "\"" << endl; 131 | 132 | vector suitableRefs; 133 | ObtainSuitableRefsByStrictPrefix(options, repo, currentPrefix, suitableRefs); 134 | 135 | if (suitableRefs.empty()) { 136 | ObtainSuitableRefsByPartialPrefixes(options, repo, currentPrefix, suitableRefs); 137 | } 138 | 139 | if (suitableRefs.empty()) { 140 | *logFile << "No suitable refs" << endl; 141 | return; 142 | } 143 | 144 | sort(suitableRefs.begin(), suitableRefs.end()); 145 | suitableRefs.erase(unique(suitableRefs.begin(), suitableRefs.end()), suitableRefs.end()); 146 | // TODO 147 | //if (!options.sortByName) { 148 | // *logFile << "FIXME: sorting by time is not implemented yet" << endl; 149 | //} 150 | 151 | for_each(suitableRefs.begin(), suitableRefs.end(), [](string s) { 152 | *logFile << "Suitable ref: " << s.c_str() << endl; 153 | }); 154 | 155 | string newPrefix = FindCommonPrefix(suitableRefs); 156 | *logFile << "Common prefix: " << newPrefix.c_str() << endl; 157 | 158 | if (newPrefix != currentPrefix) { 159 | ReplaceUserPrefix(cmdLine, mb2w(newPrefix)); 160 | 161 | } else { 162 | string currentSuffix = w2mb(GetSuggestedSuffix(cmdLine)); 163 | *logFile << "currentSuffix = \"" << currentSuffix.c_str() << "\"" << endl; 164 | 165 | if (options.showDialog) { 166 | // Yes, we show dialog even if there is only one suitable ref. 167 | *logFile << "Showing dialog..." << endl; 168 | string selectedRef = ShowRefsDialog(suitableRefs, currentPrefix + currentSuffix); 169 | *logFile << "Dialog closed, selectedRef = \"" << selectedRef.c_str() << "\"" << endl; 170 | if (!selectedRef.empty()) { 171 | // Use case: we iterate over branches with suggested suffixes 172 | // but then we understand that we do not remember branch name 173 | // and want to see them as dialog (via extra hotkey). 174 | // In this case we should drop last suggested suffix. 175 | ReplaceSuggestedSuffix(cmdLine, wstring(L"")); 176 | 177 | ReplaceUserPrefix(cmdLine, mb2w(selectedRef)); 178 | } 179 | 180 | } else { 181 | string newSuffix = ObtainNextSuggestedSuffix(options.suggestNextSuffix, currentPrefix, currentSuffix, suitableRefs); 182 | *logFile << "nextSuffx = \"" << newSuffix.c_str() << "\"" << endl; 183 | ReplaceSuggestedSuffix(cmdLine, mb2w(newSuffix)); 184 | } 185 | } 186 | } 187 | 188 | #ifdef DEBUG 189 | void LogicTest() { 190 | assert(RefMayBeEncodedByPartialPrefix("svn/trunk", "s/t")); 191 | assert(RefMayBeEncodedByPartialPrefix("foo/bar/qux", "f/b")); 192 | assert(RefMayBeEncodedByPartialPrefix("foo/bar/qux", "f/b/q")); 193 | assert(RefMayBeEncodedByPartialPrefix("foo/bar/qux", "f/ba/q")); 194 | assert(RefMayBeEncodedByPartialPrefix("foo/bar/qux", "f/bar/q")); 195 | assert(RefMayBeEncodedByPartialPrefix("foo/bar/qux", "foo/bar/qux")); 196 | assert(RefMayBeEncodedByPartialPrefix("foo/bar-qux", "f/b-q")); 197 | assert(RefMayBeEncodedByPartialPrefix("foo/barQux", "f/bQ")); 198 | 199 | assert(!RefMayBeEncodedByPartialPrefix("foo/bar/qux", "fo/baz/q")); 200 | assert(!RefMayBeEncodedByPartialPrefix("foo", "f/b")); 201 | assert(!RefMayBeEncodedByPartialPrefix("foo/", "f/b")); 202 | assert(!RefMayBeEncodedByPartialPrefix("foo/b", "f/bar")); 203 | assert(!RefMayBeEncodedByPartialPrefix("foo/bar/qux", "f/q")); 204 | assert(!RefMayBeEncodedByPartialPrefix("foo/bar-qux", "f/brq")); 205 | 206 | { 207 | vector suitableRefs = { string("abcfoo"), string("abcxyz"), string("abcbar") }; 208 | assert(string("bar") == ObtainNextSuggestedSuffix(true, string("abc"), string("xyz"), suitableRefs)); 209 | assert(string("foo") == ObtainNextSuggestedSuffix(true, string("abc"), string("bar"), suitableRefs)); 210 | assert(string("foo") == ObtainNextSuggestedSuffix(true, string("abc"), string(""), suitableRefs)); 211 | assert(string("foo") == ObtainNextSuggestedSuffix(false, string("abc"), string("xyz"), suitableRefs)); 212 | assert(string("bar") == ObtainNextSuggestedSuffix(false, string("abc"), string("foo"), suitableRefs)); 213 | assert(string("bar") == ObtainNextSuggestedSuffix(false, string("abc"), string(""), suitableRefs)); 214 | } 215 | { 216 | vector suitableRefs = { string("abc"), string("abcxyz"), string("abcbar") }; 217 | assert(string("") == ObtainNextSuggestedSuffix(true, string("abc"), string("bar"), suitableRefs)); 218 | assert(string("xyz") == ObtainNextSuggestedSuffix(true, string("abc"), string(""), suitableRefs)); 219 | assert(string("bar") == ObtainNextSuggestedSuffix(false, string("abc"), string(""), suitableRefs)); 220 | assert(string("") == ObtainNextSuggestedSuffix(false, string("abc"), string("xyz"), suitableRefs)); 221 | } 222 | } 223 | #endif 224 | -------------------------------------------------------------------------------- /src/Logic.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "CmdLine.hpp" 7 | 8 | typedef struct tOptions { 9 | int showDialog; 10 | int stripRemoteName; 11 | int suggestNextSuffix; 12 | } Options; 13 | 14 | git_repository* OpenGitRepo(std::wstring dir); 15 | 16 | void TransformCmdLine(const Options &options, CmdLine &cmdLine, git_repository *repo); 17 | 18 | #ifdef DEBUG 19 | void LogicTest(); 20 | #endif 21 | -------------------------------------------------------------------------------- /src/RefsDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "RefsDialog.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "GitAutocomplete.hpp" 7 | #include "Guid.hpp" 8 | #include "GitAutocompleteLng.hpp" 9 | #include "Utils.hpp" 10 | 11 | using namespace std; 12 | 13 | static size_t MaxLength(const vector &list) { 14 | return (*max_element(list.begin(), list.end(), [](string x, string y) -> bool { 15 | return x.length() < y.length(); 16 | })).length(); 17 | } 18 | 19 | static SMALL_RECT GetFarRect() { 20 | SMALL_RECT farRect; 21 | Info.AdvControl(&MainGuid, ACTL_GETFARRECT, 0, &farRect); 22 | *logFile << "Far rect (l, t, r, b) = (" << farRect.Left << ", " << farRect.Top << ", " << farRect.Right << ", " << farRect.Bottom << ")" << endl; 23 | return farRect; 24 | } 25 | 26 | static FarListItem * InitializeListItems(const vector &list, const string &initiallySelectedItem) { 27 | size_t size = list.size(); 28 | FarListItem *listItems = new FarListItem[size]; 29 | size_t initiallySelected = 0; 30 | for (size_t i = 0; i < size; ++i) { 31 | wstring wstr = mb2w(list[i]); 32 | listItems[i].Text = (const wchar_t *)wcsdup(wstr.c_str()); 33 | listItems[i].Flags = LIF_NONE; 34 | if (list[i] == initiallySelectedItem) { 35 | initiallySelected = i; 36 | } 37 | } 38 | listItems[initiallySelected].Flags |= LIF_SELECTED; 39 | return listItems; 40 | } 41 | 42 | static void FreeListItems(FarListItem *listItems, size_t size) { 43 | for (size_t i = 0; i < size; ++i) { 44 | free((wchar_t*)listItems[i].Text); 45 | } 46 | delete[] listItems; 47 | } 48 | 49 | typedef struct tGeometry { 50 | int left; 51 | int top; 52 | size_t width; 53 | size_t height; 54 | } Geometry; 55 | 56 | static pair CalculateListBoxAndDialogGeometry(size_t maxLineLength, size_t linesCount) { 57 | // Example of list geometry: 58 | // (left padding is added inside of ListBox automatically) 59 | // 60 | // +-- Title --+ 61 | // |..bar ..| 62 | // |..feature..| 63 | // +-----------+ 64 | 65 | size_t listBoxWidth = maxLineLength + 6; 66 | size_t listBoxHeight = linesCount + 2; 67 | 68 | // Example of dialog geometry: 69 | // 70 | // .......... 71 | // ..+----+.. 72 | // ..| |.. 73 | // ..+----+.. 74 | // .......... 75 | 76 | size_t dialogWidth = listBoxWidth + 4; 77 | size_t dialogHeight = listBoxHeight + 2; 78 | 79 | // Some pretty double padding for the maximum dialog: 80 | SMALL_RECT farRect = GetFarRect(); 81 | size_t dialogMaxWidth = (farRect.Right - farRect.Left + 1) - 8; 82 | size_t dialogMaxHeight = (farRect.Bottom - farRect.Top + 1) - 4; 83 | 84 | if (dialogWidth > dialogMaxWidth) { 85 | size_t delta = dialogWidth - dialogMaxWidth; 86 | dialogWidth -= delta; 87 | listBoxWidth -= delta; 88 | } 89 | if (dialogHeight > dialogMaxHeight) { 90 | size_t delta = dialogHeight - dialogMaxHeight; 91 | dialogHeight -= delta; 92 | listBoxHeight -= delta; 93 | } 94 | 95 | Geometry list = {2, 1, listBoxWidth, listBoxHeight}; 96 | Geometry dialog = {-1, -1, dialogWidth, dialogHeight}; // auto centering 97 | return pair(list, dialog); 98 | } 99 | 100 | static int ShowListAndGetSelected(const vector &list, const string &initiallySelectedItem) { 101 | FarList listDesc; 102 | listDesc.StructSize = sizeof(listDesc); 103 | listDesc.Items = InitializeListItems(list, initiallySelectedItem); 104 | listDesc.ItemsNumber = list.size(); 105 | 106 | FarDialogItem listBox; 107 | memset(&listBox, 0, sizeof(listBox)); 108 | listBox.Type = DI_LISTBOX; 109 | listBox.Data = GetMsg(MTitle); 110 | listBox.Flags = DIF_NONE; 111 | listBox.ListItems = &listDesc; 112 | 113 | auto listAndDialogGeometry = CalculateListBoxAndDialogGeometry(MaxLength(list), list.size()); 114 | Geometry listGeometry = listAndDialogGeometry.first; 115 | Geometry dialogGeometry = listAndDialogGeometry.second; 116 | 117 | listBox.X1 = listGeometry.left; 118 | listBox.Y1 = listGeometry.top; 119 | listBox.X2 = listGeometry.left + listGeometry.width - 1; 120 | listBox.Y2 = listGeometry.top + listGeometry.height - 1; 121 | 122 | FarDialogItem *items = &listBox; 123 | size_t itemsCount = 1; 124 | int listBoxID = 0; 125 | 126 | assert(dialogGeometry.left == -1 && dialogGeometry.top == -1); // auto centering 127 | HANDLE dialog = Info.DialogInit(&MainGuid, &RefsDialogGuid, -1, -1, dialogGeometry.width, dialogGeometry.height, L"Contents", items, itemsCount, 0, FDLG_KEEPCONSOLETITLE, nullptr, nullptr); 128 | 129 | int runResult = (int)Info.DialogRun(dialog); 130 | 131 | int selected; 132 | if (runResult != -1) { 133 | selected = (int)Info.SendDlgMessage(dialog, DM_LISTGETCURPOS, listBoxID, nullptr); 134 | assert(0 <= selected && selected < (int)listBox.ListItems->ItemsNumber); 135 | } else { 136 | selected = -1; 137 | } 138 | 139 | Info.DialogFree(dialog); 140 | FreeListItems(listDesc.Items, listDesc.ItemsNumber); 141 | 142 | return selected; 143 | } 144 | 145 | string ShowRefsDialog(const vector &suitableRefs, const string &initiallySelectedRef) { 146 | assert(!suitableRefs.empty()); 147 | 148 | int selected = ShowListAndGetSelected(suitableRefs, initiallySelectedRef); 149 | if (selected >= 0) { 150 | *logFile << "Dialog succeeded. Selected = " << selected << endl; 151 | assert(0 <= selected && selected < (int)suitableRefs.size()); 152 | return suitableRefs[selected]; 153 | } else { 154 | *logFile << "Dialog failed." << endl; 155 | return string(""); 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /src/RefsDialog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | std::string ShowRefsDialog(const std::vector &suitableRefs, const std::string &initiallySelectedRef); -------------------------------------------------------------------------------- /src/Trie.cpp: -------------------------------------------------------------------------------- 1 | #include "Trie.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | typedef struct tNode { 11 | struct tNode *children[UCHAR_MAX + 1]; 12 | size_t children_count; 13 | bool leaf; 14 | } Node; 15 | 16 | struct tTrie { 17 | Node *root; 18 | }; 19 | 20 | static Node* node_create() { 21 | Node *node = (Node*)malloc(sizeof(Node)); 22 | assert(node != nullptr); 23 | node->children_count = 0; 24 | node->leaf = false; 25 | memset(node->children, 0, sizeof(node->children)); 26 | return node; 27 | } 28 | 29 | Trie* trie_create() { 30 | Trie *trie = (Trie*)malloc(sizeof(Trie)); 31 | assert(trie != nullptr); 32 | trie->root = node_create(); 33 | return trie; 34 | } 35 | 36 | static void node_free(Node *node) { 37 | for (int i = 0; i <= UCHAR_MAX; i++) { 38 | Node *child = node->children[i]; 39 | if (child != nullptr) { 40 | node_free(child); 41 | } 42 | } 43 | free(node); 44 | } 45 | 46 | void trie_free(Trie *trie) { 47 | node_free(trie->root); 48 | free(trie); 49 | } 50 | 51 | static void trie_add(Node *node, const char *str) { 52 | unsigned char ch = (unsigned char)str[0]; 53 | if (ch == '\0') { 54 | node->leaf = true; 55 | return; 56 | } 57 | 58 | Node **child = &(node->children[ch]); 59 | if (*child == nullptr) { 60 | *child = node_create(); 61 | node->children_count++; 62 | } 63 | trie_add(*child, str + 1); 64 | } 65 | 66 | void trie_add(Trie* trie, string str) { 67 | trie_add(trie->root, str.c_str()); 68 | } 69 | 70 | void build_common_prefix(Node *node, string &prefix) { 71 | if (!node->leaf && node->children_count == 1) { 72 | int single_child = -1; 73 | for (int i = 0; i <= UCHAR_MAX; i++) { 74 | if (node->children[i] != nullptr) { 75 | single_child = i; 76 | break; 77 | } 78 | } 79 | assert(single_child != -1); 80 | prefix.push_back((char)single_child); 81 | build_common_prefix(node->children[single_child], prefix); 82 | } 83 | } 84 | 85 | string trie_get_common_prefix(Trie* trie) { 86 | string prefix(""); 87 | build_common_prefix(trie->root, prefix); 88 | return prefix; 89 | } 90 | 91 | #ifdef DEBUG 92 | void trie_test() { 93 | Trie *trie = trie_create(); 94 | assert(string("") == trie_get_common_prefix(trie)); 95 | 96 | trie_add(trie, string("abcdef")); 97 | trie_add(trie, string("abcdef")); 98 | assert(string("abcdef") == trie_get_common_prefix(trie)); 99 | 100 | trie_add(trie, string("abcxyz")); 101 | assert(string("abc") == trie_get_common_prefix(trie)); 102 | 103 | trie_add(trie, string("ab")); 104 | assert(string("ab") == trie_get_common_prefix(trie)); 105 | 106 | trie_free(trie); 107 | } 108 | #endif 109 | -------------------------------------------------------------------------------- /src/Trie.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef struct tTrie Trie; 6 | 7 | Trie* trie_create(); 8 | 9 | void trie_free(Trie *trie); 10 | 11 | void trie_add(Trie* trie, std::string str); 12 | 13 | std::string trie_get_common_prefix(Trie* trie); 14 | 15 | #ifdef DEBUG 16 | void trie_test(); 17 | #endif 18 | -------------------------------------------------------------------------------- /src/Utils.cpp: -------------------------------------------------------------------------------- 1 | #include "Utils.hpp" 2 | 3 | #include 4 | 5 | #include "GitAutocomplete.hpp" 6 | 7 | using namespace std; 8 | 9 | string w2mb(wstring wstr) { 10 | size_t mbstrSize = wstr.length() * 2 + 1; 11 | char *mbstr = (char*)malloc(mbstrSize); // this is enough for all ;) FIXME 12 | bool convertedOk = (wcstombs(mbstr, wstr.c_str(), mbstrSize) != (size_t)-1); 13 | if (!convertedOk) { 14 | *logFile << "Cannot convert some string to multi-byte string :(" << endl; 15 | return string(""); 16 | } 17 | string result = string(mbstr); 18 | free(mbstr); 19 | return result; 20 | } 21 | 22 | wstring mb2w(string str) { 23 | return wstring(str.begin(), str.end()); 24 | } 25 | 26 | bool StartsWith(const char *str, const char *prefix) { 27 | while (*prefix != '\0') { 28 | if (*(str++) != *(prefix++)) { 29 | return false; 30 | } 31 | } 32 | return true; 33 | } 34 | 35 | bool StartsWith(const string &str, const string &prefix) { 36 | return StartsWith(str.c_str(), prefix.c_str()); 37 | } 38 | 39 | string DropPrefix(const string &str, const string &prefix) { 40 | assert(StartsWith(str, prefix)); 41 | return str.substr(prefix.length()); 42 | } 43 | 44 | #ifdef DEBUG 45 | void UtilsTest() { 46 | assert(StartsWith("abcdef", "abc")); 47 | assert(StartsWith("abc", "abc")); 48 | assert(StartsWith("abc", "")); 49 | 50 | assert(!StartsWith("abc", "abcdef")); 51 | assert(!StartsWith("", "abc")); 52 | assert(!StartsWith("xabc", "abc")); 53 | 54 | assert(string("def") == DropPrefix(string("abcdef"), string("abc"))); 55 | assert(string("") == DropPrefix(string("abc"), string("abc"))); 56 | 57 | assert(wstring(L"Excelsior loves Far") == mb2w(string("Excelsior loves Far"))); 58 | assert(string("") == w2mb(wstring(L"Excelsior ❤ Far"))); 59 | } 60 | #endif 61 | -------------------------------------------------------------------------------- /src/Utils.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | std::string w2mb(std::wstring wstr); 6 | 7 | std::wstring mb2w(std::string str); 8 | 9 | bool StartsWith(const char *str, const char *prefix); 10 | 11 | bool StartsWith(const std::string &str, const std::string &prefix); 12 | 13 | std::string DropPrefix(const std::string &str, const std::string &prefix); 14 | 15 | #ifdef DEBUG 16 | void UtilsTest(); 17 | #endif 18 | -------------------------------------------------------------------------------- /src/Version.hpp: -------------------------------------------------------------------------------- 1 | #include "farversion.hpp" 2 | 3 | #define PLUGIN_BUILD 1 4 | #define PLUGIN_DESC L"Git Autocomplete Plugin for Far Manager" 5 | #define PLUGIN_NAME L"GitAutocomplete" 6 | #define PLUGIN_FILENAME L"GitAutocomplete.dll" 7 | #define PLUGIN_COPYRIGHT L"Copyright (c) 2016 Excelsior LLC" 8 | #define PLUGIN_AUTHOR L"Vladimir Parfinenko & Ivan Kireev, " PLUGIN_COPYRIGHT 9 | #define PLUGIN_VERSION_MAJOR 1 10 | #define PLUGIN_VERSION_MINOR 2 11 | #define PLUGIN_VERSION_BUILD 1 12 | #define PLUGIN_VERSION MAKEFARVERSION(PLUGIN_VERSION_MAJOR,PLUGIN_VERSION_MINOR,0,PLUGIN_VERSION_BUILD,VS_RELEASE) 13 | 14 | // We do not use any very special API. 15 | #define PLUGIN_MIN_FAR_VERSION MAKEFARVERSION(3,0,0,1,VS_RELEASE) 16 | --------------------------------------------------------------------------------