Sei sulla pagina 1di 10

PSPad editor script interface description

Note!
Dont place any non script files direct into script language subdirectories !
All files e.g. in VBScript subrirectory are consider as script and non script file causes compilation error.

modules library
You can write own library and share function from library in other scripts. Unique module_name is identifier.
To call function from other module, place module name before function name:
myLibrary.someFunction()

global functions/subroutines
addMenuItem(caption: string; submenu: string; procedure: string)
creates menu item in PSPad main menu. if you don't want submenu, send empty string as parameter
Its contained in script Init subroutine and works only during Init phase. All other calling is ignored.

echo(text: string)
information box with text and button OK

sleep(ms: integer)

stops script execution for number of miliseconds

setWaitCursor([boolean])

sets screen cursor to HourGlass (true parameter) and Default one (false parameter)

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


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

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)

returns value of variable passed as parameter.

reloadClips

reloads all code clip files

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 - you are able to make free selection, byt without error marks

logSetTypeList

sets LOG window type to list style - only line by line selection, but with error marks

logSetParser(expression: string): string


sets LOG parser expression

pspadVersion(): string
returns PSPad version

moduleExists(name: string):boolean
returns True if script module exists

moduleVersion(name: string):string
returns version of module, if module doesn't exists, returns empty string

moduleFileName(name: string):string

returns file name of module, if module doesn't exists, 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 by index

closeAllEditors
closes all editor windows

editorsCount: integer
returns number of open editors

projectFilesCount: integer
returns number of files (not folders) in project. Use cycle from 0 to projectFilesCount-1

projectFiles(index: integer): string

returns file name for index. If file doesn't exists, returns empty string

projectItemsCount: integer

returns number of all items (files and folders) in project. Use cycle from 0 to projectItemsCount-1

projectItems(index: integer): string

returns item name for index. If item doesn't exists, returns empty string

projectItemType(index: integer): integer

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

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, e.g. "CWD \public\www". Function returns FTP server return stringserveru

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, when refresh parameters is send, FTP folder will be refreshed
after uload

ftpRefresh

refresh current ftp folder

newEditor(): object
creates new object for editor handling

editor object function


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

assignLog(): boolean

this function is obsolete now. Is replaced with logXXXXX() functions. Now returns always 0, in the past
returns always 1

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

reloadFile(): boolean
reload file

closeFile(): boolean
closes 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

topLineIndex([integer]): integer
sets or returns returns index of the first line in editor window

linesInWindow(): integer
returns number of lines in editor window

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 in parameter 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


sets start of the block

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


sets end of the 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

highlighter([s: string]): string


returns/set highlighter for editor

editor commands list


ecLeft
ecRight
ecUp
ecDown
ecWordLeft
ecWordRight
ecLineStart
ecLineEnd
ecPageUp
ecPageDown
ecPageLeft
ecPageRight
ecPageTop
ecPageBottom
ecEditorTop
ecEditorBottom
ecNextLineStart

move cursor left one char


move cursor right one char
move cursor up one line
move cursor down one line
move cursor left one word
move cursor right one word
move cursor to beginning of line
move cursor to end of line
move cursor up one page
move cursor down one page
move cursor right one page
move cursor left one page
move cursor to top of page
move cursor to bottom of page
move cursor to absolute beginning
move cursor to absolute end
move cursor to next line begining

ecSelLeft
ecSelRight
ecSelUp
ecSelDown
ecSelWord
ecSelWordLeft
ecSelWordRight
ecSelLineStart
ecSelLineEnd
ecSelPageUp
ecSelPageDown
ecSelPageLeft
ecSelPageRight
ecSelPageTop
ecSelPageBottom
ecSelEditorTop
ecSelEditorBottom

