PSPad Scripting and Extensions Reference

Placement of Extensions and Scripts

They go in the Script/[Language] folders.

All files in the SCRIPT directory and its subdirectories are considered scripts; putting non-script files in these folders will cause a compilation error. If you want to put comments, just put a script file in there with nothing but comments.

API Modules

Script files can contain only functions, subs, variables, and Consts at global scope. In effect, they are APIs. module_name, module_ver, and module_date globals are optional but highly recommended. The Init() function is required; its purpose is to place your functionality into PSPad's SCRIPTS menu. APIs, and share those functions in them out to other scripts.

To call a function from a custom API module, place the module name before the function name:

addMenuItem (caption: string; submenu: string; procedure: string)

creates a menu item in PSPad's main menu. If you don't want a submenu, send an empty string as a parameter. It can only be used in the Init() function.

echo (text: string)

information box with text and OK button

sleep (ms: integer)

stops script execution for number of miliseconds

inputText (label [,default_value [, cancel_value]]: string): string

input text dialog. Cancel_value is returned after Cancel button is pressed.

setClipboardText (text: string)

stores text into clipboard

getClipboardText (): string

returns text from clipboad

runPSPadAction (ActionName: string)

allows to run any PSPad editor action. List of actions follows.

getVariable (name: string) OR getVarValue (name: string)

returns value of variable passed as parameter.

logClear

clears whole LOG window content

logAddLine (test: string)

adds new line into LOG

logGetLine (index: integer): string

returns line from LOG, identified by index parameter (numbered from 0)

logSetLine (index: integer, test: string)

sets log line, identified by index

logLinesCount (): Integer

returns current number of LOG window lines

logLineIndex ([index: integer]): Integer

sets or returns (if no parameter) current line index of LOG window

logSetTypeMemo>

sets LOG window type to memo style

logSetTypeList>

sets LOG window type to list style

logSetParser (expression: string): string

sets LOG parser expression

pspadVersion (): string

returns PSPad version (q.v. %PSPAD% variable)

moduleExists (name: string):boolean

returns True if script module exists

moduleVersion (name: string):string

returns version of module. If not defined, returns empty string

moduleFileName (name: string):string

returns file name of module. If not defined, returns empty string

modulePath ():string

returns module file path include last backslash

closeEditorByTitle (file_name: string): boolean

closes editor by filename

closeEditorByIndex (index: integer): boolean

closes editor windows by index

closeAllEditors>

closes all editor windows

editorsCount: integer

returns number of open editors

projectFilesCount: integer

returns the number of files in the currently active project.

projectFiles (index: integer): string

returns file name for index. If not defined, returns empty string

projectItemsCount: integer

returns the number of all items (files and folders) in the currently active project.

projectItems (index: integer): string

returns item name for index. If not defined, returns empty string

projectItemType (index: integer): integer

returns project item type. 1: folder, 2: file, -1: item doesn't exist

projectFileName: string

returns project file name

projectSave>

saves project

ftpConnect (connection_name: string): boolean

connect to in PSPad defined FTP connection

ftpDisconnect>

disconnect FTP server

ftpCommand (command: string): string

send command to FTP server. Returns server reply.

ftpDownloadFile (ftp_filename, local_filename): boolean

download file from ftp and stored it as local file

ftpUploadFile (local_filename, ftp_filename, [refresh]): boolean

uploads local file to current FTP directory. If refresh is true, server-side folder will be refreshed after uload

ftpRefresh>

refresh current ftp folder

newEditor (): object

creates new object for editor handling

assignEditorByName (file_name: string): boolean

assign editor window to object by file name

assignEditorByIndex (index: integer): boolean

assign editor window to object by editor index

assignActiveEditor (): boolean

assign active editor window into object and show it

newFile ([file_name: string]): boolean

creates new file in PSPad. File name is optional

openFile (file_name: string): boolean

opens existing file in new editor window

saveFile (): boolean

saves file

saveFileAs (file_name: string): boolean

saves file as another name

