[][src]Module tp_note::config

Collects tp-note's configuration from a configuration file, the command-line parameters. It also reads the clipboard.

Structs

ARGS

Structure to hold the parsed command-line arguments.

Args

tp-note is a note-taking-tool and a template system, that consistently synchronizes the note's meta-data with its filename. tp-note collects various information about its environment and the clipboard and stores them in variables. New notes are created by filling these variables in predefined and customizable Tera-templates. In case <path> points to an existing tp-note-file, the note's meta-data is analysed and, if necessary, its filename is modified. For all other file types, tp-note creates a new note that annotates the file <path> points to. If <path> is a directory (or, when omitted the current working directory), a new note is created in that directory. After creation, tp-note launches an external editor of your choice. Although the note's structure follows pandoc-conventions, it is not tied to any specific markup language.

CFG

Reads and parses the configuration file "tp-note.toml". An alternative filename (optionally with absolute path) can be given on the command line with "--config".

CLIPBOARD

Reads the clipboard and empties it.

Cfg

Configuration data, deserialized from the configuration-file.

Clipboard

Represents the clipboard content.

Hyperlink

Represents a hyperlink.

Constants

CLIPBOARD_LEN_MAX

Limit the size of clipboard data tp-note accepts as input.

CLIPBOARD_TRUNCATED_LEN_MAX

Defines the maximum length of the template variables {{ clipboard_truncated }} and {{ clipboard_linkname }} which are usually used to in the note's front matter as title. The title should not be too long, because it will end up as part of the file-name when the note is saved to disk. Filenames of some operating systems are limited to 255 bytes.

CURRENT_EXE

Name of this executable (without ".exe" extension on Windows).

EDITOR_ARGS

Default command-line argument list when launching external editor. The editor list is executed item by item until an editor is found. Can be changed in config file.

ENABLE_EMPTY_CLIPBOARD

Should the clipboard be emptied when tp-note closes? Default value.

ENABLE_READ_CLIPBOARD

By default clipboard support is enabled, can be disabled in config file. A false value here will set ENABLE_EMPTY_CLIPBOARD to false.

NOTE_EXTENSION

File extension of to-note files.

NOTE_FILENAME_LEN_MAX

Maximum length of a note's filename in bytes. If a filename-template produces a longer string, it will be truncated.

TMPL_ANNOTATE_CONTENT

Default template used when the command-line parameter points to an existing non-.md-file. Can be modified through editing the configuration file. The following variables are defined: {{ dirname }}, {{ file_stem }}, {{ extension }}, {{ note-extension }} {{ sort_tag }}, {{ username }}, {{ lang }}, {{ path }}, {{ separator| path }}. In addition all environment variables can be used, e.g. {{ get_env(name=\"LOGNAME\") }} When placed in YAML-front-matter, the filter | json_encode must be appended.

TMPL_ANNOTATE_FILENAME

Filename of a new note, that annotates an existing file on disk given in . Useful variables are: {{ title | path(alpha=true) }}, {{ subtitle | path }}, {{ note_extension | path }}. All variables also exist in a {{ <var>| path(alpha) }} variant: in case its value starts with a number, the string is prepended with '. The first non-numerical variable must be the {{ <var>| path(alpha) }} variant.

TMPL_CLIPBOARD_CONTENT

Default template used, when the clipboard contains a string. When string represents a link in markdown format: , the first part is stored in {{ clipboard-linkname }}, the second part in {{ clipboard-linkurl }}. The following variables are defined: {{ dirname }}, {{ file_stem }}, {{ extension }}, {{ note-extension }} {{ path }}, {{ separator| path }}. In addition all environment variables can be used, e.g. {{ get_env(name=\"LOGNAME\") }} When placed in YAML-front-matter, the filter | json_encode must be appended.

TMPL_CLIPBOARD_FILENAME

Default filename template used when the clipboard contains a string. Useful variables in this context are: {{ title| path }}, {{ subtitle| path }}, {{ note_extension| path }}, {{ year| path }}, {{ month| path }}. {{ day| path }}. All variables also exist in a {{ <var>| path(alpha) }} variant: in case its value starts with a number, the string is prepended with '. The first non-numerical variable must be the {{ <var>| path(alpha) }} variant.

TMPL_NEW_CONTENT

Default content-template used when the command-line argument is a directory. Can be changed through editing the configuration file. The following variables are defined: {{ dirname }}, {{ file_stem }}, {{ extension }}, {{ note-extension }} {{ sort_tag }}, {{ username }}, {{ date }}, {{ lang }}, {{ path }}, {{ separator }}, {{ year }}, {{ month }}. {{ day }}. In addition all environment variables can be used, e.g. {{ get_env(name=\"LOGNAME\") }} When placed in YAML-front-matter, the filter | json_encode must be appended.

TMPL_NEW_FILENAME

Default filename-template for a new note file on disk. It satisfies the sync criteria for note-meta data in front-matter and filename. Useful variables in this context are: {{ title| path }}, {{ subtitle| path }}, {{ note_extension| path }}, All variables also exist in a {{ <var>| path(alpha) }} variant: in case its value starts with a number, the string is prepended with '. The first non-numerical variable must be the {{ <var>| path(alpha) }} variant.

TMPL_SYNC_FILENAME

Default filename-template to test, if the filename of an existing note file on disk, corresponds to the note's meta data stored in its front matter. If it is not the case, the note's filename will be renamed. Can be modified through editing the configuration file. Useful variables in this context are: {{ sort_tag | path }} {{ title| path }}, {{ subtitle| path }}, {{ note_extension | path }}, All variables also exist in a {{ <var>| path(alpha) }} variant: in case its value starts with a number, the string is prepended with '. {{ sort_tag | path }} must be the first in line here, then followed by a {{ <var>| path(alpha) }} variable. The first non-numerical variable must be the {{ <var> | path(alpha) }} variant.

VIEWER_ARGS

Default command-line argument list when launching external viewer with --view. Can be changed in config file. The viewer list is executed item by item until an editor is found.

Functions

print_message

Pops up a message box and prints msg.

print_message_console

Prints msg on console.