ecLeft + ecSelection;
ecRight + ecSelection;
ecUp + ecSelection;
ecDown + ecSelection;
selects word under cursor
ecWordLeft + ecSelection;
ecWordRight + ecSelection;
ecLineStart + ecSelection;
ecLineEnd + ecSelection;
ecPageUp + ecSelection;
ecPageDown + ecSelection;
ecPageLeft + ecSelection;
ecPageRight + ecSelection;
ecPageTop + ecSelection;
ecPageBottom + ecSelection;
ecEditorTop + ecSelection;
ecEditorBottom + ecSelection;

ecScrollUp
ecScrollDown
ecScrollLeft
ecScrollRight

scroll up one line leaving cursor position unchanged.


scroll down one line leaving cursor position unchanged.
scroll left one char leaving cursor position unchanged.
scroll right one char leaving cursor position unchanged.

ecInsertMode
ecOverwriteMode
ecToggleMode

set insert mode


set overwrite mode
toggle ins/ovr mode

ecNormalSelect
ecColumnSelect
ecLineSelect

normal selection mode


column selection mode
line selection mode

ecMatchBracket

go to matching bracket

ecGotoMarker0
...
ecGotoMarker9
ecSetMarker0
...
ecSetMarker9

goto marker

ecDeleteLastChar
ecDeleteChar
ecDeleteWord
ecDeleteLastWord
ecDeleteBOL
ecDeleteEOL
ecDeleteLine
ecClearAll
ecLineBreak
ecInsertLine

delete last char (i.e. backspace key)


delete char at cursor (i.e. delete key)
delete from cursor to end of word
delete from cursor to start of word
delete from cursor to beginning of line
delete from cursor to end of line
delete current line
delete everything
break line at current position, move caret to new line
break line at current position, leave caret

ecUndo
ecRedo
ecCut
ecPaste
ecSelectAll
ecCopy

perform undo if available


perform redo if available
cut selection to clipboard
paste clipboard to current position
select entire content of editor, cursor to end
copy selection to clipboard

ecBlockIndent
ecBlockUnindent
ecTab
ecShiftTab

indent selection
unindent selection
tab key
shift+Tab key

goto marker
set marker
set marker

ecUpperCase
apply to the current or previous word
ecLowerCase
ecToggleCase
ecTitleCase
ecUpperCaseBlock apply to current selection, or current char if no selection
ecLowerCaseBlock
ecToggleCaseBlock

PSPad actions list


aAddDiacritic
aAddFile
aAddFilesToFolder
aAddFolder
aAllToASCII
aANSIToBase64
aANSIToQuotedPrint
aANSIToURL
aAutoCompl
aAutoRefresh
aBase64ToANSI
aBlockAlign
aBlockCenter
aBlockLeft
aBlockRight
aCapitalize
aClose
aCloseAll
aCodeExplorer
aCodeFormat
aColorSelect
aComment
aCompile
aCopy
aCopyLine
aCSSToInLine
aCSSToStructure
aCSVImport
aCut
aDateTime
aDateTimeDialog
aDecToHex
aDelete
aDelFolder
aDelMark
aDelMarks
aDiffSame
aExit
aExpClipHTML
aExpClipRTF
aExpClipTeX
aExpClipXHTML
aExport
aFilesSearch
aFind
aFindNext
aFindPrev
aFindPrevWord
aFindWord
aFont

Add accent marks (dictionary is required)


Add current file to project
Add Files to project - dialog
New folder to project
Remove Accent from chars
Encode all text/selected text to Base64
Encode all text/selected text to Quoted printable
Encode all text/selected text to URL adress form
Auto completion
Set Autorefresh flag for window
Decode all text/selected text from Base64
Align selection to block
Justify block to the center
Justify block to the left
Justify block to the right
Capitalize block
Close window
Close All
Code Explorer window
Code Case Change dialog
Color Selector window
Add/Remove Comment
Compile
Copy
Copy Line
Reformat into Inline CSS
Reformat into Structured CSS
Import from CSV dialog
Cut
Insert Date Time
Date Time Dialog
Decimal to Hexadecimal selection
Delete
Remove Folder from project
Delete Bookmark
Delete all Bookmarks
Text Diff with File Contents on Disk
Exit
Export to Clipboard as HTML
Export to Clipboard as RTF
Export to Clipboard as &TeX
Export to clipboard as XHTML
Export dialog
Search / Replace in Files dialog
Find dialog
Find Next
Find Previous
Previous Occurrence of Current Word
Next Occurrence of Current Word
Font dialog