reloadFile (): boolean

reload file

closeFile (): boolean

close file

activate (): boolean

brings editor to front

printFile (boolean): boolean

if parameters is 1 then PrintDialog appears before print

readOnly ([boolean]): boolean

returns if no param or sets editor ReadOnly state

modified ([boolean]): boolean

returns if no param or sets editor Modified state

text (string):string

replaces/returns all editor text

selText (string): string

replaces/returns selected text from editor

lineText (string): string

replaces/returns content of active line

linesCount (): integer

returns editor lines count

appendText (string): boolean

appends text to editor end

fileName (string): string

sets/returns editor file name

command (editor_command: string): boolean

runs editor command processor command

setCaretPos (x: integer; y: integer): boolean

sets editor caret position. -1 = mean no change coordinate

caretX (integer): integer

sets/returns editor CaretX position

caretY (integer): integer

sets/returns editor CaretY position

setBlockBegin (x: integer; y: integer): boolean

set start of block

setBlockEnd (x: integer; y: integer): boolean

set end of block

selectionMode ([s: string]): string

sets selection mode. C: column, N: normal, L: line selection. if no parameter is sent, function returns C for column, N for normal and L for line selection mode of current editor

blockBeginX: integer

returns block start column

blockBeginY: integer

returns block start line

blockEndX: integer

returns block end column

blockEndY: integer

returns block end line

selStart (integer): integer

returns/sets block start

selLength (integer): integer

returns/sets block length

ecLeft => move cursor left one char

ecRight => move cursor right one char

ecUp => move cursor up one line

ecDown => move cursor down one line

ecWordLeft => move cursor left one word

ecWordRight => move cursor right one word

ecLineStart => move cursor to beginning of line

ecLineEnd => move cursor to end of line

ecPageUp => move cursor up one page

ecPageDown => move cursor down one page

ecPageLeft => move cursor right one page

ecPageRight => move cursor left one page

ecPageTop => move cursor to top of page

ecPageBottom => move cursor to bottom of page

ecEditorTop => move cursor to absolute beginning

ecEditorBottom => move cursor to absolute end

ecNextLineStart => move cursor to next line begining

ecSelLeft => ecLeft + ecSelection;

ecSelRight => ecRight + ecSelection;

ecSelUp => ecUp + ecSelection;

ecSelDown => ecDown + ecSelection;

ecSelWordLeft => ecWordLeft + ecSelection;

ecSelWordRight => ecWordRight + ecSelection;

ecSelLineStart => ecLineStart + ecSelection;

ecSelLineEnd => ecLineEnd + ecSelection;

ecSelPageUp => ecPageUp + ecSelection;

ecSelPageDown => ecPageDown + ecSelection;

ecSelPageLeft => ecPageLeft + ecSelection;

ecSelPageRight => ecPageRight + ecSelection;

ecSelPageTop => ecPageTop + ecSelection;

ecSelPageBottom => ecPageBottom + ecSelection;

ecSelEditorTop => ecEditorTop + ecSelection;

ecSelEditorBottom ecEditorBottom + ecSelection;

ecScrollUp => scroll up one line leaving cursor position unchanged.

ecScrollDown => scroll down one line leaving cursor position unchanged.

ecScrollLeft => scroll left one char leaving cursor position unchanged.

ecScrollRight => scroll right one char leaving cursor position unchanged.

ecInsertMode => set insert mode

ecOverwriteMode => set overwrite mode

ecToggleMode => toggle ins/ovr mode

ecNormalSelect => normal selection mode

ecColumnSelect => column selection mode

ecLineSelect => line selection mode

ecMatchBracket => go to matching bracket

ecGotoMarker0 => goto marker

ecGotoMarker9 => goto marker

ecSetMarker0 => set marker

ecSetMarker9 => set marker

ecDeleteLastChar => delete last char (i.e. backspace key)

ecDeleteChar => delete char at cursor (i.e. delete key)

ecDeleteWord => delete from cursor to end of word

ecDeleteLastWord => delete from cursor to start of word

