File indexing completed on 2024-05-19 04:00:08

0001 var katescript = {
0002     "author": "Henri Kaustinen <heka1@protonmail.com>",
0003     "license": "LGPLv2+",
0004     "revision": 1,
0005     "kate-version": "23.04",
0006     "functions": ["nextParagraph", "previousParagraph"],
0007     "actions": [
0008         {   "function": "nextParagraph",
0009             "name": "Go to Next Paragraph",
0010             "category": "Navigation"
0011         },
0012         {   "function": "previousParagraph",
0013             "name": "Go to Previous Paragraph",
0014             "category": "Navigation"
0015         }
0016     ]
0017 };
0018 
0019 /*
0020  * Move cursor after current or next paragraph. Paragraph ends with empty line,
0021  * line with only whitespace or document end.
0022 */
0023 function nextParagraph() {
0024     var cursor = view.cursorPosition();
0025     var line = cursor.line;
0026 
0027     // If cursor is already on an empty line, move to the next non-empty line.
0028     if (document.line(line).trim() === '') {
0029         while (line < document.lines() - 1 && document.line(line).trim() === '') {
0030             line++;
0031         }
0032     }
0033 
0034     // Find the next empty line.
0035     while (line < document.lines() - 1 && document.line(line).trim() !== '') {
0036         line++;
0037     }
0038 
0039     cursor.line = line;
0040     cursor.column = document.lineLength(cursor.line);
0041     view.setCursorPosition(cursor);
0042 }
0043 
0044 /*
0045  * Move cursor before current or previous paragraph. Paragraph starts after line.
0046  * line, line with only whitespace or document start.
0047 */
0048 function previousParagraph() {
0049     var cursor = view.cursorPosition();
0050     var line = cursor.line;
0051 
0052     // If cursor is already on an empty line, move to the previous non-empty line.
0053     if (document.line(line).trim() === '') {
0054         while (line > 0 && document.line(line).trim() === '') {
0055             line--;
0056         }
0057     }
0058 
0059     // Find the first empty line before the paragraph.
0060     while (line > 0 && document.line(line).trim() !== '') {
0061         line--;
0062     }
0063 
0064     cursor.line = line;
0065     cursor.column = cursor.line == 0 ? 0 : document.lineLength(cursor.line);
0066     view.setCursorPosition(cursor);
0067 }
0068 
0069 function help(cmd)
0070 {
0071     if (cmd == 'nextParagraph') {
0072         return i18n('Move the cursor after the current or next paragraph.');
0073     } else if (cmd == 'previousParagraph') {
0074         return i18n('Move the cursor before the current or previous paragraph.');
0075     }
0076 }
0077 
0078 // kate: space-indent on; indent-width 4; replace-tabs on;