Merge pull request #2212 from unxed/ctrl_yo
[far2l.git] / incsrch / incsrch.h
blob328f437bb53b804cc1e88942aac931a4eb46f3eb
1 /*
2 FAR manager incremental search plugin, search as you type in editor.
3 Copyright (C) 1999-2019, Stanislav V. Mekhanoshin
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>.
18 #pragma once
20 #ifdef _MSC_VER
21 #pragma warning(disable : 4514)
22 #pragma warning(push, 1)
23 #endif
24 #include "minwin.h"
25 #include <string.h>
26 #include <limits.h>
27 #include <stddef.h>
28 #if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__DragonFly__)
29 #include <malloc.h>
30 #endif
31 #include <stdlib.h>
33 #if defined(WINPORT_DIRECT)
35 static inline wchar_t __cdecl Upper(wchar_t Ch)
37 WINPORT(CharUpperBuff)(&Ch, 1);
38 return Ch;
41 #define __int64 __int64_t
42 #define _MAX_PATH MAX_PATH
43 #define _tstrcpy(a, b) lstrcpy((a), (b))
44 #define _tstrlen(a) lstrlen((a))
45 #define _tstrnlen(a, n) lstrnlen((a), (n))
46 #else
47 #include <tchar.h>
48 #define _tstrcpy(a, b) strcpy((a), (b))
49 #define _tstrlen(a) strlen((a))
50 #define _tstrnlen(a, n) sstrnlen((a), (n))
51 #if !defined(INT_PTR)
52 #define INT_PTR int
53 #endif
54 #endif
56 #include "farplug-wide.h"
57 #include "farcolor.h"
58 #ifdef _MSC_VER
59 #pragma warning(pop)
60 #endif
61 #include "srchlng.h"
63 #define MAX_STR 80
64 #define TITLE_LEN 26
65 #define TITLE_PREFIX_STR _T("^: ")
66 #define TITLE_PREFIX_STR_DWORD 0x203A5E
67 #define TITLE_PREFIX_LEN 3
68 #define PREVIEW_EVENTS MAX_STR
70 #if defined(__WATCOMC__)
71 #define __plugin __declspec(dllexport)
72 #elif defined(WINPORT_DIRECT)
73 #define __plugin SHAREDSYMBOL
74 #else
75 #define __plugin
76 #endif
78 #if !defined(WINPORT_DIRECT) && !defined(EXP_NAME)
79 #define EXP_NAME(x) x
80 #endif
82 #ifdef __cplusplus
83 extern "C" {
84 #endif
86 extern INT_PTR ModuleNumber;
87 extern FARAPIMENU apiMenu;
88 extern FARAPIGETMSG apiGetMsg;
89 extern FARAPITEXT apiText;
90 extern FARAPIEDITORCONTROL apiEditorControl;
91 #ifdef VIEWVER_SUPPORT
92 extern FARAPIVIEWERCONTROL apiViewerControl;
93 extern int iViewerStatusColor;
94 #endif
95 #if defined(WINPORT_DIRECT)
96 extern FARAPIDIALOGINIT apiDialogInit;
97 extern FARAPIDIALOGRUN apiDialogRun;
98 extern FARAPIDIALOGFREE apiDialogFree;
99 extern FARAPISENDDLGMESSAGE apiSendDlgMessage;
100 extern FARSTDSNPRINTF apiSnprintf;
101 #else
102 extern FARAPIDIALOG apiDialog;
103 extern FARAPICHARTABLE apiCharTable;
104 #endif
106 #define GetMsg(MsgId) apiGetMsg(ModuleNumber, MsgId)
108 extern struct EditorInfo ei;
109 extern struct EditorConvertText ect;
110 extern struct EditorSetPosition esp;
111 extern struct EditorGetString egs;
113 extern TCHAR sStr[MAX_STR];
114 extern int nLen;
116 extern void SearchLoopEditor(void);
117 extern void SearchLoopViewer(void);
118 extern BOOL WaitInput(BOOL Infinite);
120 #define DIFT_MSGNUM 0x80000000
122 typedef struct _DialogTemplateItem
124 unsigned char Type;
125 signed char X1;
126 signed char Y1;
127 signed char Selected;
128 unsigned int Flags;
129 INT_PTR Data; // Message number or pointer to string
130 } DialogTemplateItem;
132 extern int DialogFromTemplate(const TCHAR *sTitle, const DialogTemplateItem *aTplItems,
133 struct FarDialogItem *aDialogItems, int nItemsNumber, TCHAR *sHelpTopic, int nFocus,
134 int nDefaultButton);
136 extern BOOL CollectEvents(void);
137 extern void ShowTitle(int OpenFrom);
138 extern void SelectFound(BOOL bRedraw);
139 extern void StatusMessage(int Index);
140 extern void SetPosition(int nLine, int nPos, int nLeftPos);
141 extern void PositionToView(int nLine, int nStartPos);
142 extern void PasteSearchText(void);
144 #define KC_CHAR 1
145 #define KC_BACK 2
146 #define KC_NEXT 4
147 #define KC_PREV 8
148 #define KC_HELP 16
149 #define KC_CLEARMSG 32
150 #define KC_FAILKILL 128
152 typedef struct _KbdCommand
154 unsigned char Flags;
155 unsigned char AsciiChar;
156 } KbdCommand;
158 extern KbdCommand aEvents[PREVIEW_EVENTS];
159 extern int nEvents;
161 extern BOOL bEscape;
162 extern BOOL bTermEvent;
163 extern INPUT_RECORD Event;
164 #if !defined(WINPORT_DIRECT)
165 extern HANDLE hInputHandle;
166 #endif
167 extern BOOL bNotFound;
169 /* config options */
170 extern BOOL bCaseSensitive;
171 extern BOOL bKeepSelection;
172 extern BOOL bBeepOnMismatch;
173 extern BOOL bRestartEOF;
174 extern BOOL bUseSelection;
175 extern BOOL bAutoNext;
176 extern BOOL bBSunroll;
178 extern BOOL bThisUseSelection;
179 extern BOOL bThisAutoNext;
180 extern BOOL bStopOnFound;
181 extern BOOL bReverse;
183 #ifdef __cplusplus
185 #endif
187 #include "loc.h"
188 #include "misc.h"
190 #ifdef _MSC_VER
191 #define _heapshrink _heapmin
192 #endif