PureWLX library

Overview

This purebasic userlibrary provides an interface to TotalCMD lister plugins (*.wlx).

Functions

PureWLX_LoadPlugin(PluginFilename.s)

Load a TotalCMD wlx plugin.

Returned values :

Returns a plugin handle or #False if failed.
PureWLX_LoadPluginMem(*PluginAddress)

Load a TotalCMD wlx plugin from memory.

Returned values :

Returns a plugin handle or #False if failed.
PureWLX_FreePlugin(*PluginID.WLXPlugin)

Free a TotalCMD wlx plugin.
PureWLX_CreatePluginWindow(*PluginID.WLXPlugin, ParentWindowHandle.l, Filename.s, ShowFlags.l, NeedRedraw.l)

Display a file in a parent window

Parameters :

- *PluginID : wlx plugin handle
- ParentWindowHandle : parent window / gadget handle
- Filename : file to display
- ShowFlags : a combination of the following flags (from wlx plugin SDK help)
	lcp_wraptext	Text: Word wrap mode
	lcp_fittowindow	Images: Fit image to window
	lcp_fitlargeronly	Fit image to window only if larger than the window.
			Always set together with lcp_fittowindow.
	lcp_center		Center image in viewer window
	lcp_ansi		Ansi charset
	lcp_ascii		Ascii(DOS) charset
	lcp_variable	Variable width charset
	lcp_forceshow	If lcp_forceshow is defined, you may try to load the file even if the plugin wasn't made for it.
	You may ignore these parameters if they don't apply to your document type.
- NeedRedraw : some plugin require this flag = #True (plugin window is redrawed after a #WM_SIZE event).

Returned values :

- plugin child window handle if success
- #Null if failed
PureWLX_ClosePluginWindow(*PluginID.WLXPlugin, PluginWindowHandle.l)

Closes a WLX plugin child window.

Parameters :

- *PluginID : wlx plugin handle
- PluginWindowHandle : plugin window handle [returned by PureWLX_CreatePluginWindow()]
PureWLX_UpdatePluginWindow(*PluginID.WLXPlugin, ParentWindowHandle.l, PluginWindowHandle.l, Filename.s, ShowFlags.l)

Update plugin child window with new file

Parameters :

- *PluginID : wlx plugin handle
- ParentWindowHandle : parent window / gadget handle
- PluginWindowHandle : plugin window handle [returned by PureWLX_CreatePluginWindow()]
- Filename : file to display
- ShowFlags : a combination of the following flags (from wlx plugin SDK help)
	lcp_wraptext	Text: Word wrap mode
	lcp_fittowindow	Images: Fit image to window
	lcp_fitlargeronly	Fit image to window only if larger than the window.
			Always set together with lcp_fittowindow.
	lcp_center		Center image in viewer window
	lcp_ansi		Ansi charset
	lcp_ascii		Ascii(DOS) charset
	lcp_variable	Variable width charset
	lcp_forceshow	If lcp_forceshow is defined, you may try to load the file even if the plugin wasn't made for it.
	You may ignore these parameters if they don't apply to your document type.

Returned values :

- #True if success
- #Null if failed

Comment :

You may use PureWLX_PluginSupportsUpdatePluginWindow() to check if the plugin supports this function.
If it doesn't, use PureWLX_ClosePluginWindow() followed by PureWLX_CreatePluginWindow()


PureWLX_ListSendCommand(*PluginID.WLXPlugin, PluginWindowHandle.l, Command.l, Parameter.l)

Send a command to the plugin window.

Parameters :

- *PluginID : wlx plugin handle
- PluginWindowHandle : plugin window handle [returned by PureWLX_CreatePluginWindow()]
- Command : one of the following commands  (from wlx plugin SDK help)
	lc_copy		Copy current selection to the clipboard
	lc_newparams	New parameters passed to plugin, see Parameter below
	lc_selectall	Select the whole contents
	lc_setpercent	Go to new position in document (in percent).
