ebox/examples/ebox-basic-examples.el
Kinneyzhang 8a8e862098 feat(ebox): publish standalone low-level package
Split the verified renderer, layout engine, Grid support, native boundary, tests, examples, and paired documentation into the independent Ebox repository. Keep ETAF and application concerns outside this package.
2026-08-05 09:15:35 +08:00

41 lines
1.4 KiB
EmacsLisp
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;;; ebox-basic-examples.el --- Basic Ebox examples -*- lexical-binding: t; -*-
;;; Commentary:
;; Load this file after adding the repository root to `load-path', then run
;; `M-x ebox-basic-examples-open'. The example intentionally uses `:wrap-mode
;; kp' to exercise the optional ekp-backed wrapping path while still loading
;; cleanly when ekp is unavailable.
;;; Code:
(require 'ebox)
(defconst ebox-basic-examples-long-text
"作为可嵌入 Emacs buffer 的文本 UI 组件Ebox 负责把普通字符串渲染成稳定的像素宽度盒子。这个示例混合中文、English words 和标点,用来验证 CJK 换行、kp wrap、padding、margin 与 border 在同一个盒子里的组合效果。")
(defun ebox-basic-examples-build ()
"Return the basic example layout node."
(ebox-build
`(box :content ,ebox-basic-examples-long-text
:margin 2
:margin-top 1
:padding (0 2)
:width (410)
:border "gray"
:wrap-mode kp)))
(defun ebox-basic-examples-render ()
"Render the basic example to a propertized string."
(ebox-render (ebox-basic-examples-build)))
;;;###autoload
(defun ebox-basic-examples-open ()
"Open the basic Ebox example buffer."
(interactive)
(ebox-display-buffer "*ebox-basic-examples*"
(ebox-basic-examples-build)))
(provide 'ebox-basic-examples)
;;; ebox-basic-examples.el ends here