6. Snippets in Notepad - AlSchemist/GimpLambdaLib GitHub Wiki

A snippet is a piece of source code designed to input more easily a program: it is the call of a function with its parameters that must be replaced.

6.1 Installation of Notepad++ Snippets plugin

Before browsing the Gimp lambda library from the Notepad++ text editor, let’s install the free GNU-licensed Snippets plugin powered by Frank. The Snippets plugin displays in Notepad++ a new window on the right offering the list of keywords or functions of a language according to the edited source code.

🟩 Notepad++ plugin manager

Notepad++ menu Plugins > Plugins Admin...


@ffes NppSnippets:

🟩 Selection of Snippets 1.7 then installation

In the first Available tab of the Notepad++ plugin manager, scroll and check ✔️ Snippets 1.7


6.2 Download PDB’s and GimpλLib’s snippets SQLite databases

📀 Download Notepad++ zipped snippets 66 Kb containing PDB’s and GimpλLib’s snippets SQLite databases.

Once NotePadPlus.zip is downloaded, unzip the zipped archive with 7-zip > Extract to NotePadPlus or directly the Windows File Manager:

In the Windows File Manager, you should retrieve two .sqlite files.


6.3 Configuring PDB’s and GimpλLib’s snippets in Notepad++

🟩 Gimp Lambda Library snippets in an SQLite database

🟩 Import snippets from GimpλLib and the Procedure DataBase of Gimp

In Notepad++:

  1. Right click on the default library above for example ANSI-characters under Snippets on the right.
  2. Click contextual menu Import Library…
  3. Select GimpLambdaLib\NotepadPlus\GimpScript-Fu-PDB.sqlite where you have unzipped GimpLambdaLib.zip
    => this SQLite database contains 1069 snippets.
  4. Click Open button to load GimpScript-Fu-PDB.sqlite
  5. Click Import button
  6. Repeat the same procedure to import the 618 snippets from GimpλLib.sqlite

6.4 Usage of Snippets in Notepad++

6.4.1 Populate a new source code from snippets in Notepad++

In Notepad++, click New to create an empty source code.

🟩 Create empty text in (S)cheme language

Notepad++ menu Language > S > Scheme indicates that it is a TinyScheme source code also called Script-Fu.


🟩 Using Gimp λLib and PDB snippets

  1. In the GimpScript-Fu PDB snippets, scroll and double-click on gimp-version
    => This Gimp function is displayed between parenthesis as the first line of the source code.
  2. Press ENTER at the end of line 1 to create the second line, which is still empty.
  3. Change snippets by selecting GimpλLib snippets on the right.
  4. Scroll and double-click on the function show
    => (show firstPrm lstOtherPrm) is displayed in the second line of the source code.
  5. Double-click firstPrm to replace the 1st parameter with the string of characters "pi: "
  6. Double-click lstOtherPrm to replace the second parameter with the constant *pi*

The new code source in Notepad++ should be populated with the two following calls of functions:

(gimp-version)     ; function of the PDB
(show "pi: " *pi*) ; function of the GimpλLib

After selecting line 1 or 2 or both, copy the line to the clipboard by Ctrl+C in Windows.


6.4.2 Execution in the Script-Fu console

Paste by Ctrl+V in the input area of ​​the Script-Fu console.
Validate with the Enter key to read the result.


6.4.3 Comparing PDB in Script-Fu console vs. in Notepad++ Snippets

Traditionally, reading the PDB is done by clicking the Browse button from the Script-Fu console in particular for details on the parameters of call and the expected return. Snippets of GimpScript Fu-PDB.sqlite from Notepad++ are equivalent to the PDB in the Script-Fu console. Only deprecated functions have been removed. In summary, the developer can scroll in the Snippets window to find a function of the GimpλLib and its calling parameters.

⚠️ **GitHub.com Fallback** ⚠️