- Parameter : used for lc_newparams, may be a combination of  (from wlx plugin SDK help)
	lcp_wraptext	Text word wrap mode
	lcp_ansi		Ansi charset
	lcp_ascii		Ascii(DOS) charset
	lcp_variable	Variable width charset
	lcp_fittowindow	Images: Fit image to window
	lcp_fitlargeronly	Images: Sent in addition to lcp_fittowindow if only images larger than the client are should be resized - smaller should be shown centered
	lcp_center		Images: Sent when the image needs to be centered (may be combined with lcp_fittowindow and/or lcp_fitlargeronly)

Returned values :

- #True if success
- #Null if failed
PureWLX_PrintFile(*PluginID.WLXPlugin, PluginWindowHandle.l, Filename.s, PrinterName.s)

Prints a file using the wlx plugin.

Parameters :

- *PluginID : wlx plugin handle
- PluginWindowHandle : plugin window handle [returned by PureWLX_CreatePluginWindow()]
- Filename : file to print
- PrinterName : printer name ["" = default printer]

Returned values :

- #True if success
- #Null if failed
PureWLX_GetDetectString(*PluginID.WLXPlugin)

Get plugin detection string [allows to find out what kind of files the plugin can handle].

Parameters :

- *PluginID : wlx plugin handle

About the detection string : (from wlx plugin SDK help)

The syntax of the detection string is as follows. There are operands, operators and functions.

Operands:

EXT		The extension of the supported file to be loaded (always uppercase).
SIZE		The size of the file to be loaded.
FORCE		Force multimedia mode.
MULTIMEDIA	Plugin supports multimedia files. Check the example below!

[5]		The fifth byte in the file to be loaded. The first 8192 bytes can be checked for a match.
12345		The number 12345
"TEST"		The string "TEST"

Operators

&		AND. The left AND the right expression must be true (!=0).
|		OR: Either the left OR the right expression needs to be true (!=0).
=		EQUAL: The left and right expression need to be equal.
!=		UNEQUAL: The left and right expression must not be equal.
<		SMALLER: The left expression is smaller than the right expression. Comparing a number and a string returns false (0). Booleans are stored as 0 (false) and 1 (true).
>		LARGER: The left expression is larger than the right expression.

Functions

()		Braces: The expression inside the braces is evaluated as a whole.
!()		NOT: The expression inside the braces will be inverted. Note that the braces are necessary!
FIND()		The text inside the braces is searched in the first 8192 bytes of the file. Returns 1 for success and 0 for failure.
FINDI()		The text inside the braces is searched in the first 8192 bytes of the file. Upper/lowercase is ignored.

Internal handling of variables

Variables can store numbers and strings. Operators can compare numbers with numbers and strings with strings, but not numbers with strings. Exception: A single char can also be compared with a number. Its value is its ANSI character code (e.g. "A"=65). Boolean values of comparisons are stored as 1 (true) and 0 (false).

Examples:

String							Interpretation

EXT="WAV" | EXT="AVI"					The file may be a Wave or AVI file.

EXT="WAV" & [0]="R" & [1]="I" & [2]="F" & [3]="F" & FIND("WAVEfmt")	Also checks for Wave header "RIFF" and string "WAVEfmt"

([0]="P" & [1]="K" & [2]=3 & [3]=4) | ([0]="P" & [1]="K" & [2]=7 & [3]=8)	Checks for the ZIP header PK#3#4 or PK#7#8 (the latter is used for multi-volume zip files).

EXT="TXT" & !(FINDI("") | FINDI(""))				This plugin handles text files which aren't HTML files. A first detection is done with the  and  tags. If these are not found, a more thorough check may be done in the plugin itself.

MULTIMEDIA & (EXT="WAV" | EXT="MP3")				Replace the internal player for WAV and MP3 files (which normally uses Windows Media Player as a plugin). 

Operator precedence

The strongest operators are =, != < and >, then comes &, and finally |. What does this mean? Example:

expr1="a" & expr2 | expr3<5 & expr4!=b will be evaluated as ((expr1="a") & expr2) | ((expr3<5) & (expr4!="b"))
If in doubt, simply use braces to make the evaluation order clear.
PureWLX_PluginSupportsUpdatePluginWindow(*PluginID.WLXPlugin)

Find out if PureWLX_UpdatePluginWindow() is supported.

Returned values :

- #True if yes
- #Null if no