ecDeleteBOL => delete from cursor to beginning of line

ecDeleteEOL => delete from cursor to end of line

ecDeleteLine => delete current line

ecClearAll => delete everything

ecLineBreak => break line at current position, move caret to new line

ecInsertLine => break line at current position, leave caret

ecUndo => perform undo if available

ecRedo => perform redo if available

ecCut style='font-size: 10.0pt; => cut selection to clipboard

ecPaste => paste clipboard to current position

ecSelectAll => select entire content of editor, cursor to end

ecCopy => copy selection to clipboard

ecBlockIndent => indent selection

ecBlockUnindent => unindent selection

ecTab style='font-size: 10.0pt; => tab key

ecShiftTab => shift+Tab key

ecUpperCase => apply to the current or previous word

ecLowerCase

ecToggleCase

ecTitleCase

ecUpperCaseBlock => apply to current selection, or current char if no selection

ecLowerCaseBlock

ecToggleCaseBlock

aAddDiacritic => Add accent marks (dictionary is required)

aAddFile => Add current file to project

aAddFilesToFolder => Add Files to project - dialog

aAddFolder => New folder to project

aAllToASCII => Remove Accent from chars

aAutoCompl => Auto completion

aAutoRefresh => Set Autorefresh flag for window

aBlockAlign => Align selection to block

aBlockCenter => Justify block to the center

aBlockLeft => Justify block to the left

aBlockRight => Justify block to the right

aCapitalize => Capitalize block

aClose => Close window

aCloseAll => Close All

aCodeExplorer => Code Explorer window

aCodeFormat => Code Case Change dialog

aColorSelect => Color Selector window

aComment => Add/Remove Comment

aCompile => Compile

aCopy => Copy

aCopyLine => Copy Line

aCSSToInLine => Reformat into Inline CSS

aCSSToStructure => Reformat into Structured CSS

aCSVImport => Import from CSV dialog

aCut => Cut

aDateTime => Insert Date Time

aDateTimeDialog => Date Time Dialog

aDecToHex => Decimal to Hexadecimal selection

aDelete => Delete

aDelFolder => Remove Folder from project

aDelMark => Delete Bookmark

aDelMarks => Delete all Bookmarks

aDiffSame => Text Diff with File Contents on Disk

aExit => Exit

aExpClipHTML => Export to Clipboard as HTML

aExpClipRTF => Export to Clipboard as RTF

aExpClipTeX => Export to Clipboard as &TeX

aExpClipXHTML => Export to clipboard as XHTML

aExport => Export dialog

aFilesSearch => Search / Replace in Files dialog

aFind => Find dialog

aFindNext => Find Next

aFindPrev => Find Previous

aFindPrevWord => Previous Occurrence of Current Word

aFindWord => Next Occurrence of Current Word

aFont => Font dialog

aFullScreen => Full Screen mode

aGoogleSearch => Google Search dialog

aGotoLine => Goto Line dialog

aGUID => Insert GUID

aHexToDec => Hexadecimal to Decimal selection

aHTMLCompress => Compress HTML code

aHtmlCheck => Check HTML code

aHTMLPrev => HTML Page Preview

aHTMLReformat => Reformat HTML code

aHTMLSelTag => Select TAG

aIndent => Indent Block

aInfo => File Info

aInserFile => Insert From File...

aInsertText => Insert Text into Lines...

aInvertCase => Invert Case

aJoinLine => Join Lines

aLangHelp => Help for Language

aLastUserConvertor => Run Last used convertor

aLineNum => Line Numbers

aLogWindow => Show / Hide LOG window

aLoremIpsum => Lorem Ipsum generator

aLowerCase => To Lower Case

aMacroMgr => Macro Manager

aMacroPlay => Play Macro

aMacroRecord => Start / Stop Recording

aMailContents => As e-mail Contents

aMailFile => As e-mail Attachment

aMarkDown => Next Bookmark

aMarkList => Bookmark List

aMarkUp => Previous Bookmark

