diff --git a/TextrudeInteractive/MainWindow.xaml.cs b/TextrudeInteractive/MainWindow.xaml.cs index b046da1..877015c 100644 --- a/TextrudeInteractive/MainWindow.xaml.cs +++ b/TextrudeInteractive/MainWindow.xaml.cs @@ -11,7 +11,6 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Media; -using System.Windows.Media.Imaging; using Engine.Application; using MaterialDesignExtensions.Controls; using TextrudeInteractive.Monaco.Messages; @@ -297,7 +296,7 @@ public void SetOutputPanes(EngineOutputSet outputControl, bool trim) //ensure there is always at least one output - otherwise things can get confusing for the user if (!_outputManager.Panes.Any()) - _outputManager.AddPane(new EditPaneViewModel()); + _outputManager.AddPane(ViewModelFactory.CreateOutput(OutputPaneModel.Empty, 0)); _outputManager.FocusFirst(); } diff --git a/examples/00_welcome.texproj b/examples/00_welcome.texproj new file mode 100644 index 0000000..5a3d4f7 --- /dev/null +++ b/examples/00_welcome.texproj @@ -0,0 +1,57 @@ +{ + "Version": 1, + "Description": "", + "EngineInput": { + "Definitions": [ + "", + "", + "", + "", + "color=blue", + "", + "size=large" + ], + "IncludePaths": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "Models": [ + { + "Format": 2, + "Text": "str: a string\r\nnum: 100\r\nlst:\r\n - 45\r\n - 23\r\n", + "Path": "", + "Name": "model" + }, + { + "Format": 1, + "Text": "Num,Description\r\n100,failure\r\n200,breakage", + "Path": "", + "Name": "model1" + } + ], + "Template": "\r\nHello \r\n {{env.USERNAME}} \r\n {{ date.now | \r\n date.to_string \u0022%r on %A, %d %h %Y\u0022}}\r\n\r\nYour model is: \r\n\u0060\u0060\u0060\r\n{{debug.dump model}}\r\n\u0060\u0060\u0060\r\nProperty access :\r\n \u0022{{model.str}}\u0022 \r\n\r\nArray access: \r\n {{model.lst[0] \u002B model.lst[1]}}\r\n\r\nThe \u0022model1\u0022 tab contains a CSV model \r\n\u0060\u0060\u0060\r\n{{debug.dump model1}}\r\n\u0060\u0060\u0060\r\nThe \u0022defs\u0022 tab contains::\r\n{{for d in def~}}\r\n {{for.index}}. \u0027{{d.key}}\u0027 is \u0027{{d.value}}\u0027\r\n{{~end}}\r\n\r\nThe _output1_ tab on the right should\r\ninclude text captured like this... \r\n{{capture output1}} \r\n Text for output1 window \r\n{{end}}\r\n\r\nOutput is regenerated whenever you edit \r\nthe template, models or definitions.\r\n\r\nMore examples are available; use \r\nProject-\u003ELoad from the menu. \r\n", + "TemplatePath": "" + }, + "OutputControl": { + "Outputs": [ + { + "Format": "markdown", + "Name": "output", + "Path": "" + }, + { + "Format": "text", + "Name": "output1", + "Path": "" + } + ] + } +} \ No newline at end of file diff --git a/examples/01_humanizr.texproj b/examples/01_humanizr.texproj new file mode 100644 index 0000000..5c04b05 --- /dev/null +++ b/examples/01_humanizr.texproj @@ -0,0 +1,38 @@ +{ + "Version": 1, + "Description": "", + "EngineInput": { + "Definitions": [ + "", + "", + "", + "", + "" + ], + "IncludePaths": [ + "", + "", + "", + "" + ], + "Models": [ + { + "Format": 1, + "Text": "text\r\na variable\r\nNameOfThing\r\nThe title of this book is\r\n\u0022 with spaces \u0022", + "Path": "", + "Name": "model" + } + ], + "Template": "** Textrude includes \r\n[Humanizr](https://github.com/Humanizr/Humanizer)\r\nfor convenient text processing.\r\n\r\n\r\n{{for v in model\r\ntxt =v.text\r\n}}\r\n# {{txt}}\r\n- _PASCALIZE_ \u0027{{txt | \r\n humanizr.pascalize}}\u0027\r\n- _CAMEL_ \u0027{{txt | \r\n humanizr.camelize}}\u0027\r\n- _UNDERSCORE_ \u0027{{txt | \r\n humanizr.underscore}}\u0027\r\n- _TITLE_ \u0027{{txt | \r\n humanizr.titleize}}\u0027\r\n- _KEBAB_ \u0027{{txt | \r\n humanizr.kebaberize}}\u0027\r\n{{end}}", + "TemplatePath": "" + }, + "OutputControl": { + "Outputs": [ + { + "Format": "markdown", + "Name": "output", + "Path": "" + } + ] + } +} \ No newline at end of file diff --git a/examples/02_include_library_scripts.texproj b/examples/02_include_library_scripts.texproj new file mode 100644 index 0000000..e468a7a --- /dev/null +++ b/examples/02_include_library_scripts.texproj @@ -0,0 +1,44 @@ +{ + "Version": 1, + "Description": "", + "EngineInput": { + "Definitions": [ + "", + "", + "", + "", + "" + ], + "IncludePaths": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "Models": [ + { + "Format": 3, + "Text": "", + "Path": "", + "Name": "model" + } + ], + "Template": "\r\n/***\r\n You can include scripts from the \r\n \u0027system\u0027 lib folder or from your\r\n own library. \r\n\r\n Additional include paths are specified \r\n in the \u0027inc\u0027 tab to the left. \r\n \r\n Here\u0027s a standard warning...\r\n ***/\r\n\r\n{{include \u0022lib/warnings.sbn\u0022}}\r\n{{autogenwarning}}", + "TemplatePath": "" + }, + "OutputControl": { + "Outputs": [ + { + "Format": "cpp", + "Name": "output", + "Path": "" + } + ] + } +} \ No newline at end of file diff --git a/examples/03_env_and_def.texproj b/examples/03_env_and_def.texproj new file mode 100644 index 0000000..e5dd3ea --- /dev/null +++ b/examples/03_env_and_def.texproj @@ -0,0 +1,46 @@ +{ + "Version": 1, + "Description": "", + "EngineInput": { + "Definitions": [ + "", + "", + "", + "", + "LANGUAGE=ENGLISH", + "", + "COUNTRY=United Kingdom" + ], + "IncludePaths": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "Models": [ + { + "Format": 3, + "Text": "", + "Path": "", + "Name": "model" + } + ], + "Template": "Textrude automatically provides access \r\nto environment variables via the \u0027env\u0027 \r\nnamespace:\r\n\r\nFor example, your username is: \r\n\r\n {{env.USERNAME}}\r\n\r\nAs well as environment variables, you\r\ncan supply your own definitions in the \r\n\u0027def\u0027 tab. These are available via \r\nthe \u0027def\u0027 namespace:\r\n\r\n {{def.LANGUAGE}} / {{def.COUNTRY}}\r\n\r\nYou can easily list all environment \r\nvariables using the debug.dump command:\r\n\r\n{{debug.dump env}}\r\n\r\nor just type \u0027env.\u0027 and use intellisense \r\n\r\n\r\n", + "TemplatePath": "" + }, + "OutputControl": { + "Outputs": [ + { + "Format": "markdown", + "Name": "output", + "Path": "" + } + ] + } +} \ No newline at end of file diff --git a/examples/04_multiple_models_and_outputs.texproj b/examples/04_multiple_models_and_outputs.texproj new file mode 100644 index 0000000..3d6eed7 --- /dev/null +++ b/examples/04_multiple_models_and_outputs.texproj @@ -0,0 +1,54 @@ +{ + "Version": 1, + "Description": "", + "EngineInput": { + "Definitions": [ + "", + "", + "", + "", + "" + ], + "IncludePaths": [ + "", + "", + "", + "" + ], + "Models": [ + { + "Format": 2, + "Text": "enumName: errors ", + "Path": "", + "Name": "names" + }, + { + "Format": 1, + "Text": "id,description\r\n123,disk\r\n34,display\r\n73,monitor\r\n5,keyboard\r\n2,camera\r\n", + "Path": "", + "Name": "errors" + } + ], + "Template": "You can use as many models or outputs as\r\nyou want.\r\n\r\nThis project has 2 models \r\n- \u0027names\u0027 - a yaml model\r\n- \u0027errors\u0027 - a csv file containing \r\n error descriptions\r\n\r\nand 3 outputs\r\n- \u0027output\u0027 which is the default\r\n- \u0027cpp\u0027 for a C\u002B\u002B source file\r\n- \u0027h\u0027 for a C\u002B\u002B header file\r\n\r\n\r\nTo write to a particular output, use the \r\ncapture keyword...\r\n\r\n{{typeName =names.enumName \u002B\u0022_t\u0022}}\r\n\r\n{{-capture h}}\r\n#pragma once\r\ntypedef enum {\r\n{{-for error in (errors | array.sort \u0022id\u0022)}}\r\n err_{{error.description}} = {{error.id}},\r\n{{-end}} \r\n} {{typeName}}; \r\n\r\n{{end}}\r\n\r\n\r\n{{-capture cpp}}\r\n#include \u0022err.h\u0022\r\nvoid showError({{typeName}} error) {\r\n{{for i in errors~}}\r\n if (error == {{i.id}})\r\n printf(\u0022ERROR - {{i.description}}\u0022);\r\nelse \r\n{{-end}}\r\n printf(\u0022UNKNOWN ERROR\u0022);\r\n} \r\n{{end}}\r\n", + "TemplatePath": "" + }, + "OutputControl": { + "Outputs": [ + { + "Format": "markdown", + "Name": "output", + "Path": "" + }, + { + "Format": "cpp", + "Name": "cpp", + "Path": "" + }, + { + "Format": "cpp", + "Name": "h", + "Path": "" + } + ] + } +} \ No newline at end of file diff --git a/examples/05_misc_functions.texproj b/examples/05_misc_functions.texproj new file mode 100644 index 0000000..e051ab3 --- /dev/null +++ b/examples/05_misc_functions.texproj @@ -0,0 +1,38 @@ +{ + "Version": 1, + "Description": "", + "EngineInput": { + "Definitions": [ + "", + "", + "", + "", + "" + ], + "IncludePaths": [ + "", + "", + "", + "" + ], + "Models": [ + { + "Format": 0, + "Text": "{\r\n\u0022top\u0022 : {\r\n \u0022number\u0022: 1,\r\n \u0022string\u0022: \u0022a string\u0022,\r\n \u0022array\u0022: [ 1,2,3,4]\r\n}\r\n}", + "Path": "", + "Name": "model" + } + ], + "Template": "This project demonstrates some\r\nof the methods in the \u0027misc\u0027\r\nnamespace:\r\n\r\nCreate a fresh guid...\r\n\r\n {{misc.new_guid}}\r\n\r\nDump an object or model:\r\n\u0060\u0060\u0060\r\n{{debug.dump model}}\r\n\u0060\u0060\u0060\r\n", + "TemplatePath": "" + }, + "OutputControl": { + "Outputs": [ + { + "Format": "markdown", + "Name": "output", + "Path": "" + } + ] + } +} \ No newline at end of file diff --git a/examples/environmentAndDefinitions.texproj b/examples/environmentAndDefinitions.texproj deleted file mode 100644 index fab0770..0000000 --- a/examples/environmentAndDefinitions.texproj +++ /dev/null @@ -1,30 +0,0 @@ -{ - "Version": 1, - "Description": "", - "EngineInput": { - "Definitions": [ - "LANGUAGE=ENGLISH", - "COUNTRY=United Kingdom" - ], - "IncludePaths": [], - "Models": [ - { - "Format": 3, - "Text": "", - "Path": "", - "Name": "" - } - ], - "Template": "Access environment variables via the \u0027env\u0027 namespace:\r\n\r\n{{env.USERNAME}}\r\n\r\n\r\nAdd definitions from the other-\u003Edefintions tab and \r\naccess them via the \u0027def\u0027 namespace:\r\n\r\n{{def.LANGUAGE}} / {{def.COUNTRY}}\r\n\r\nYou can easily list all environment variables like this:\r\n\r\n{{debug.dump env}}\r\n", - "TemplatePath": "" - }, - "OutputControl": { - "Outputs": [ - { - "Format": "text", - "Name": "", - "Path": "" - } - ] - } -} \ No newline at end of file diff --git a/examples/humanizr.texproj b/examples/humanizr.texproj deleted file mode 100644 index 9ca6777..0000000 --- a/examples/humanizr.texproj +++ /dev/null @@ -1,27 +0,0 @@ -{ - "Version": 1, - "Description": "", - "EngineInput": { - "Definitions": [], - "IncludePaths": [], - "Models": [ - { - "Format": 1, - "Text": "text\r\na variable\r\nNameOfThing\r\nThe title of this book is\r\n\u0022 with spaces \u0022", - "Path": null, - "Name": null - } - ], - "Template": "{{for v in model}}\r\n \r\n\u0027{{v.text}}\u0027\r\n PASCALIZE: \u0027{{v.text | humanizr.pascalize}}\u0027\r\n CAMEL: \u0027{{v.text | humanizr.camelize}}\u0027\r\n UNDERSCORE: \u0027{{v.text | humanizr.underscore}}\u0027\r\n TITLE: \u0027{{v.text | humanizr.titleize}}\u0027\r\n KEBAB: \u0027{{v.text | humanizr.kebaberize}}\u0027\r\n\r\n{{end}}", - "TemplatePath": "" - }, - "OutputControl": { - "Outputs": [ - { - "Format": "text", - "Name": "", - "Path": "" - } - ] - } -} \ No newline at end of file diff --git a/examples/includeExample.texproj b/examples/includeExample.texproj deleted file mode 100644 index 8fcbfc7..0000000 --- a/examples/includeExample.texproj +++ /dev/null @@ -1,27 +0,0 @@ -{ - "Version": 1, - "Description": "", - "EngineInput": { - "Definitions": [], - "IncludePaths": [], - "Models": [ - { - "Format": 3, - "Text": "", - "Path": "", - "Name": "" - } - ], - "Template": "{{include \u0022lib/warnings.sbn\u0022}}\r\n\r\n{{autogenwarning}}", - "TemplatePath": "" - }, - "OutputControl": { - "Outputs": [ - { - "Format": "text", - "Name": "", - "Path": "" - } - ] - } -} \ No newline at end of file diff --git a/examples/intro.texproj b/examples/intro.texproj deleted file mode 100644 index 971e616..0000000 --- a/examples/intro.texproj +++ /dev/null @@ -1,27 +0,0 @@ -{ - "Version": 1, - "Description": "", - "EngineInput": { - "Definitions": [], - "IncludePaths": [], - "Models": [ - { - "Format": 1, - "Text": "description,emphasize\r\n\u0022can import models in JSON,YAML, or CSV\u0022, false\r\nautomatically imports build context,false\r\nuses SCRIBAN for scripting and templating\r\nruns on Windows or Linux\r\ncomes with an interactive editor\r\nis free and open-source,true ", - "Path": null, - "Name": null - } - ], - "Template": "Hi {{env.USERNAME}}\r\n\r\nTextrude:\r\n\r\n {{for row in model\r\n\r\n description=row.description\r\n if(row.emphasize) \r\n description = description | string.upcase \r\n end\r\n \r\n \u0022- \u0022 \u002B description\r\n \u0022 \r\n \u0022 \r\n end}} ", - "TemplatePath": "" - }, - "OutputControl": { - "Outputs": [ - { - "Format": "text", - "Name": "", - "Path": "" - } - ] - } -} \ No newline at end of file diff --git a/examples/misc.texproj b/examples/misc.texproj deleted file mode 100644 index db5bf5e..0000000 --- a/examples/misc.texproj +++ /dev/null @@ -1,27 +0,0 @@ -{ - "Version": 1, - "Description": "", - "EngineInput": { - "Definitions": [], - "IncludePaths": [], - "Models": [ - { - "Format": 0, - "Text": "{\r\n\u0022top\u0022 : {\r\n \u0022number\u0022: 1,\r\n \u0022string\u0022: \u0022a string\u0022,\r\n \u0022array\u0022: [ 1,2,3,4]\r\n}\r\n}", - "Path": null, - "Name": null - } - ], - "Template": "Here\u0027s a fresh guid...\r\n\r\n{{misc.new_guid}}\r\n\r\nHere\u0027s what your model looks like:\r\n\r\n{{debug.dump model}}\r\n", - "TemplatePath": "" - }, - "OutputControl": { - "Outputs": [ - { - "Format": "text", - "Name": "", - "Path": "" - } - ] - } -} \ No newline at end of file diff --git a/examples/multiInOut.texproj b/examples/multiInOut.texproj deleted file mode 100644 index 3682a81..0000000 --- a/examples/multiInOut.texproj +++ /dev/null @@ -1,49 +0,0 @@ -{ - "Version": 1, - "Description": "", - "EngineInput": { - "Definitions": [], - "IncludePaths": [], - "Models": [ - { - "Format": 2, - "Text": "name: yaml", - "Path": null, - "Name": null - }, - { - "Format": 0, - "Text": "{\r\n \u0022name\u0022:\u0022json\u0022\r\n}", - "Path": null, - "Name": null - }, - { - "Format": 1, - "Text": "name\r\ncsv", - "Path": null, - "Name": null - } - ], - "Template": "Model 0 is {{model0.name}}\r\nModel 1 is {{model1.name}}\r\nModel 2 is {{model2[0].name}}\r\n\r\n\u0027model\u0027 is synonymous with \u0027model0\u0027...\r\n\r\n\u0027{{model.name}}\u0027 shoud be the same as \u0027{{model0.name}}\u0027\r\n\r\nTo write to another output, use the capture keyword...\r\n\r\n{{-capture output1}}\r\nYou won\u0027t see this in the output window. \r\nCheck the \u0022output1\u0022 window instead\r\n{{end}}\r\n\r\n\r\n{{-capture output2}}\r\nCapture scopes are temporary.\r\n{{end}}\r\n\r\nThat\u0027s all!\r\n", - "TemplatePath": "" - }, - "OutputControl": { - "Outputs": [ - { - "Format": "text", - "Name": "", - "Path": null - }, - { - "Format": "text", - "Name": "", - "Path": "" - }, - { - "Format": "text", - "Name": "", - "Path": "" - } - ] - } -} \ No newline at end of file diff --git a/examples/welcome.texproj b/examples/welcome.texproj deleted file mode 100644 index 99a55b6..0000000 --- a/examples/welcome.texproj +++ /dev/null @@ -1,47 +0,0 @@ -{ - "Version": 1, - "Description": "", - "EngineInput": { - "Definitions": [ - "color=blue", - "size=large" - ], - "IncludePaths": [], - "Models": [ - { - "Format": 2, - "Text": "str: a string\r\nnum: 100\r\nlst:\r\n - 45\r\n - 23\r\n", - "Path": null, - "Name": null - }, - { - "Format": 1, - "Text": "Num,Description\r\n100,failure\r\n200,breakage", - "Path": null, - "Name": null - }, - { - "Format": 1, - "Text": "file,description\r\nexample1,Demonstrates how", - "Path": null, - "Name": null - } - ], - "Template": "\r\nHello {{env.USERNAME}} \r\n\r\nIt is {{ date.now | date.to_string \u0022%r on %A, %d %h %Y\u0022}}\r\n\r\n\u003C===== Your YAML model is: {{model}}\r\n\r\nYou can access items like this...\r\n\r\n\u0022{{model.str}}\u0022 \r\n\r\nor \r\n\r\nsum of items in list is: {{model.lst[0] \u002B model.lst[1]}}\r\n\r\n\u003C===You can refer to multiple models from the same template.\r\nThere is another model with a CSV scheme in the \u0022model1\u0022 tab on the left \r\n\r\n{{debug.dump model1}}\r\n\r\nYou have the following definitions:\r\n\r\n{{for d in def~}}\r\n {{for.index}}. \u0027{{d.key}}\u0027 is \u0027{{d.value}}\u0027\r\n {{~end}}\r\n\r\nIt\u0027s possible for a template to generate output for multiple files; look \r\nin the \u0022output1\u0022 tab on the right ====\u003E\r\n{{capture output1}} \r\n Here is some text that should appear in the output1 window \r\n{{end}}\r\n\r\nOutput is regenerated whenever you edit the template, models or definitions.\r\n\r\nMore examples are available - use Project-\u003ELoad from the menu. The full list is:\r\n\r\n{{for d in model2~}}\r\n - {{d.file}}: {{d.description}}\r\n {{end}}\r\n\r\n ", - "TemplatePath": "" - }, - "OutputControl": { - "Outputs": [ - { - "Format": "text", - "Name": "", - "Path": "" - }, - { - "Format": "text", - "Name": "", - "Path": "" - } - ] - } -} \ No newline at end of file