Working mode: --mode coding|general (CST_MODE, settings.json, /mode, WebUI run settings). general swaps the default framing for a general assistant one -- workflow, safety notes, tool wording (run_shell, the subagents) -- and /status shows it; minimal (the paper profile) stays byte-frozen. The prompt state carries the mode so a switch leaves a system note in history. Clipboard: clipboard_read / clipboard_write tools (16 MiB cap read, default 64 KiB window; writing is a WRITE permission with a preview) on pbcopy / wl-copy / xclip / pbpaste / wl-paste / xclip and the Win32 clipboard. In the TUI, /attach paste falls back to clipboard text when there is no image on it. PDF: a dependency-free text extractor (src/pdf_text.c): inflate, Flate/ASCIIHex/ASCII85, PNG/TIFF predictors, layout-independent object scan, object streams, page tree walk with inherited resources, content lexer (Tj/TJ/'/" and the Td/TD/T*/Tm spacing heuristics), per-font ToUnicode CMaps and inline images skipped. Encrypted files and pages with no text layer are refused with the reason. Attachments: /attach (a path or files dropped on the terminal) now take images, PDFs and text. A PDF is stored as its text layer with the mime still saying application/pdf and its page count; anything else has to be UTF-8 text. Documents travel inline as text parts, so CST_NO_IMAGES and text-only models no longer drop them, while images keep their old path. Tests: test_pdf_text (plain, bare and zlib-framed Flate, inline image, CID + ToUnicode, object stream, error paths), documents in test_attach, inlined documents in test_llm_body, mode in test_config.
50 lines
1.9 KiB
C
50 lines
1.9 KiB
C
#ifndef CST_CLIPBOARD_H
|
|
#define CST_CLIPBOARD_H
|
|
|
|
#include <stddef.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Image bytes on the system clipboard (PNG, or BMP from a Windows DIB).
|
|
* Wayland: wl-paste; X11: xclip; macOS: pngpaste or osascript; Windows: the
|
|
* clipboard API. Returns 0 with *data malloc'd, or -1 with err filled in
|
|
* ("no image on the clipboard", "install wl-clipboard", ...). */
|
|
int cst_clipboard_image(char **data, size_t *n, char *err, size_t err_sz);
|
|
|
|
/* Cap on text moved through the clipboard (read and write). */
|
|
#define CST_CLIPBOARD_TEXT_MAX (1024 * 1024)
|
|
|
|
/* UTF-8 text on the system clipboard: Wayland (wl-paste), X11 (xclip),
|
|
* macOS (pbpaste), Windows (CF_UNICODETEXT). Returns 0 with *data malloc'd
|
|
* and NUL-terminated, or -1 with err filled in ("no text on the clipboard",
|
|
* "reading the clipboard needs wl-clipboard", ...). */
|
|
int cst_clipboard_text(char **data, size_t *n, char *err, size_t err_sz);
|
|
|
|
/* Replace the clipboard with UTF-8 text: wl-copy / xclip / pbcopy, or the
|
|
* Windows clipboard API. Returns 0 on success, else -1 with err. */
|
|
int cst_clipboard_set_text(const char *text, size_t n, char *err,
|
|
size_t err_sz);
|
|
|
|
/* Windows CF_DIB bytes (BITMAPINFOHEADER + pixels) as an image file: a PNG
|
|
* for uncompressed 24/32-bit bitmaps, else a BMP. NULL when malformed. */
|
|
char *cst_dib_to_image(const void *dib, size_t sz, size_t *n);
|
|
|
|
#define CST_PASTE_MAX_PATHS 8
|
|
#define CST_PASTE_PATH_MAX 1024
|
|
|
|
/* Split pasted text into file paths the way terminals paste dropped files:
|
|
* whitespace- or newline-separated, '...' / "..." quoting, file:// URIs
|
|
* (percent-decoded) and, outside Windows, backslash escapes. Returns the
|
|
* count, or -1 when the text is empty or holds more than max paths. Whether
|
|
* the paths exist is up to the caller. */
|
|
int cst_paste_paths(const char *text, size_t len,
|
|
char out[][CST_PASTE_PATH_MAX], int max);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|