aFullScreen
aGoogleSearch
aGotoLine
aGUID
aHexToDec
aHTMLCompress
aHtmlCheck
aHTMLPrev
aHTMLReformat
aHTMLSelTag
aIndent
aInfo
aInserFile
aInsertText
aInvertCase
aJoinLine
aLangHelp
aLastUserConvertor
aLineNum
aLogWindow
aLoremIpsum
aLowerCase
aMacroMgr
aMacroPlay
aMacroRecord
aMailContents
aMailFile
aMarkDown
aMarkList
aMarkUp
aMatchBracket
aMD5Gen
aMoveAs
aNew
aOpen
aOpenCopy
aOpenHex
aOpenSame
aOpenSelected
aOpenWWWFile
aPageSetup
aPaste
aPasteHTML
aPasteNoMove
aPrint
aPrintPrev
aPrintSetup
aProjAddOpen
aProjFolderClose
aProjFolderOpen
aProjFromDir
aProjInfo

Full Screen mode


Google Search dialog
Goto Line dialog
Insert GUID
Hexadecimal to Decimal selection
Compress HTML code
Check HTML code
HTML Page Preview
Reformat HTML code
Select TAG
Indent Block
File Info
Insert From File...
Insert Text into Lines...
Invert Case
Join Lines
Help for Language
Run Last used convertor
Line Numbers
Show / Hide LOG window
Lorem Ipsum generator
To Lower Case
Macro Manager
Play Macro
Start / Stop Recording
As e-mail Contents
As e-mail Attachment
Next Bookmark
Bookmark List
Previous Bookmark
Matching Bracket
Hash generator dialog
Move as dialog
New file dialog
Open file dialog
Open Active File with New Name dialog
Open in HEX Editor dialog
Open R/O copy of Active File
Open file appointed by selection
Open File from Internet dialog
Page Setup dialog
Paste
Paste as HTML
Paste Without Cursor Change
Print file
Print Preview
Printer Settings dialog
Add all open files to project
Close files of current project folder
Open files of current prject folder
Create Project from Directory dialog
Project Information dialog

aProjMainFile
aProjNew
aProjOpen
aProjSave
aProjSaveas
aProjSettings
aProjShow
aQuotedPrintToANSI
aReadOnly
aRedo
aReformat
aReformat2
aRemoveBlankLines
aRemoveFile
aRemoveRedundantBlank
aRemoveSpaces
aRemoveTags
aReOpen
aRepeatLastAction
aReplace
aRollBar
aRTFImport
aSave
aSaveAll
aSaveAs
aSaveBlock
aSaveSameTime
aSaveToFTP
aScriptsRecompile
aSelectAll
aSelectNext
aSelectPrew
aSelMatchBracket
aSelString
aSendToDisk
aSentensize
aSetMain
aSetMark
aShellOpen
aShowControlBar
aShowSpecChar
aSort
aSpell
aSpellCheck
aSpellSett
aStayOnTop
aSwapLineAbove
aSwapLineBellow
aSwapBlock
aSwitchLog
aSyntax
aSyntaxChange

Set File as Main for Compiler


