HydrogenAudio

Hosted Forums => foobar2000 => 3rd Party Plugins - (fb2k) => Topic started by: foosion on 2015-03-11 23:27:58

Title: foo_tfsandbox
Post by: foosion on 2015-03-11 23:27:58
This component provides an editor for title formatting code. The editor includes syntax highlighting, a preview of the selected fragment of the code and a view of the code structure. The idea behind the component is to allow users to explore title formatting scripts by exposing aspects which are normally hidden on the user interface of foobar2000 and its components.

The component is mainly targeted at title formatting beginners. I do not intend to add advanced IDE features. I am aware that some parts of the component only work well for small scripts. This applies both to the chosen presentation and the performance. Fixing these performance issues is not very high on my list of priorities. A simple remedy is to not torture the component with hundreds of lines of title formatting code.

(https://github.com/stengerh/foo_tfsandbox/raw/master/foo_tfsandbox-1.png)

Installation

Download the component from the releases page on github.com or from the official foobar2000 component site. Links to both side can be found at the end of this post. Use the normal procedure to install the component package.

If you insist on unpacking the component package and installing the component manually make sure to install all three DLL contained in the package into the same folder. Do not try to replace the SciLexer.dll from this component with the one from foo_wave_seekbar or vice versa!

Usage

Use the "Title Formatting Sandbox" command in the "View" menu of the main menu to open the Title Formatting Sandbox window. Use the close button in the title bar of the window to close it. The window remembers its position and editor content when it is closed.

The window consists of three parts: the editor, the structure view and the preview field.

The editor covers the middle and top left side of the window. You can edit title formatting code here. The editor provides syntax highlighting to distinguish different types of title formatting constructs (text, fields, function calls). It uses dimmed colours to mark code which is not executed for the playing track, e.g. the branch of an $if statement which was not taken. A translucent background indicates the smallest syntactically correct fragment of code which contains the current selection or the current cursor position if the selection is empty. The value of this fragment will be displayed in the preview field. The editor also displays a tooltip for an expression if you hover the moise pointer over it.

The structure view is on the right side of the window. It displays the structure of the code using a tree view. The labels of the entries are coloured using the same colours as in the editor. The value of the selected entry will be displayed in the preview field.

The preview field is on the bottom side of the window. It displays the value of the selected fragment of title formatting code. The selected fragment is taken either from the editor or the structure view depending on which one of these has the focus. The value of the fragment is determined based on the playing track in the context of the entire title formatting code in the editor. This means if you select a function call like "$get(X)" the preview field will display the value the variable X has at this point in the code.

Consistency with foobar2000

The component tries to interpret title formatting code in the same way as foobar2000 itself. In same cases it was not practical to be perfectly consistent with foobar2000. Most of these will not be relevant to the average user. They are documented here anyway for completeness.

There are some cases where the component uses a stricter title formatting syntax than foobar2000 itself. For example it always treats commas as special characters. If you want a comma to be treated as text you need to enclose it in single quotation marks. This is good practice anyway and makes the grammar simpler.

There are also some cases where the component evaluates title formatting code differently than foobar2000 itself. A notable example is the Boolean value of a constant expression. The foobar2000 title formatting compiler evaluates expressions at compile time if they only contain constants and some of the built-in functions. The compiler then replaces the expression with a string constant whose Boolean value is always false. I consider this to be a bug in the title formatting compiler and made no effort to reproduce the effect in this component.

Links
Title: foo_tfsandbox
Post by: carpman on 2015-03-12 00:50:11
Already been useful.
Thanks foosion.

C.
Title: foo_tfsandbox
Post by: Takaji on 2015-03-12 00:53:21
Thanks foosion, looking forward to getting better with title formatting with this!
Title: foo_tfsandbox
Post by: Daeron on 2015-03-12 01:14:52
Thanks foosion. Should be really useful for starters.

Only thinking out loud in this post. Don't take anything I say as a serious request.

At a quick glance, things I thought newbies may run into that aren't currently 'addressed':
- Special fields: %isplaying%, %list_index%. Maybe show 'Not available in this context' as output with a different color/icon when the exact line is highlighted? Ignore otherwise?
- Tag splitting: %<genre>%. Album list specific, but given the popularity of that component among starters, I expect it to come up often.
- Columns UI stuff: $rgb(). Colorize the output? Ignore? Ignore with a warning that it's only available when using CUI?
- Special characters: ★. Foobar shows these just fine even when $char() is not used. Show it, but maybe tell them to do so?

Perhaps add a quick link to the titleformatting wiki? It will be redundant with 'Help/Title formatting help', but does newbies even notice that?

While we are at it, perhaps advertise the component on the wiki page (http://wiki.hydrogenaud.io/index.php?title=Foobar2000:Title_Formatting_Reference) from now on?
Title: foo_tfsandbox
Post by: Falstaff on 2015-03-12 06:47:35
thanks foosion, that's a great add
Title: foo_tfsandbox
Post by: MachineHead on 2015-03-12 07:28:16
Five seconds after installing...I swear I didn't try to do this on purposes, foosion. 

http://i.imgur.com/3uwKtTW.png (http://i.imgur.com/3uwKtTW.png)

Unicode - is it me or does it need some loving?
Title: foo_tfsandbox
Post by: foosion on 2015-03-12 07:41:27
Thanks for the feedback everyone! I actually started this component quite some time ago but it had been gathering dust for a few years now. I picked it up in the second half of 2014 and gave it some polish. There are still a few more feature I would like to see in the component, Daeron found some of them.  I am in a hurry now so I will comment the suggestions later.
Title: foo_tfsandbox
Post by: foosion on 2015-03-12 07:43:17
And we have the first bug report. It looks like the preview field is not set up to use UTF-8. Thanks for reporting!
Title: foo_tfsandbox
Post by: bulletproof2k on 2015-03-12 12:08:18
The really essential component, thanks)
Title: foo_tfsandbox
Post by: DustMagnet on 2015-03-12 17:04:34
Thank you, foosion. Excellent plug-in.
Title: foo_tfsandbox
Post by: samithaj on 2015-03-12 17:57:48
Thanks foosion!!! Very useful for beginners
Title: foo_tfsandbox
Post by: jazzthieve on 2015-03-12 18:24:58
This looks very handy, always used Notepad+ before but I think I will use this instead.
Title: foo_tfsandbox
Post by: foosion on 2015-03-13 07:17:35
Version 1.0.1 is out. It fixes the bug reported by MachineHead.
Title: foo_tfsandbox
Post by: eahm on 2015-03-13 18:17:42
Outstanding, thanks for this! Here is my first little issue I didn't notice before:

When I enter my conversion code everything works perfectly but this sandbox shows two \\, how do I clean this? Thanks.

Code:
Code: [Select]
$if($meta(album artist,0),%album artist%\[%date% - ][%album%]\[D%discnumber%]\[%tracknumber%. ][%title%],[%artist%]\[%date% - ][%album%]\[D%discnumber%]\[%tracknumber%. ][%title%])


Screenshot:
No multiple discs, no Various Artists
(http://i.imgur.com/JHMYqff.png)

Multiple discs:
(http://i.imgur.com/zYTfCTF.png)

Various Artists:
(http://i.imgur.com/MIVBTTl.png)

Various Artists, multiple discs:
(http://i.imgur.com/5lqp2tR.png)
Title: foo_tfsandbox
Post by: lvqcl on 2015-03-13 18:27:21
for example:
Code: [Select]
$if($meta(album artist,0),%album artist%\[[%date% - ]%album%\][D%discnumber%\][%tracknumber%. ][%title%],[%artist%]\[[%date% - ]%album%\][D%discnumber%\][%tracknumber%. ][%title%])
Title: foo_tfsandbox
Post by: eahm on 2015-03-13 18:32:19
Perfect, thanks lvqcl.

Lossy:
Code: [Select]
$if($meta(album artist,0),%album artist%\[[%date% - ]%album%\][D%discnumber%\][%tracknumber%. ][%title%],[%artist%]\[[%date% - ]%album%\][D%discnumber%\][%tracknumber%. ][%title%])

Lossless:
Code: [Select]
$if($meta(album artist,0),%album artist%\[[%date% - ]%album%' [L]'\][D%discnumber%\][%tracknumber%. ][%title%],[%artist%]\[[%date% - ]%album%' [L]'\][D%discnumber%\][%tracknumber%. ][%title%])

Car:
Code: [Select]
$if($meta(album artist,0),%album artist% [[%date% ]%album%\][D%discnumber% ][%tracknumber% ][%title%],[%artist% ][[%date% ]%album%\][D%discnumber% ][%tracknumber% ][%title%])
Title: foo_tfsandbox
Post by: Josh Lincoln on 2015-06-20 18:27:58
...
The component is mainly targeted at title formatting beginners. I do not intend to add advanced IDE features. I am aware that some parts of the component only work well for small scripts. This applies both to the chosen presentation and the performance. Fixing these performance issues is not very high on my list of priorities. A simple remedy is to not torture the component with hundreds of lines of title formatting code.
...

What is IDE?
Title: foo_tfsandbox
Post by: marc2003 on 2015-06-20 18:45:16
https://en.wikipedia.org/wiki/Integrated_de...ent_environment (https://en.wikipedia.org/wiki/Integrated_development_environment)
Title: foo_tfsandbox
Post by: TheEmpathicEar on 2015-07-19 20:13:20
Perfect, thanks lvqcl.

Lossy:
Code: [Select]
$if($meta(album artist,0),%album artist%\[[%date% - ]%album%\][D%discnumber%\][%tracknumber%. ][%title%],[%artist%]\[[%date% - ]%album%\][D%discnumber%\][%tracknumber%. ][%title%])

Lossless:
Code: [Select]
$if($meta(album artist,0),%album artist%\[[%date% - ]%album%' [L]'\][D%discnumber%\][%tracknumber%. ][%title%],[%artist%]\[[%date% - ]%album%' [L]'\][D%discnumber%\][%tracknumber%. ][%title%])

Car:
Code: [Select]
$if($meta(album artist,0),%album artist% [[%date% ]%album%\][D%discnumber% ][%tracknumber% ][%title%],[%artist% ][[%date% ]%album%\][D%discnumber% ][%tracknumber% ][%title%])

I just started looking at this. What distinguishes Lossy, Lossless and Car above?
Title: foo_tfsandbox
Post by: luk3Z on 2015-12-06 10:10:09
Hi.
I'm using default user interface of foobar 1.3.9 (foo_ui_std 0.9.5).
I downloaded this component today and started some "experiments", so I have few questions:

1. why variables like %list_total% is not working in status bar formatting i.e.: ★ Now playing: %artist% - %title% | total tracks: %list_total%
http://wiki.hydrogenaud.io/index.php?title...25list_total.25 (http://wiki.hydrogenaud.io/index.php?title=Foobar2000:Titleformat_Reference#.25list_total.25)
and where can I use this variables ?

2. why variables like %play_count% is not working in status bar formatting [Titleformat Playback Statistics]
http://wiki.hydrogenaud.io/index.php?title...back_Statistics (http://wiki.hydrogenaud.io/index.php?title=Foobar2000:Titleformat_Playback_Statistics)
and where can I use this variables ?

3. do I need "Playback Statistics Component" or foobar have build in some functions of statistics ?:
http://www.foobar2000.org/components/view/foo_playcount (http://www.foobar2000.org/components/view/foo_playcount)
http://wiki.hydrogenaud.io/index.php?title...(foo_playcount) (http://wiki.hydrogenaud.io/index.php?title=Foobar2000:Components/Playback_Statistics_v3.x_(foo_playcount))

Thanks fo any reply 
Title: foo_tfsandbox
Post by: foosion on 2015-12-06 21:04:59
1. why variables like %list_total% is not working in status bar formatting i.e.: ? Now playing: %artist% - %title% | total tracks: %list_total%
http://wiki.hydrogenaud.io/index.php?title...25list_total.25 (http://wiki.hydrogenaud.io/index.php?title=Foobar2000:Titleformat_Reference#.25list_total.25)
and where can I use this variables ?
%list_total% works in the playlist (and a few other places which deal with lists).

2. why variables like %play_count% is not working in status bar formatting [Titleformat Playback Statistics]
http://wiki.hydrogenaud.io/index.php?title...back_Statistics (http://wiki.hydrogenaud.io/index.php?title=Foobar2000:Titleformat_Playback_Statistics)
and where can I use this variables ?

3. do I need "Playback Statistics Component" or foobar have build in some functions of statistics ?:
http://www.foobar2000.org/components/view/foo_playcount (http://www.foobar2000.org/components/view/foo_playcount)
http://wiki.hydrogenaud.io/index.php?title...(foo_playcount) (http://wiki.hydrogenaud.io/index.php?title=Foobar2000:Components/Playback_Statistics_v3.x_(foo_playcount))
There is no built-in playback statistics function. You need foo_playcount for that and the %play_count% field.

Note that many special fields and functions are not available in the title formatting sandbox. The sandbox only supports the functions and fields which work everywhere.
Title: Re: foo_tfsandbox
Post by: fuffi on 2016-10-23 15:36:28
Thank you for this component! I guess, I've searched my half foobar2000-life for such a useful goodie! And now, I've found it accidentially while browsing the f2k-components-pages looking for something completely different....will give it a try.

Note that many special fields and functions are not available in the title formatting sandbox. The sandbox only supports the functions and fields which work everywhere.
Hope, I keep that in mind....
Title: Re: foo_tfsandbox
Post by: fuffi on 2016-11-02 11:55:17
So far, that component is a WIN! thank you again.

Would it be possible to allow resizing of that window?

Maybe also allow to move/resize those single parts (the code, the tree view and the result) of the windows?
(and remember their positions the next time, the component is started)

That would help much dealing with long and complex code.


(https://picload.org/image/rdirciog/screenshot.png)
Title: Re: foo_tfsandbox
Post by: foosion on 2016-11-02 18:52:53
Resizing the window is already on my private wishlist. In the mean time the best way to deal with complex title formatting code inside and outside of the component is to add line breaks. ;)
Title: Re: foo_tfsandbox
Post by: wcs13 on 2016-12-06 19:01:22
+1 for window resizing (option to make it full screen + drag & drop of the splitters). I hope that won't be too long to implement sometime soon.  O:)
Title: Re: foo_tfsandbox
Post by: foosion on 2016-12-13 23:42:55
Version 1.0.2 is out. The window just got resizable.

The width of the code structure view and the height of the output view are still fixed. They will become resizable in a later version. See foo_tfsandbox/#3 (https://github.com/stengerh/foo_tfsandbox/issues/3) on GitHub.
Title: Re: foo_tfsandbox
Post by: always.beta on 2016-12-14 15:08:26
When the playlist is empty, click View>tfsandbox, > crash.
Title: Re: foo_tfsandbox
Post by: foosion on 2016-12-14 20:46:14
Thanks for reporting. I reproduced the crash and documented the exact conditions at foo_tfsandbox/#4 (https://github.com/stengerh/foo_tfsandbox/issues/4) on GitHub.
Title: Re: foo_tfsandbox
Post by: foosion on 2016-12-14 20:56:52
Version 1.0.3 is out. It fixes the crash reported by always.beta.
Title: Re: foo_tfsandbox
Post by: millzeyweb on 2017-01-09 22:06:50
Thanks for the updates and responding to feature requests.

I'm on Win7 with v1.0.3 and cant move the splitters, is that normal? I went straight to trying to hack the window size with authotkey before I saw v1.0.3 (and it didnt work). The width of the tree view is the most useful for me in regards to resizing. I'm trying to compare two fairly complex strings, and cant get any decent screenshot of the tree view.

If there was some sort of export for the tree that would be cool. But even better would be automatic formatting/indenting of the code pasted in the first box, with line feeds of course of legibility which could then be copy/pasted back and forth in a code editor. Then when desired result reached line feeds removed to paste in FB2K where needed. If this was implemented it wouldnt be dependent on the tree view 100% for easier interpretation/comparison of TF code. I've tried to manually indent/linefeed TF code for comparison of two TF strings or just to create/fix one, and its too confusing, but you've already got the tree view doing that.

If i've overlooked some functionality or purpose of the sandbox I apologize. Thanks again for the component.
Title: Re: foo_tfsandbox
Post by: foosion on 2017-01-10 07:50:19
You cannot move the splitters because that has not been implemented yet. Strictly speaking they are not even splitters yet, just empty space between two widgets.

Thanks for your suggestions about making the structure of the script easier to understand. I am aware that the tree view is inadequate for the nesting depth of most real-life scripts. My goal with the title formatting sandbox is to make it easier for people to learn and understand title formatting. I therefore implemented various features to make things visible that normally aren't while keeping the semantics of normal title formatting including the notion that tabs and spaces are significant. I am therefore wary to add an (automatic) indentation feature.
Title: Re: foo_tfsandbox
Post by: Porcus on 2017-01-10 10:01:01
Possible wishlist items, possibly soon to be discarded for being too much work:

* Items for (highlight &) right-click menu: "Save as"/"Export to", and also "Open"/"Import from" the following
- file copy/move/rename preset
- Window title / Status bar / Notification area tooltip
- text file

* When editing file copy/move/rename patterns, or convert to file naming patterns, or Window title / Status bar / Notification area tooltip patterns:
- Right-click -> open sandbox
(This possibly requires several instances. Or maybe, just put the string on top of the buffer window.)
Title: Re: foo_tfsandbox
Post by: foosion on 2017-01-10 20:10:00
Actually I think those are reasonable feature requests. Most of them have been at the back of my mind since I began working on the plugin (see issues #6 (https://github.com/stengerh/foo_tfsandbox/issues/6), #7 (https://github.com/stengerh/foo_tfsandbox/issues/7), #8 (https://github.com/stengerh/foo_tfsandbox/issues/8) on GitHub). However some of them are not feasible without the cooperation of other components (see issue #9 (https://github.com/stengerh/foo_tfsandbox/issues/9)).
Title: Re: foo_tfsandbox
Post by: fuffi on 2017-09-08 20:54:46
Hello foosion,

your component is a big help, though it is no big fun without sliders to resize the portions of the window, when dealing with long code (nag nag nag nag...). ;-D

Anyways,
can we -somehow- define where the input for the "preview field" comes from? And make it stick over sessions (close and open the sandbox-windows).

You wrote, it is taken from the actual playing song, but -for me- this is not a useful context.
The now playing song changes very often while I'm jumping in and out of the sandbox window and starting the test-song again (because of its tags) *and* listen to it again and again (and the follow up songs) is... well...kinda boring.

Maybe  I didn't figure out, how to define a fix file/track for the preview, and it is very simple?

Title: Re: foo_tfsandbox
Post by: Fabcore on 2021-06-02 20:35:41
Hi foosion, loving this component so much but, can you please update the interface to "night mode"?
X
Thanks in advance
Regards.
Title: Re: foo_tfsandbox
Post by: mjm716 on 2021-06-03 03:44:15
Regards.

re: screenshot: any reason you don't find and correct the tags rather than code for bad data?
(e.g. display %album artist%/<TAG> in facets/playlist viewer/... and change variants to standard "Various Artists")   

just askin for a friend :)
Title: Re: foo_tfsandbox
Post by: Fabcore on 2021-06-03 17:04:20
re: screenshot: any reason you don't find and correct the tags rather than code for bad data?
(e.g. display %album artist%/<TAG> in facets/playlist viewer/... and change variants to standard "Various Artists")   
just askin for a friend :)
of course i tag the bad data but when manage thousans of albums the things becomes quite time consuming, so, i code that for the sake of 'detection' the bad or missing fields in certains tags and make the rid of that. In that case, the code on the screenshot is for album artist/ artist.
SimplePortal 1.0.0 RC1 © 2008-2021