Text Editor

Texteditor creates a text editor that can be used to send strings to Csound. Hitting return when in single line mode will send the string to Csound on a named string channel while pressing the up and down buttons when the texteditor is in focus will toggle through the previous strings that have been sent. When in "multiline" mode, press command and return to send the string data to Csound.

texteditor wrap(val), readonly(val), doubleClickTogglesEdit(val), caretColour("colour"), scrollbars(val), file("filename"), fontSize("colour"), mode("mode"), active(val), alpha(val), bounds(x, y, width, height), channel("chan"), colour("colour"), fontColour("colour"), identChannel("channel"), popup(val), parent(val), rotate(radians, pivotx, pivoty), visible(val), toFront(), moveBehind("widgetName"), widgetArray("chan", number),

Specific Identifiers


wrap(val) Turns text wrapping on of off. This is set to 0 by default, so no wrapping of text is done


readonly(val) Sets the widget to readonly mode.


doubleClickTogglesEdit(val) Used to toggle editing in a text editor. Double clicking on the text editor will toggle readonly mode.


caretColour("colour") This sets the caret colour of a text editor. Any CSS or HTML colour string can be passed to this identifier. The colour identifier can also be passed an RBG, or RGBA value. All channel values must be between 0 and 255. For instance colour(0, 0, 255) will create a blue, while colour(0, 255, 0, 255) will create a green with an alpha channel set to full.


scrollbars(val) Sets whether the widget will show scrollbars or not.


file("filename") This identifier is used across a number of widgets.

combobox and listbox - will load lines from a file as selectable items.
gentable and soundfiler - will load a sound file to display
image - will load an iamge to display (PNG/JPG/SVG)
infobutton - sets the file to display when the button is clicked This can be a local html file, or a URL.
texteditor - sets the file to load, should be a text file.

If a full file path is not given, file() will search in the current directory, i.e., the directory that contains the csd file that is open. It is best to keep all files in the same directory as your csd file. If you wish to keep them in a separate folder use relative paths, i.e, ../../folder.

Avoid absolute path at all costs. Failure to do so will most likely problems with your instruments as soon as you share them.


fontSize("colour") Sets the size of a nslider's font.


mode("mode")

When used with a filebutton, valid modes are:

  • file, Default. Will open a browser to select a file
  • save, Will open a browser to select an existing file, or write the name of a new file. Note Cabbage will not create this new file, you will need to do that yourself in Csound.
  • directory, Will open the browser to select a folder/directory
  • preset, Will stop the file browser from opening, and instead write a preset file to disk with a default file name. See Presets
  • named preset, Will display a message box with a text editor so that users can name their presets. See Presets
  • remove preset, Will remove the currently select preset from the snapshot XML file. See Presets


When used with a texteditor, it sets multiline mode. Defaults to "single". Use "multi" to enable multiline.

Common Identifiers


active(val) Will deactivate a control if 0 is passed. Controls which are deactivate can still be updated from Csound.


alpha(val) A value between 0 and 1 will set the alpha blend value for the entire component. Can be useful if you need to fade widgets in and out.


bounds(x, y, width, height) integer values that set position and size on screen(in pixels).


channel("chan") or channel("chan1", "chan2") in the case of widgets that accept two channels such as xypad, soundfiler and range widgets. channel() accepts a string/s that names the channel/s that Cabbage will communicate with Csound on. The current value of this widget can be retrieved in Csound using a chnget, or a cabbageGetValue opcode. Its value can be set using the cabbageSet, or cabbageSetValue opcodes. hrange, vrange, xypad, and soundfiler all take two channels:

hrange, vrange : channel("min", "max") - min and max values

xypad : channel("x", "y") - x and y values

soundfiler : channel("start", "length") - start time and length of user selection, in samples

Channels named should start with a letter and cannot have any white spaces. Note that all widgets should have a unique channel name.


colour("colour") This sets the main colour. Any CSS or HTML colour string can be passed to this identifier. The colour identifier can also be passed an RBG, or RGBA value. All channel values must be between 0 and 255. For instance colour(0, 0, 255) will create a blue, while colour(0, 255, 0, 255) will create a green with an alpha channel set to full.


fontColour("colour") Sets the colour of the font. In the case of slider this sets teh colour of the font in the value textBox if it is shown.


identChannel("channel") [!!! DEPRECATED !!!] Although identifier channels still work, they are no longer supported. Please use the new guiMode("queue") system and the cabbageGet and cabbageSet opcodes instead. They are far more efficient then identifiers channel.


popup(val) This identifier, used with an image or groupbox will convert the plant into a popup plant. The plant will not be shown on the instrument's main interface, but will instead appear when the user sets visible to 1. < DAWs treat popup dialogue windows in different ways. As a result, you may notice inconsistent behaviour when running your instruments as plugins across a variety of different hosts.


parent(val) This identifier is can be to set a widget's parent. It should only be used when creating widgets dynamically using the cabbageCreate opcode. See plants for more details.


rotate(radians, pivotx, pivoty) Rotates the widget by a number of radians(2xPI=full rotation). pivotx and pivoty will determine the rotation pivot points, where 0, 0 represents the component's top-left position.


visible(val) A value of 0 will cause the widget to become invisible. Widgets have their visibility set to 1 by default.


toFront() Brings a widget to the front of the z order. This identifier takes no arguments and is only intended for use within the Csound orchestra. it makes no sense to call it when declaring the widget.


moveBehind("widgetName") Moves a widget directly behind another. This identifier should only ever be called from your Csound orchestra using a cabbageSet opcode.

This only works with widgets or plants that have the same parent.


widgetArray("chan", number) [!!! DEPRECATED !!!] Deprecated. Please see the section on Managing large numbers of widgets

Example

<Cabbage>
form caption("Texteditor Example") size(380, 300), guiMode("queue"), colour(2, 145, 209) pluginId("def1")

texteditor bounds(18, 20, 341, 204) fontSize(16), channel("orcText"), scrollbars(1), wrap(1),  fontColour(124, 210, 0), colour(0, 0, 0, 100)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
ksmps = 16
nchnls = 2
0dbfs = 1


; Rory Walsh 2021 
;
; License: CC0 1.0 Universal
; You can copy, modify, and distribute this file, 
; even for commercial purposes, all without asking permission. 

instr 1

    SText  = 

    cabbageSet "orcText", "text", SText
    cabbageSet "scoText", "text",  "schedule(1, 0, 2, 300)"

    SText cabbageGetValue "orcText"
    if changed:k(SText) == 1 then
        event "i", 2, 0, 1
    endif

    SText cabbageGetValue "scoText"
    if changed:k(SText) == 1 then
        event "i", 3, 0, 1
    endif
endin

instr 2
    SText chnget "orcText"
    prints SText
    ires compilestr SText 
    print ires ; -1 as could not compile
endin

instr 3
    SText chnget "scoText"
    prints SText
    ires compilestr SText 
    print ires ; -1 as could not compile
endin
</CsInstruments>
<CsScore>
i1 0 z
</CsScore>
</CsoundSynthesizer>