Clipboard Snippets

From OpenCircuits
Jump to navigation Jump to search

Will split this to Clipboard Snips and Clipboard Snippets Clipboard Commands

This is the Help "file" for the Python Application whose main page is: Python Smart Clipboard

Snippet Customization

This is primarily done by modifying your snippets file or by specifying a particular snippet file in parameters.py. The GUI has a button for snippet file access which works if you are only using one file. The big idea here is that you have a file specially formatted to hold the name of the snippets and the snippet itself. This is called the snippet file. You can have multiple snippet files. To "activate" a file include it in parameters.py, see the entry:


 # ----- snippets one of the following formats 
 self.snippets_fn        = "./snipsand/snippetts_1.txt"                                     # for a single file
 self.snippets_fn        = [ "./snipsand/snippetts_1.txt", "./snipsand/snippetts_1.txt" ]   # multiple snippet files


files are opened from the directory of the main application ( clipboard.py ) so you can use names with a path relative to that.

File Format

The snippets files are simply text files ( .txt ) that have a special format. There are three major components:

  • Comments
  • Snippet Names
  • Snippet content

So comments are just comments, no effect on the snippets but perhaps useful to the reader/author of the file. Currently the only lines that are comments start with # in column 1 ( line[0] ).

Snippet names mark the beginning of the snippet and are used in the GUI to let the user pick a snippet. They are marked with ">>>>>" ( len = 5 ) followed by the name.

After the name the rest of the snippet. Currently there is no processing of these line, no blank line removal, no comments ( except # in "column 1" )

Snippets are normally sorted by the snippet name ( parameters.snippets_sort = True ) so name them to get a meaningful order, or make sure they are in the order you want and set the parameter to False.

For the proper format of you file see the sample file /snipsand/snippetts_examples.txt, and perhaps /snipsand/snippetts_test.txt with your download.

See clipboard.App._read_list_of_snippets_() for the code.