forked from dail8859/LuaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotepad.lua
More file actions
357 lines (286 loc) · 11.9 KB
/
Copy pathNotepad.lua
File metadata and controls
357 lines (286 loc) · 11.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
--- Notepad++ wrapper.
-- Provides access to the Notepad++ application. Most of the API messages and notifications have been made available, but more can be made available as needed.
--
-- The global instance `npp` is used for application access.
--
-- @classmod Notepad
--- Activates the specified document.
-- @function ActivateDoc
-- @tparam int view either `MAIN_VIEW` or `SUB_VIEW`
-- @tparam int index2Activate index of the view to activate
--- Disable checking for auto updates.
-- @function DisableAutoUpdate
--- View another docked tab.
-- @function DmmViewOtherTab
-- @tparam string name name of the docked tab (e.g. "Function List")
--- Opens a document.
-- @function DoOpen
-- @tparam string file name
-- @treturn bool `true` if successful, else `false`
--- Enable or disable the file extension column in the doc switcher.
-- @function DocSwitcherDisableColumn
-- @tparam bool toShow whether to show or hide the column
--- Gets the BufferID located at the given position.
-- @function GetBufferIDFromPos
-- @tparam int position position of document
-- @tparam int view either `MAIN_VIEW` or `SUB_VIEW`
-- @treturn int BufferID or 0 if invalid
--- Gets the current directory of the document.
-- @function GetCurrentDirectory
-- @treturn string current directory
--- Gets the current document index within the view.
-- @function GetCurrentDocIndex
-- @tparam int view either `MAIN_VIEW` or `SUB_VIEW`
-- @treturn int index of the current document. -1 if the requested view is not visible.
--- Selects and returns the word at the cursor's position
-- @function GetCurrentWord
-- @treturn string word
--- Gets the file extension of the current document.
-- @function GetExtPart
-- @treturn string file extension
--- Gets the file name of the current document.
-- @function GetFileName
-- @treturn string file name
--- Gets the file name at the cursor position.
-- @function GetFileNameAtCursor
-- @treturn string file path
--- Gets the full path of the current document.
-- @function GetFullCurrentPath
-- @treturn string full path
--- Gets the full path of the provided buffer ID.
-- @function GetFullPathFromBufferID
-- @tparam int BufferID
-- @treturn string full path
--- Gets the file name (without extension) of the current document.
-- @function GetNamePart
-- @treturn string
--- Gets the number of open documents.
-- @function GetNbOpenFiles
-- @tparam int view either `ALL_OPEN_FILES`, `PRIMARY_VIEW`, or `SECOND_VIEW`
-- @treturn int
--- Gets the number of files a the session file.
-- @function GetNbSessionFiles
-- @tparam string session full path to the session file
-- @treturn int number of files
--- Gets the directory of the Notepad++ application.
-- @function GetNppDirectory
-- @treturn string
--- Gets the plugin configuration directory.
-- @function GetPluginsConfigDir
-- @treturn string
--- Gets the position information of the provided buffer ID.
-- @function GetPosFromBufferID
-- @tparam int BufferID
-- @tparam int priorityView either `MAIN_VIEW` or `SUB_VIEW`. If priorityView set to `SUB_VIEW`, then it will be searched first
-- @treturn int the two highest bits will either be `MAIN_VIEW` or `SUB_VIEW`. The lower 30 bits will be the 0-based index.
--- Hides or shows the menu.
-- @function HideMenu
-- @tparam bool hideOrNot whether or not to hide the menu
-- @treturn bool the previous state
--- Hides or shows the status bar.
-- @function HideStatusBar
-- @tparam bool hideOrNot whether or not to hide the status bar
-- @treturn bool the previous state
--- Hides or shows the tab bar.
-- @function HideTabBar
-- @tparam bool hideOrNot whether or not to hide the tab bar
-- @treturn bool the previous state
--- Hides or shows the tool bar.
-- @function HideToolBar
-- @tparam bool hideOrNot whether or not to hide the tool bar
-- @treturn bool the previous state
--- Gets whether the doc switcher is hidden or shown.
-- @function IsDocSwitcherShown
-- @treturn bool
--- Gets whether the menu is hidden or shown.
-- @function IsMenuHidden
-- @treturn bool
--- Gets whether the status bar is hidden or shown.
-- @function IsStatusBarHidden
-- @treturn bool
--- Gets whether the tab bar is hidden or shown.
-- @function IsTabBarHidden
-- @treturn bool
--- Gets whether the tool bar is hidden or shown.
-- @function IsToolBarHidden
-- @treturn bool
--- Launch the "Find in Files" dialog.
-- @function LaunchFindInFilesDlg
-- @tparam string path the directory path to search
-- @tparam string filter the filter to use (e.g. "*.c *.h")
--- Loads a session file.
-- @function LoadSession
-- @tparam string filename full path to the session file
--- Makes the current buffer marked as dirty.
-- @function MakeCurrentBufferDirty
--- Executes a menu command.
-- @function MenuCommand
-- @tparam int command one of the [IDM_xxx](https://github.com/dail8859/LuaScript/blob/master/src/Npp/menuCmdID.h) constants
--- Reloads the specified buffer ID.
-- @function ReloadBufferID
-- @tparam int BufferID
-- @tparam bool alertOrNot whether to show an alert dialog.
-- @treturn bool
--- Reloads the specified file.
-- @function ReloadFile
-- @tparam bool withAlert use an alert or not
-- @tparam string filename file name to reload
--- Saves all the opened documents.
-- @function SaveAllFiles
-- @treturn bool
--- Saves the current document.
-- @function SaveCurrentFile
-- @treturn bool
--- Saves the current document as the specified name.
-- @function SaveCurrentFileAs
-- @tparam bool asCopy flag to indicate of the file should be saved as a copy
-- @tparam string filename file name
-- @treturn bool
--- Saves a new session file of the currently opened buffers.
-- @function SaveCurrentSession
-- @tparam string session full path of the new session file
--- Enable or disable the editor's border edge
-- @function SetEditorBorderEdge
-- @tparam bool useOrNot
--- Enable or disable the use of smooth fonts.
-- @function SetSmoothFont
-- @tparam bool useOrNot
--- Enable or disable the doc switcher panel.
-- @function ShowDocSwitcher
-- @tparam bool showOrNot
--- Switch to the specified document.
-- @function SwitchToFile
-- @tparam string filename file name
-- @treturn bool `true` if successful, else `false`
--- Activate the tab bar context menu.
-- @function TriggerTabbarContextMenu
-- @tparam int view either `MAIN_VIEW` or `SUB_VIEW`
-- @tparam int index 0-based index
--- Properties
-- @section properties
--- Whether plugins are allowed to be loaded from the `%APPDATA%` directory.
-- @tparam[readonly] bool AppDataPluginsAllowed
--- Gets or sets the buffer's end of line mode (one of the `SC_EOL_xxx` constants).
-- @array BufferFormat
-- @tparam BufferID id
-- @treturn int
--- Gets or sets the buffer's language type (one of the `L_xxx` constants).
-- @array BufferLangType
-- @tparam BufferID id
-- @treturn int
--- Gets the current BufferID.
-- @tparam[readonly] BufferID CurrentBufferID
--- Gets the current column of the cursor.
-- @tparam[readonly] int CurrentColumn
--- Gets the current line number of the cursor.
-- @tparam[readonly] int CurrentLine
--- Gets the currently active view, either `MAIN_VIEW` or `SUB_VIEW`.
-- @tparam[readonly] int CurrentView
--- Gets the default background color used for documents.
-- @tparam[readonly] colour DefaultBackgroundColor
--- Gets the default foreground color used for documents.
-- @tparam[readonly] colour DefaultForegroundColor
--- Gets the description of a language.
-- @array LanguageDescription
-- @tparam[readonly] int language one of the `L_xxx` constant
-- @treturn string
--- Gets the language name.
-- @array LanguageName
-- @tparam[readonly] int language one of the `L_xxx` constant
-- @treturn string
--- Gets the encoding of Notepad++'s localization.
-- @tparam[readonly] int NativeLangEncoding
--- Sets the status bar's text.
-- `field` must be one of the following:
--
-- * `STATUSBAR_DOC_TYPE`
-- * `STATUSBAR_DOC_SIZE`
-- * `STATUSBAR_CUR_POS`
-- * `STATUSBAR_EOF_FORMAT`
-- * `STATUSBAR_UNICODE_TYPE`
-- * `STATUSBAR_TYPING_MODE`
--
-- @array StatusBar
-- @tparam int field
--- Gets the Notepad++ version.
-- The high 16 bits contain the major version. The low 16 bits contain the minor version.
-- @usage print((npp.Version >> 16) .. '.' .. (npp.Version & 0xff))
-- @tparam[readonly] int Version
--- Gets the version of the Windows operating system (one of the `WV_xxx` constants).
-- @tparam[readonly] int WindowsVersion
--- Helper Methods
-- @section helpermethods
--- Sends a message to the current editor.
-- This duplicates the functionality of the editor object, providing access to this through an interface that is more familiar to Scintilla C++ developers.
-- @function SendEditor
-- @static
-- @tparam int sci_const A `SCI_xxx` message constant
-- @param[opt=0] wparam optional parameter dependent on the specific message
-- @param[opt=0] lparam optional parameter dependent on the specific message
-- @return optional return value dependent on the specific message
--- Looks up the symbolic name of a constant.
-- @function ConstantName
-- @static
-- @tparam int const number
-- @tparam[opt] string hint the prefix of the constant to attempt to find
-- @treturn string The symbolic name of a Scintilla / Notepad++ constant. Raises error if not found.
--- Registers a Lua function to handle a given event.
-- See the topic on Callbacks
--
-- @function AddEventHandler
-- @static
-- @tparam string event name of the desired event (can also be an array of strings)
-- @tparam function callback function to call when the event(s) is triggered
-- @treturn bool always returns `true` currently
--- Removes previously registered Lua function for a given event.
-- @function RemoveEventHandler
-- @static
-- @tparam string event name of the desired event
-- @tparam function callback a previously registered function
-- @treturn bool `true` if the function had been previously registered, else `false`
-- @see AddEventHandler
--- Removes all registered Lua functions for a given event.
-- @function RemoveAllEventHandlers
-- @static
-- @tparam string event name of the desired event
-- @see AddEventHandler
--- Registers a Lua function for a shortcut key.
-- The callback is not passed any parameters.
--
-- **Note:** This can only be called during startup.
-- @function AddShortcut
-- @static
-- @tparam string name the user-friendly name of the shortcut (this is displayed in the menu)
-- @tparam string shortcut the modifier and key (e.g. "`Ctrl+Alt+Shift+D`"). The _key_ must be one of: `A`-`Z`, `0`-`9`, `F1`-`F12`, `;`, `/`, `~`, `[`, `\`, `]`, `\`, `,`, `-`, `.`, `=`, `up`, `down`, `left`, `right`, `space`, `pageup`, `pagedown`, `backspace`, `delete`, `escape`
-- @tparam function callback function to call when the shortcut is triggered
--- Writes an error message to the console.
-- Calls `tostring` on each parameter and prints the results in the console in red text.
-- @function WriteError
-- @static
-- @param ... variable number of arguments
--- Clears the console.
-- @function ClearConsole
-- @static
--- Continuously calls a function at a set interval.
--
-- **Note:** The timer will continue to fire until `StopTimer` is called. Also, these timers run synchronously in the same thread as Notepad++, meaning that if Notepad++ is busy processing the file (such as doing search/replace) the timer event will get delayed. It is safe to access any of the globally defined LuaScript objects in the callback.
-- @function StartTimer
-- @static
-- @tparam int ms milliseconds to wait between calls
-- @tparam function callback function to be called. It will be passed a singe parameter, the opaque `timer` object
-- @return the opaque `timer` object
-- @see StopTimer
-- @usage -- A trivial example...save a copy of the current file every 10 seconds, unless the file is too big
-- npp.StartTimer(10000, function(timer)
-- if editor.Length < 1000 then
-- npp:SaveCurrentFileAs(true, [[C:\path\to\current\file.backup]])
-- else
-- npp.StopTimer(timer)
-- end
-- end)
--- Stops a previously created timer.
--
-- @function StopTimer
-- @static
-- @param timer the opaque `timer` object returned from `StartTimer` or passed into the callback
-- @see StartTimer