### Install Python LSP Server Source: https://context7.com/alexey-t/cudatext/llms.txt Command to install the Python LSP server using pip. ```Bash pip install python-lsp-server ``` -------------------------------- ### Install Python-Markdown using pip Source: https://github.com/alexey-t/cudatext/blob/master/testfiles/code_tree/code-tree with fenced blocks 2.md Use this command to install the latest stable version of Python-Markdown from PyPI. This is the recommended method for most users. ```bash pip install markdown ``` -------------------------------- ### Install Python-Markdown from Git Repository Source: https://github.com/alexey-t/cudatext/blob/master/testfiles/code_tree/code-tree with fenced blocks 2.md Install the latest development version directly from the GitHub repository. This is useful for users who want to test unreleased features or contribute to the project. ```bash pip install git+https://github.com/Python-Markdown/markdown.git ``` -------------------------------- ### C Code Example Source: https://github.com/alexey-t/cudatext/blob/master/testapps/test_treehelpers/tests/fold.md This snippet demonstrates basic C code structure. ```c d d d ``` -------------------------------- ### Python LSP Server Configuration Source: https://context7.com/alexey-t/cudatext/llms.txt Example JSON configuration for the Python LSP server, specifying lexers, command paths, and server settings. ```JSON { "lexers": { "Python": "python" }, "cmd_windows": ["pylsp.exe"], "cmd_unix": ["pylsp"], "cmd_macos": ["pylsp"], "settings": { "pylsp": { "plugins": { "jedi_completion": { "fuzzy": true } } } } } ``` -------------------------------- ### Create Search Engine and Attach to Editor Source: https://context7.com/alexey-t/cudatext/llms.txt Initializes a search engine and associates it with the current editor. ```Python h = finder_proc(0, FINDER_CREATE) finder_proc(h, FINDER_SET_ED, value=ed.get_prop(PROP_HANDLE_SELF, '')) finder_proc(h, FINDER_SET_FINDTEXT, value='TODO') finder_proc(h, FINDER_SET_OPT, value='i') ``` -------------------------------- ### Create DMG from Folder Source: https://github.com/alexey-t/cudatext/blob/master/doc/make_osx_file.txt Instructions to use Disk Utility to create a DMG disk image from a prepared folder. This is the final step in packaging the application for distribution. ```bash run Disk Manager app, create DMG from folder cudatext-osx ``` -------------------------------- ### Prepare Application Bundle for DMG Source: https://github.com/alexey-t/cudatext/blob/master/doc/make_osx_file.txt Commands to strip the application binary and prepare the directory structure for creating a DMG file. This is typically done to reduce the DMG size. ```bash strip cudatext rm -rf cudatext-osx mkdir cudatext-osx cp -rf cudatext.app cudatext-osx/ ``` -------------------------------- ### Reload Lexer Library Source: https://context7.com/alexey-t/cudatext/llms.txt Reloads the lexer library, typically after installing a new lexer. ```Python lexer_proc(LEXER_REREAD_LIB, '') ``` -------------------------------- ### Get Lexer Style Information Source: https://context7.com/alexey-t/cudatext/llms.txt Retrieves style information for syntax highlighting for a given lexer. ```Python styles = lexer_proc(LEXER_GET_STYLES, 'Python') ``` -------------------------------- ### Get Lexer Properties Source: https://context7.com/alexey-t/cudatext/llms.txt Fetches properties of a specific lexer, including comment characters, file types, and sub-lexers. ```Python props = lexer_proc(LEXER_GET_PROP, 'Python') print('Line comment:', props['c_line']) print('File types:', props['typ']) print('Sub-lexers:', props['sub']) ``` -------------------------------- ### Get Selected Text and Line Range Source: https://context7.com/alexey-t/cudatext/llms.txt Retrieve the selected text using `get_text_sel()` and the range of selected lines using `get_sel_lines()`. ```Python sel = ed.get_text_sel() # selection of first caret ('' if none) sel_lines = ed.get_sel_lines() # (first_line_index, last_line_index) or (-1,-1) ``` -------------------------------- ### C/C++ Build System Configuration with GCC Source: https://context7.com/alexey-t/cudatext/llms.txt Sublime Text compatible build system configuration for C/C++ files using GCC. Includes build and run variants. ```json { "file_patterns": ["*.c", "*.cpp"], "name": "Build", "cmd": ["gcc", "$file", "-o", "$file_base_name"], "working_dir": "$file_path", "file_regex": "^([^:]+):(\\d+):(\\d+): .+$", "variants": [ { "name": "Run", "cmd": ["./$file_base_name"], "working_dir": "$file_path" } ] } ``` -------------------------------- ### Configure C/C++ LSP with clangd Source: https://context7.com/alexey-t/cudatext/llms.txt Configuration for C/C++ language server using clangd. Specify lexers and command-line arguments for Unix and Windows. ```json { "lexers": { "C++": "cpp", "C": "c" }, "cmd_unix": ["clangd", "--background-index"], "cmd_windows": ["clangd.exe", "--background-index"], "log_stderr": true } ``` -------------------------------- ### Set Caret with Selection Source: https://context7.com/alexey-t/cudatext/llms.txt Define a caret with a selection by providing the start and end coordinates using `set_caret(x1, y1, x2, y2)`. ```Python # --- Set caret with selection --- ed.set_caret(0, 5, 10, 5) # select columns 0-10 on line 5 ``` -------------------------------- ### Undo-Safe Text Replacement Source: https://context7.com/alexey-t/cudatext/llms.txt For undo-safe replacement of all lines, split the new content into lines and use `replace_lines()` with the start and end line indices. ```Python lines = 'new\ncontent'.splitlines() ed.replace_lines(0, ed.get_line_count() - 1, lines) ``` -------------------------------- ### Create libiconv Symlink on FreeBSD Source: https://github.com/alexey-t/cudatext/blob/master/setup/freebsd_files/readme_cudatext_freebsd.txt Create a symbolic link for libiconv.so.3 to libiconv.so.2 to resolve missing library errors when running CudaText. ```bash # ln -s /usr/local/lib/libiconv.so.2 /usr/local/lib/libiconv.so.3 ``` -------------------------------- ### Substring Extraction Source: https://context7.com/alexey-t/cudatext/llms.txt Extract a substring by specifying the start and end column and line numbers using `get_text_substr(x1, y1, x2, y2)`. ```Python substr = ed.get_text_substr(0, 0, 5, 0) # columns 0..5 on line 0 ``` -------------------------------- ### Handle Editor Events with Python Source: https://context7.com/alexey-t/cudatext/llms.txt Implement event handlers for editor actions like opening, saving, and key presses. Returning False can cancel default behavior. Requires `install.inf` or runtime subscription. ```python # install.inf snippet: # [item1] # events=on_open,on_save,on_key from cudatext import * class Command: def on_open(self, ed_self): """Called after a file is opened from disk.""" msg_status('Opened: ' + ed_self.get_filename()) def on_save_pre(self, ed_self): """Called before saving. Return False to cancel save.""" if ed_self.get_filename().endswith('.readonly'): msg_box('This file is read-only by convention!', MB_OK | MB_ICONWARNING) return False # cancel the save def on_key(self, ed_self, key, state): """key: int key code (see cudatext_keys), state: str with 'a','c','s','m'.""" from cudatext_keys import VK_F5 if key == VK_F5 and state == '': msg_status('F5 pressed – running build...') return False # block default handling def on_change_slow(self, ed_self): """Called after editing pauses (respects py_change_slow option).""" count = ed_self.get_line_count() msg_status(f'Document has {count} lines') def on_state(self, ed_self, state): """Called when application-wide state changes.""" if state == APPSTATE_THEME_SYNTAX: msg_status('Syntax theme changed') ``` -------------------------------- ### Configure TypeScript/JavaScript LSP with typescript-language-server Source: https://context7.com/alexey-t/cudatext/llms.txt Configuration for TypeScript/JavaScript language server. Maps lexers and defines commands for Unix and Windows. ```json { "lexers": { "JavaScript": "javascript", "TypeScript": "typescript" }, "cmd_unix": ["typescript-language-server", "--stdio"], "cmd_windows": ["typescript-language-server.cmd", "--stdio"] } ``` -------------------------------- ### Editor Properties Source: https://context7.com/alexey-t/cudatext/llms.txt Functions for getting and setting various editor properties like lexer, encoding, read-only status, word wrap, and zoom. ```APIDOC ## Editor Class — Properties (`get_prop` / `set_prop`) Editor properties expose dozens of per-editor settings: lexer, encoding, read-only, word-wrap, filename, modified state, zoom, etc. ### Filename and lexer ```python fn = ed.get_prop(PROP_FILENAME, '') lexer = ed.get_prop(PROP_LEXER_FILE, '') ed.set_prop(PROP_LEXER_FILE, 'Python') ``` ### Read-only and modified ```python ed.set_prop(PROP_RO, True) is_mod = ed.get_prop(PROP_MODIFIED, '') ``` ### Encoding ```python enc = ed.get_prop(PROP_ENC, '') # e.g. 'utf8' ed.set_prop(PROP_ENC, 'utf-8 bom') ``` ### Word wrap ```python ed.set_prop(PROP_WRAP, WRAP_ON_WINDOW) ``` ### Tab size and indent ```python ed.set_prop(PROP_TAB_SIZE, 4) ed.set_prop(PROP_TAB_SPACES, True) # use spaces, not tabs ``` ### Zoom ```python ed.set_prop(PROP_ZOOM_PERCENT, 125) # 125% ``` ### Tab title ```python ed.set_prop(PROP_TAB_TITLE, 'My custom title') ``` ### UI-tab color ```python ed.set_prop(PROP_TAB_COLOR, 0xFF0000) # red tab ``` ### Get line count and char count ```python lines = ed.get_line_count() chars = ed.get_char_count() ``` ### Scroll position ```python ed.set_prop(PROP_SCROLL_VERT, 10) # scroll to line 10 ``` ```