aMatchBracket => Matching Bracket

aMD5Gen => Hash generator dialog

aMoveAs => Move as dialog

aNew => New file dialog

aOpen => Open file dialog

aOpenCopy => Open Active File with New Name dialog

aOpenHex => Open in HEX Editor dialog

aOpenSame => Open R/O copy of Active File

aOpenSelected => Open file appointed by selection

aOpenWWWFile => Open File from Internet dialog

aPageSetup => Page Setup dialog

aPaste => Paste

aPasteHTML => Paste as HTML

aPasteNoMove => Paste Without Cursor Change

aPrint => Print file

aPrintPrev => Print Preview

aPrintSetup => Printer Settings dialog

aProjAddOpen => Add all open files to project

aProjFolderClose => Close files of current project folder

aProjFolderOpen => Open files of current prject folder

aProjFromDir => Create Project from Directory dialog

aProjInfo => Project Information dialog

aProjMainFile => Set File as Main for Compiler

aProjNew => New Project (closes all)

aProjOpen => Open Project dialog

aProjSave => Save Project

aProjSaveas => Save Project as dialog

aProjSettings => Project Settings dialog

aProjShow => Show/hide left Panel

aReadOnly => Read Only on/off for file

aRedo => Redo

aReformat => Reformat block (paragraph=blank line)

aReformat2 => Reformat block (paragraph=short line)

aRemoveBlankLines font-family: "Arial","sans-serif";> => Remove Blank Lines

aRemoveFile => Remove File from Project

aRemoveRedundantBlank font-family:"Arial","sans-serif";> => Remove Redundant Blank Lines

aRemoveSpaces => Remove Redundant Spaces dialog

aRemoveTags => Remove HTML tags - it opens result in new window

aReOpen => Reopen Active File

aRepeatLastAction => Repeat last command

aReplace => Replace dialog

aRollBar => Ruler on/off

aRTFImport => Import text from RTF

aSave => Save current file

aSaveAll => Save All files

aSaveAs => Save As dialog

aSaveBlock => Save Block As dialog

aSaveSameTime => Save Without changing File Date

aSaveToFTP => Save to FTP

aScriptsRecompile => Recompile scripts

aSelectAll => Select All

aSelectNext => Next Window

aSelectPrew => Previous Window

aSelMatchBracket => Select Inside Brackets

aSelString => Select String

aSendToDisk => Save to Drive A:

aSentensize => Sentensize selection

aSetMain => Set as Main File for Compiler

aSetMark => Set Bookmark

aShellOpen => Open with associated application

aShowControlBar => Show/hide all toolbars

aShowSpecChar => Show/hide nonprinted characters

aSort => Sort dialog

aSpell => Online Spell Check on/off

aSpellCheck => Spell Check with dialog

aSpellSett => Spell Settings dialog

aStayOnTop => Stay on Top on/off

aSwapLineAbove => Swap line with line above (applicable to block)

aSwapLineBellow => Swap line with line bellow (applicable to block)

aSwapBlock => Swap lines in selected block

aSwitchLog => Jump to Editor / LOG

aSyntax => Syntax on/off

aSyntaxChange => Change Syntax dialog

aSysEdit => Open System Files (Autoexc, Config, ...)

aTabToSpaces => Convert Tabs to Spaces dialog

aTagToLowercase => Tags to Lowercase

aTagToUpperCase => Tags to Uppercase

aTextToHTML => Text to HTML

aToJScript => Selection to JavaScript

aToPHP => Selection to PHP variable

aUndo => Undo

aUnIndent => UnIndent Block

aUnQuote => Remove Email Quoting

aUpperCase => To Upper Case

aUserConvertors => User Convertors dialog

aWindCascade => Cascade windows

aWindSplitHoriz => Horizontal Split current file

aWindSplitVert => Vertical Split current file

aWindTile => Arrange windows

aWindTileHoriz => Tile windows Horizontal

aWindTileVert => Tile windows Vertical

aWordWrap => Word Wrap Lines on/off