New Project (closes all)
Open Project dialog
Save Project
Save Project as dialog
Project Settings dialog
Show/hide left Panel
Decode all text/selected text from Quoted printable
Read Only on/off for file
Redo
Reformat block (paragraph=blank line)
Reformat block (paragraph=short line)
Remove Blank Lines
Remove File from Project
Remove Redundant Blank Lines
Remove Redundant Spaces dialog
Remove HTML tags - it opens result in new window
Reopen Active File
Repeat last command
Replace dialog
Ruler on/off
Import text from RTF
Save current file
Save All files
Save As dialog
Save Block As dialog
Save Without changing File Date
Save to FTP
Recompile scripts
Select All
Next Window
Previous Window
Select Inside Brackets
Select String
Save to Drive A:
Sentensize selection
Set as Main File for Compiler
Set Bookmark
Open with associated application
Show/hide all toolbars
Show/hide nonprinted characters
Sort dialog
Online Spell Check on/off
Spell Check with dialog
Spell Settings dialog
Stay on Top on/off
Swap line with line above (applicable to block)
Swap line with line bellow (applicable to block)
Swap lines in selected block
Jump to Editor / LOG
Syntax on/off
Change Syntax dialog

aSysEdit
aTabToSpaces
aTagToLowercase
aTagToUpperCase
aTextToHTML
aToJScript
aToPHP
aUndo
aUnIndent
aUnQuote
aUpperCase
aURLToANSI
aUserConvertors
aWindCascade
aWindSplitHoriz
aWindSplitVert
aWindTile
aWindTileHoriz
aWindTileVert
aWordWrap

Open System Files (Autoexc, Config, ...)


Convert Tabs to Spaces dialog
Tags to Lowercase
Tags to Uppercase
Text to HTML
Selection to JavaScript
Selection to PHP variable
Undo
UnIndent Block
Remove Email Quoting
To Upper Case
Decode all text/selected text from URL adress form
User Convertors dialog
Cascade windows
Horizontal Split current file
Vertical Split current file
Arrange windows
Tile windows Horizontal
Tile windows Vertical
Word Wrap Lines on/off

sample vb script
' it will create new editor window, copy all text from first window
into new
' and save new file as C:\SAMPLE.TXT
const module_name = "sample"
'this name must be unique !!!
const module_desc = "Sample script" 'script description
const module_ver
= "0.001a"
'version
sub Main
'main procedure
dim obj1, obj2, s
'variable definition
pspadVersion
msgbox "PSPad version : " & pspadVersion()
msgbox "Module version: " & moduleVersion("sample")
set obj1 = getNewEditor()
'new editor object
set obj2 = getNewEditor()
'new editor object
obj2.assignEditorByIndex(0)
'assign PSPad window 1 to obj2
obj1.NewFile()
'opens new file in PSPad and
assign to obj2
s = obj2.getText
'returns all text from window 1
obj1.settext(s)
'replaces all text in new window
' here is presented access to editor lines line by line
dim item
for each item in obj1
MsgBox item
next
obj1.saveFileAs("C:\sample.txt")
'save as new editor
obj1.closeFile
'close copy file
end sub
sub Demo1
msgbox "You run Demo1 from sample script"

end sub
sub Demo2
msgbox "You run Demo2 from sample script"
end sub
' name "Init" is required, its called automatically during
initialization to create menu items
sub Init
addMenuItem "Main from Sample", "", "Main"
addMenuItem "Demo1 from Sample","Sample - submenu", "Demo1"
addMenuItem "Demo2 from Sample","Sample - submenu", "Demo2"
end sub

sample n.2 - run user convertor to all open files


const module_name
const module_ver

= "RunAction"
= "0.001"

'this name must be unique !!!


'version

sub Procedure
set obj = NewEditor()
for i = 0 to editorsCount - 1
obj.assignEditorByIndex(i)
obj.activate
if i = 0 then 'for first file we call user convertor selector
runPSPadAction "aUserConvertors"
else
'for all other files we run last used convertor
runPSPadAction "aLastUserConvertor"
end if
next
end sub
' name "Init" is required, its called automatically during
initialization to create menu items
sub Init
addMenuItem "Run action demo (convert all open files)","", "Procedure"
end sub

Potrebbero piacerti anche