1. Yad Text

Display text information dialog.

yad text info
Figure 1. Text dialog

You will notice there is no =TEXT option.

Command
yad --text-info < /tmp/hello.txt does providing the file "hello.txt" exists.

It reads the information from a file and displays it in the --text-info box.

1.1. --fore=COLOR

Use specified color for text.

Lets create a simple text file called hello.txt in /tmp .
Inside the text file type "Hello There!"
Now read the file into the --text-info dialog like:

Command
yad --text-info --fore=red < /tmp/hello.txt
yad text info fore red
Figure 2. Text dialog with foreground color

You can load quite a large text file and scroll bars will be added when required.

1.2. --back=COLOR

Use specified color for background.

The background colour can also be changed like:

Command
yad --text-info --back=cyan < /tmp/hello.txt
yad text info back cyan
Figure 3. Text dialog with background color

1.3. --line=NUMBER

Jump to specific line at startup.
This option works only when filename was specified.

1.4. --file-op

Enable file operations.
This option adds open and save menu items to popup menu, This option works only in editable mode.

1.5. --confirm-save=[TEXT]

Confirm file saving if file content was changed.
This option works only when --in-place is specified. Optional argument is a text for confirmation dialog.

1.6. --wrap

Enable text wrapping.

Create a text file called dogs.txt. In the file type "The quick brown fox jumped over the lazy dogs back."

Command
yad --text-info --wrap < dogs.txt
yad text info wrap
Figure 4. Text dialog wrap enabled

Notice how the text is wrapped in the dialog box.

1.7. --margins=NUMBER

Set text margins to NUMBER.

Command
yad --text-info --wrap --margins=20 < dogs.txt
yad text info margins 20
Figure 5. Text dialogwith margins set to 20

I added --wrap so you could see margins on both sides.

1.8. --editable

Allow changes to the text.

Command
yad --text-info --editable < hello.txt
yad text info editable 1
Figure 6. Text dialog with editable enabled

Now add sunshine after there

yad text info editable 2
Figure 7. Text dialog with new text

When you click OK, the following will be displayed:
Hello there sunshine!

1.9. --tail

Autoscroll to end of text.
If you load a text file it will scroll through the text to the end of the file.
If it’s a long file it will scroll too fast to read it.

It’s a handy way to get to the end of a file.

Note This option works only when text is read from stdin.

1.10. --show-cursor

Show cursor in read-only mode.

Command
yad --text-info --show-cursor < dogs.txt
yad text info show cursor
Figure 8. Text dialog with show-cursor enabled

Note the line after the "back." word

1.11. --show-uri

Make URI clickable.

Create a file called links.txt. Type https://github.com/v1cont/yad/ in the file and save the file.

Command
yad --text-info < links.txt --show-uri
yad text info show uri
Figure 9. Text dialog with show-uri enabled

Now click on the link to go to the website.

1.12. --uri-color=COLOR

Use specified color for links.

Command
yad --text-info < links.txt --show-uri --uri-color=red
yad text info show uri color red
Figure 10. Text dialog with show-uri enabled and color red

1.13. --listen

Listen data from stdin even if filename was specified.

1.14. --in-place

Save file on exit instead of print it content on stdout.
This option works only if file was specified from command-line.

1.15. --file-op

Enable file operations.
This option adds open and save menu items to popup menu.
This option works only in editable mode.

Command
yad --text-info --editable --file-op
yad text info file op
Figure 11. Text Dialog - --file-op

Disable search bar.

2. Examples

2.1. testedit

Now lets make it do something.
Write the following script, save it as testedit, then make it executable.

Code
#!/bin/sh
# Created by smokey01
# http://smokey01.com/yad/

yad --text-info --editable < /tmp/hello.txt > /tmp/hello2.txt
rm /tmp/hello.txt
cp /tmp/hello2.txt /tmp/hello.txt
rm /tmp/hello2.txt

Now run testedit to have some fun.

Note If you don’t want to edit the hello2.txt file just click OK.
Warning If you click Cancel button the text in the file will be removed.

Enter "Hello There!" in the text box. Klick on the OK-button.

yad text info 2.1 1
Figure 12. Text dialog with the default text

Now run the script again.

Enter "Hi" under "Hello There!" and klick the OK-button.
Now run the script again and se what happend.

yad text info 2.1 2
Figure 13. Text dialog with new text

3. GtkSourceView options

These options works only if YAD is build with GtkSourceView.

3.1. --lang=LANGUAGE

Highlight syntax for specified LANGUAGE.

Command
yad --text-info --lang=css < ./asciidoctor.css --width=600 --height=480
yad lang css
Figure 14. Text dialog with --lang=css

3.2. --theme=THEME

Set used theme to THEME. Use yad-tools(1) to get list of all available themes.

For my Salix OS the aviable themes is:

Command: yad-tools --show-themes
yad-tools --show-themes

Classic
Cobalt
Kate
Oblivion
Solarized Dark
Solarized Light
Tango
Command
yad --text-info --lang=css --theme=Kate< ./asciidoctor.css --width=600 --height=480
yad lang css kate
Figure 15. Text dialog with --lang=css --theme=Kate

3.3. --mime=TYPE

Specify mime type of input data.
This options only needed for guessing appropriate syntax highlighting.

3.4. --line-num

Show line numbers.

Command
yad --text-info --line-num --lang=css < ./asciidoctor.css --width=600 --height=480
yad lang css linenum
Figure 16. Text dialog with --line-num

3.5. --line-hl

Highlight current line.

Command
yad --text-info --line-hl --lang=css < ./asciidoctor.css --width=600 --height=480
yad lang css linehl
Figure 17. Text dialog with --line-hl

3.6. --line-marks

Enable line marks mode.
There are two types of marks. First type sets by left mouse button and second by the right mouse button.

3.7. --mark1-color=COLOR

Set background color for marks of first type to COLOR.
Default is lightgreen.

3.8. --mark2-color=COLOR

Set background color for marks of second type to COLOR.
Default is pink.

3.9. --right-margin=[POS]

Enable mark of right margin.
Optional argument POS is a margin position in characters.
Default is 80.

Command
yad --text-info --right-margin=60 --lang=css < ./asciidoctor.css --width=600 --height=480
yad lang css right margin
Figure 18. Text dialog with --right-margin=60

3.10. --brackets

Highlight matching brackets.

3.11. --indent

Enable autoindent.
This option also sets TAB key as indent key.

3.12. --smart-he=TYPE

Set behavior of HOME and END keys.
The TYPE is one of newer, before, after or always.

3.13. --smart-bs

Enable smart mode for BackSpace.
If this option is enabled BackSpace will delete spaces to the next tab position.

3.14. --tab-width

Set tabulation step.

3.15. --indent-width

Set indentation step.

3.16. --spaces

Insert spaces instead of tabulation.

Back to YAD Guide