Re: drop down box or something like it.
Brian Wolven <[email protected]>
| Newsgroups | gmane.comp.windows.shells.litestep |
|---|---|
| Message-ID | <[email protected]> |
Hale, Paul wrote:
>>
>> *alias !saveSetting !execute [!setEvar %1
>> %2][!xtextSaveEvar @$settingsFile$@ @%1@ @%2@]
>> *alias !stripPath !execute [!xtextReplace @$settingsFile$@ @(^%1
>> \=)(.*\\)(.*\..*\=)_@ @\1\3@]
>> *alias !stripExtn !execute [!xtextReplace @$settingsFile$@ @(^%1
>> \=.*)(\..*\=)_@ @\1\=@]
>>
>
> I have been trying to figure these lines out, and I am not having much
> luck with it. Let me try and get the regex on one line for ease of
> example.
>
> StripPath
> @(^%1\=)(.*\\)(.*\..*\=)_@ @\1\3@
> The way I understand it, @ ... @ normal Textedit @=$
> () is for grouping
> ^%1 is saying that the argument happens at the beginning of the string
> \= means equals. Do you actually use Var=Value in your themevars? I just
> put a space in mine. Is that a problem?
>
> Next group
> .*\\ is saying remove all \'s
>
> Next group
> .*..*\= I have no idea. Actually, I have no idea past this point.
>
> Can anyone enlighten me?
This is where you have to read the xtextedit docs, so as to know the
escape codes specific to this module:
------------
Escape Codes
The backslash (\) character is used to mark an escape code.
The following are valid escape sequences:
\= Double quote (")
\^ Replaces with a bang (!)
\# Replaces with a dollar sign ($) (Useful for evars, for example
\#litestepdir\# will become $litestepdir$)
\~ Semicolon (;)
\1 Ignored and used in !xTextReplace(All) for () matches (explained
below also with \2, \3 ,...)
Any other use of backslash will be ignored unless it is used for a
character used in regexps, such as * or \.
------------
So @(^%1 \=)(.*\\)(.*\..*\=)_@ breaks down to (using [] for delimiters
here):
1) Everything from start of line to first occurrence of [ "] is
assigned to the first pattern; this is the evar name plus the space that
separates it from the evar value. My evar values are *always* quoted -
that's how xtextedit saves things, and any scripts I write maintain that
convention.
2) The second pattern captures any sequence of characters [.*] ending
with a backslash [\]; this will be the "path".
3) The third sequence captures a series of characters (the file name)
[.*] followed by a dot [\.] followed by another series of characters
(the extension) [.*] that ends with a quote [\=] and is then followed by
the end of the line [_].
We write out the first and third patterns, tossing the second [@\1\3@],
so that
name "c:\path\more_path\filename.extension"
becomes
name "filename.extension"
!stripextension does the same thing, only now we've assigned the
filename to the first sequence we match (^%1 \=.*), %1 being the evar
name we're modifying, and the extension to the second sequence, which is
then discarded. We write out only the first pattern, then add a quote,
as we lumped (and discarded) that with the extension [@\1\=@].
QED =)
---------------------------------------------------------------------
Can't Unsubscribe? Check http://desktopian.org/listunsub.html
LS List Homepage: http://wuzzle.org/list/litestep.php
Get the LS FAQ: http://lsfaq.shellfront.org