Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Titleformat Editor (Read 1535 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Titleformat Editor

Hi,

Back in time I used to do some pretty complex titleformat scripts (I'm looking at one right now, it's 11.000 chars long  :o ).
Time has passed, and those scripts are now almost unreadable for me, unless I could copy/paste them into a nice editor that would auto-indent them and auto-color them so I could understand how they work.

Does such editor exist ?

Thanks in advance.

Re: Titleformat Editor

Reply #1
Notepad++ is probably good enough for most people. Someone shared this or something very similar to it on the forums years ago that I had saved.

userDefineLang.xml:
Code: [Select]
<NotepadPlus>
    <UserLang name="foobar2000" ext="foob TAGZ fcs foo cfg">
        <Settings>
            <Global caseIgnored="yes" />
            <TreatAsSymbol comment="no" commentLine="no" />
            <Prefix words1="no" words2="no" words3="no" words4="no" />
        </Settings>
        <KeywordLists>
            <Keywords name="Delimiters">&apos;00&apos;00</Keywords>
            <Keywords name="Folder+">BlockBegin</Keywords>
            <Keywords name="Folder-">BlockEnd</Keywords>
            <Keywords name="Operators">&apos; ( ) , [ ] | =</Keywords>
            <Keywords name="Comment">1 1 2 2 0//</Keywords>
            <Keywords name="Words1">%album artist% %album% %date% %artist% %title% %tracknumber% %genre% %subgenre% %performer% %instrument% %composer% %conductor% %orchestra% %publisher% %work% %cat#% %tempo% %bitrate% %discnumber% %situation% %rating% %emyfav% %bpm% %check sm% %score% %check ly% %lyrics% %check tad% %check q% %check gs% %check pi% %check lc% %added% %downloaded% %length% %cwb_systemdate% %special%</Keywords>
            <Keywords name="Words2">%isplaying% %_ispaused% %_composer% %_comment% %__channels% %_date% %_directoryname% %disc% %_diskwriter_index% %_foobar2000_version% %_filename% %_filename_ext% %_genre% %_isplaying% %ispaused% %_length% %_length_seconds% %_path% %_path_raw% %_playlist_number% %_subsong% %__bitrate% %__extrainfo% %__replaygain_album_gain% %__replaygain_album_peak% %__replaygain_track_gain% %__replaygain_track_peak% %__samplerate% %playback_time% %length% %length_seconds% %_time_elapsed% %_time_elapsed_seconds% %_time_remaining% %_time_remaining_seconds% %play_count% %codec% %codec_profile% %filename% %filename_ext% %directoryname% %path% %subsong% %path_sort% %length_seconds% %filesize% %bitrate% %channels% %samplerate% %__mp3_stereo_mode% %added% %_system_year% %_system_month% %_system_day% %_system_hour% %last_played% %_selected_back% %_back% %_selected_back_no_focus% %_selected_text% %_time_total% %_time_total_seconds% %bitrate% %_width% %_height% %_trackinfo_mode% %_trackinfo_notrack% %cwb_systemdate% %cwb_systemdatetime% %cwb_activelist% %cwb_activelist_count% %cwb_playinglist% %cwb_playinglist_count% %cwb_queueindex% %cwb_queueindexes% %cwb_queuelength% %cwb_queue_end_playlist% %cwb_next_title% %cwb_next_artist% %cwb_playback_order%</Keywords>
            <Keywords name="Words3">$if $if2 $if3 $ifequal $ifgreater $iflonger $select $repeat $panel $drawrect $font $imageabs $imageabs2 $button $button2 $sorted $pad</Keywords>
            <Keywords name="Words4">$put $puts $get $abbr $lower $upper $num $caps $caps2 $len $pad $pad_right $cut $padcut $padcut_right $insert $add $sub $mul $div $muldiv $mod $min $max $left $right $and $or $xor $not $fix_eol $fix_eol2 $meta $meta_sep $mets_num $mets_test $info $char $strcmp $stricmp $directory $greater $longer $strchr $strrchr $strstr $progress $progress2 $replace $ext $substr $rgb $transition $blend $rand $trim $tab $crlf $longest $shortest $set_style $calculate_blend_target $offset_colour $setpvar $glass $getpvar $eval $align $alignset $alignrel $alignabs $calcwidth $calcheight $fileexists $cwb_urldecode $cwb_httpclean $cwb_removethe $cwb_ltrim $cwb_datediff</Keywords>
        </KeywordLists>
        <Styles>
            <WordsStyle name="DEFAULT" styleID="11" fgColor="000000" bgColor="FFFFFF" fontName="Courier New" fontStyle="0" fontSize="10" />
            <WordsStyle name="FOLDEROPEN" styleID="12" fgColor="FF8000" bgColor="FFFF80" fontName="" fontStyle="0" />
            <WordsStyle name="FOLDERCLOSE" styleID="13" fgColor="FF8040" bgColor="FFFF80" fontName="" fontStyle="0" />
            <WordsStyle name="KEYWORD1" styleID="5" fgColor="0000FF" bgColor="FFFFFF" fontName="Arial" fontStyle="0" fontSize="10" />
            <WordsStyle name="KEYWORD2" styleID="6" fgColor="4646FF" bgColor="FFFFFF" fontName="Arial" fontStyle="0" fontSize="10" />
            <WordsStyle name="KEYWORD3" styleID="7" fgColor="FF0000" bgColor="FFFFFF" fontName="Courier New" fontStyle="0" fontSize="11" />
            <WordsStyle name="KEYWORD4" styleID="8" fgColor="FF4646" bgColor="FFFFFF" fontName="Courier New" fontStyle="0" fontSize="11" />
            <WordsStyle name="COMMENT" styleID="1" fgColor="FFFF00" bgColor="FFFFFF" fontName="" fontStyle="0" />
            <WordsStyle name="COMMENT LINE" styleID="2" fgColor="008000" bgColor="FFFFFF" fontName="Arial" fontStyle="2" fontSize="10" />
            <WordsStyle name="NUMBER" styleID="4" fgColor="FF0080" bgColor="FFFFFF" fontName="Arial" fontStyle="0" fontSize="10" />
            <WordsStyle name="OPERATOR" styleID="10" fgColor="000000" bgColor="FFFFFF" fontName="Courier New" fontStyle="0" />
            <WordsStyle name="DELIMINER1" styleID="14" fgColor="A25151" bgColor="FFFFFF" fontName="Arial" fontStyle="0" />
            <WordsStyle name="DELIMINER2" styleID="15" fgColor="FFFFFF" bgColor="FFFFFF" fontName="" fontStyle="0" />
        </Styles>
    </UserLang>
</NotepadPlus>

Example:


I'm not exactly sure it'll help you unboggle whatever nightmarish creature you have created, though.

Re: Titleformat Editor

Reply #2
Updated version of the notepad++ language script

Code: [Select]
<NotepadPlus>
    <UserLang name="foobar2000" ext="foob TAGZ fcs foo cfg" udlVersion="2.1">
        <Settings>
            <Global caseIgnored="yes" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
            <Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
        </Settings>
        <KeywordLists>
            <Keywords name="Comments">03 03 04 04 00// 01 02</Keywords>
            <Keywords name="Numbers, prefix1"></Keywords>
            <Keywords name="Numbers, prefix2"></Keywords>
            <Keywords name="Numbers, extras1"></Keywords>
            <Keywords name="Numbers, extras2"></Keywords>
            <Keywords name="Numbers, suffix1"></Keywords>
            <Keywords name="Numbers, suffix2"></Keywords>
            <Keywords name="Numbers, range"></Keywords>
            <Keywords name="Operators1">&apos; ( ) , [ ] | =</Keywords>
            <Keywords name="Operators2"></Keywords>
            <Keywords name="Folders in code1, open">BlockBegin</Keywords>
            <Keywords name="Folders in code1, middle"></Keywords>
            <Keywords name="Folders in code1, close">BlockEnd</Keywords>
            <Keywords name="Folders in code2, open"></Keywords>
            <Keywords name="Folders in code2, middle"></Keywords>
            <Keywords name="Folders in code2, close"></Keywords>
            <Keywords name="Folders in comment, open"></Keywords>
            <Keywords name="Folders in comment, middle"></Keywords>
            <Keywords name="Folders in comment, close"></Keywords>
            <Keywords name="Keywords1">%album artist% %album% %date% %artist% %title% %tracknumber% %genre% %subgenre% %performer% %instrument% %composer% %conductor% %orchestra% %publisher% %work% %cat#% %tempo% %bitrate% %discnumber% %situation% %rating% %emyfav% %bpm% %check sm% %score% %check ly% %lyrics% %check tad% %check q% %check gs% %check pi% %check lc% %added% %downloaded% %length% %cwb_systemdate% %special%</Keywords>
            <Keywords name="Keywords2">%isplaying% %_ispaused% %_composer% %_comment% %__channels% %_date% %_directoryname% %disc% %_diskwriter_index% %_foobar2000_version% %_filename% %_filename_ext% %_genre% %_isplaying% %ispaused% %_length% %_length_seconds% %_path% %_path_raw% %_playlist_number% %_subsong% %__bitrate% %__extrainfo% %__replaygain_album_gain% %__replaygain_album_peak% %__replaygain_track_gain% %__replaygain_track_peak% %__samplerate% %playback_time% %length% %length_seconds% %_time_elapsed% %_time_elapsed_seconds% %_time_remaining% %_time_remaining_seconds% %play_count% %codec% %codec_profile% %filename% %filename_ext% %directoryname% %path% %subsong% %path_sort% %length_seconds% %filesize% %bitrate% %channels% %samplerate% %__mp3_stereo_mode% %added% %_system_year% %_system_month% %_system_day% %_system_hour% %last_played% %_selected_back% %_back% %_selected_back_no_focus% %_selected_text% %_time_total% %_time_total_seconds% %bitrate% %_width% %_height% %_trackinfo_mode% %_trackinfo_notrack% %cwb_systemdate% %cwb_systemdatetime% %cwb_activelist% %cwb_activelist_count% %cwb_playinglist% %cwb_playinglist_count% %cwb_queueindex% %cwb_queueindexes% %cwb_queuelength% %cwb_queue_end_playlist% %cwb_next_title% %cwb_next_artist% %cwb_playback_order%</Keywords>
            <Keywords name="Keywords3">$if $if2 $if3 $ifequal $ifgreater $iflonger $select $repeat $panel $drawrect $font $imageabs $imageabs2 $button $button2 $sorted $pad</Keywords>
            <Keywords name="Keywords4">$put $puts $get $abbr $lower $upper $num $caps $caps2 $len $pad $pad_right $cut $padcut $padcut_right $insert $add $sub $mul $div $muldiv $mod $min $max $left $right $and $or $xor $not $fix_eol $fix_eol2 $meta $meta_sep $mets_num $mets_test $info $char $strcmp $stricmp $directory $greater $longer $strchr $strrchr $strstr $progress $progress2 $replace $ext $substr $rgb $transition $blend $rand $trim $tab $crlf $longest $shortest $set_style $calculate_blend_target $offset_colour $setpvar $glass $getpvar $eval $align $alignset $alignrel $alignabs $calcwidth $calcheight $fileexists $cwb_urldecode $cwb_httpclean $cwb_removethe $cwb_ltrim $cwb_datediff</Keywords>
            <Keywords name="Keywords5"></Keywords>
            <Keywords name="Keywords6"></Keywords>
            <Keywords name="Keywords7"></Keywords>
            <Keywords name="Keywords8"></Keywords>
            <Keywords name="Delimiters">00&apos; 01 02&apos; 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23</Keywords>
        </KeywordLists>
        <Styles>
            <WordsStyle name="DEFAULT" fgColor="000000" bgColor="FFFFFF" fontName="Courier New" fontStyle="0" fontSize="10" nesting="0" />
            <WordsStyle name="COMMENTS" fgColor="FFFF00" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="LINE COMMENTS" fgColor="008000" bgColor="FFFFFF" fontName="Arial" fontStyle="2" fontSize="10" nesting="0" />
            <WordsStyle name="NUMBERS" fgColor="FF0080" bgColor="FFFFFF" fontName="Arial" fontStyle="0" fontSize="10" nesting="0" />
            <WordsStyle name="KEYWORDS1" fgColor="0000FF" bgColor="FFFFFF" fontName="Arial" fontStyle="0" fontSize="10" nesting="0" />
            <WordsStyle name="KEYWORDS2" fgColor="4646FF" bgColor="FFFFFF" fontName="Arial" fontStyle="0" fontSize="10" nesting="0" />
            <WordsStyle name="KEYWORDS3" fgColor="FF0000" bgColor="FFFFFF" fontName="Courier New" fontStyle="0" fontSize="11" nesting="0" />
            <WordsStyle name="KEYWORDS4" fgColor="FF4646" bgColor="FFFFFF" fontName="Courier New" fontStyle="0" fontSize="11" nesting="0" />
            <WordsStyle name="KEYWORDS5" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS6" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS7" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="OPERATORS" fgColor="000000" bgColor="FFFFFF" fontName="Courier New" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN CODE1" fgColor="FF8000" bgColor="FFFF80" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN CODE2" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS1" fgColor="A25151" bgColor="FFFFFF" fontName="Arial" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS2" fgColor="FFFFFF" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS3" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS4" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS5" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS6" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS7" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
        </Styles>
    </UserLang>
</NotepadPlus>

Re: Titleformat Editor

Reply #3
Thanks guys. That looks great. I'm close to making it work, but I can't get auto-indent yet. It still shows all my titleformat code in one single line.

I have :
- Installed Notepad++ (latest version : 7.6.6 x64)
- Created the userDefineLang.xml file (even renamed it foobar2000.xml), using the updated language script
- Put it inside Notepad++'s "Localization" subfolder
- Launched Notepad++
- Language > Define your language > Import... > Selected the userDefineLang.xml file > Import successful
- Restarted Notepad++
- Selected "foobar2000" language
- Opened a "test.txt" file with some titleformat code

So now the colors seem to work. But how about the auto-indent ? I need it to understand "whatever nightmarish creature I have created" !  :D

Re: Titleformat Editor

Reply #4
What's the problem? You can't read your own code without indents? That makes little sense. Just read through your code and arrange it with indents as you see fit.
Personally, I think separating block elements of code and using titles is way more handy when organizing code. I very rarely use indents with titleformatting.

Re: Titleformat Editor

Reply #5
My code doesn't have any indents nor spacing. Here's a very short example :

Code: [Select]
$if($strcmp(%see again%,'Oui'),$rgb(144,255,144),$if($strcmp(%see again%,'Peut-être'),$rgb(255,179,51),$if($strcmp(%see again%,'Non'),$rgb(153,153,153),)))%title%$rgb(149,149,149)['  ['%version%']']['  ['%guests%']']$rgb()
Now imagine the same with 11.000 chars.
I'd like a software that would be able to create automatic indents based on the syntax. E.g. after an $if( , or after an $if( followed by its first argument, or whatever.
A software that would analyze my previous code and automatically display something like this :

Code: [Select]
$if($strcmp(%see again%,'Oui'),
---- $rgb(144,255,144),
---- $if($strcmp(%see again%,'Peut-être'),
-------- $rgb(255,179,51),
-------- $if($strcmp(%see again%,'Non'),
------------ $rgb(153,153,153),
-------- )
---- )
)
%title%$rgb(149,149,149)['  ['%version%']']['  ['%guests%']']$rgb()
I can't imagine having to do that by hand for a 11.000 char code. Especially since I have a lot of long codes like that one.

Re: Titleformat Editor

Reply #6
Code: [Select]
$if($strcmp(%see again%,'Oui'),$rgb(144,255,144),
$if($strcmp(%see again%,'Peut-être'),$rgb(255,179,51),
$if($strcmp(%see again%,'Non'),$rgb(153,153,153),
)))

%title%$rgb(149,149,149)['  ['%version%']']['  ['%guests%']']$rgb()

2 seconds work, easily readable.

Also, I doubt your entire code is full of nested ifs. 11.000 chars full of nested ifs?? Btw, 11.000 is decent, but it's not really massive. Just my elplaylist script is about the same and I can run through it and don't use indents at all.
Just go through your code and organize it, what you're looking for won't happen.

Re: Titleformat Editor

Reply #7
OK, that's great, thank you.
That's right : why use auto-indent when we can write code without it ?...
Well, maybe because it's easier to read. Or maybe because we just want to.
Indent was invented for a reason. Feel free to not use it if you want, I don't question your choices. But let other people use it if they want.

So now could we please just try to answer the previous question ? I'd just like to know if auto-indent can be done with Notepad++, maybe via a plug-in or something. @Daeron suggested it after me asking about auto-indent, so I guess he had something in mind. Right ?

Re: Titleformat Editor

Reply #8
I'd just like to know if auto-indent can be done with Notepad++, maybe via a plug-in or something.

Like I've mentioned before....NO, No auto indent with notepad++ for titleformatting.
But perhaps you want Daeron to mention the same before you give it up. Lets just wait for him then.

Re: Titleformat Editor

Reply #9
The styles have no indentation to them, it's just the coloring that helps with editing. Titleformatting is not supposed to be something super complicated.

Notepad++ might be capable of indenting some languages (probably via plugins), but I don't think anyone bothered to write one for foobar.

I guess there's also this component:
https://www.foobar2000.org/components/view/foo_tfsandbox

As I recall it didn't seem all that useful to me, given Np++ already did the syntax highlights and I think intendations aren't supported either.


Re: Titleformat Editor

Reply #11
Thanks a lot to both for the script. I was looking for something like this months ago. I think it would be a good idea to have one in the uploads section.

@wcs13  I don't know about indentation, but you can at least split the single line script using the extended search option. For example, usually a position  where a new line makes sense in a titleformatting expression is between a closed bracket and a dollar sign (there might be other options I can't think of right now).

So, for example, you can replace:
Code: [Select]
)$
with:
Code: [Select]
)\r\n$

It might not be the most sensible way to split lines, but it will make it more readable and than you can adjust it.

P.S.
In case I wasn't clear: I'm talking about notepad++



P.SS.
I made some quick test and I found these two replacements to be very useful to split lines in a reasonable way:

Code: [Select]
$
replace with:
Code: [Select]
\n$

and

Code: [Select]
),
replace with:
Code: [Select]
\n),\n
I'm late

Re: Titleformat Editor

Reply #12
Thanks to all of you. There are some interesting and complementary solutions in this thread.

Daeron, actually foosion's component worked pretty well on one of my long TF scripts (see pic). I just wonder WHY the narrow right part isn't resizeable, as you can see. Can that parameter be adjusted somewhere ?

davideleo, your method is interesting and I will try it on Notepad++. Let's see how it works.

PS : I know the shown code can be heavily optimized. First, it's only an example. And second, that was precisely the reason why I wanted to give it a look after some years ! lol