Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions TeXmacs/plugins/lang/dic/en_US/zh_CN.scm
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
("Use CSS for more advanced formatting" "使用 CSS 进行更高级的格式化")
("Use high resolution icons" "使用高分辨率图标")
("Use line wrapping for lines which are longer than 80 characters" "自动换行超过 80 个字符的行")
("Use relative path" "使用相对路径")
("Use retina fonts" "使用适配视网膜屏的字体")
("Use the Formatted Mogan Scheme" "使用格式化后的 Mogan Scheme")
("Windows Bitmap" "Windows位图")
Expand Down Expand Up @@ -1169,6 +1170,7 @@
("Insert the recognized LaTeX code into the document" "仅将识别后的LaTeX代码插入文档")
("Insert the image and the recognized LaTeX code into the document" "将图片与识别后的LaTeX代码插入文档")
("Insert only the picture into the document" "仅将图片插入文档")
("Inserting bibliography in %1" "在 %1 中插入参考文献")
("insertion" "嵌入")
("inside mathematics" "在数学模式中")
("interactive command" "")
Expand Down Expand Up @@ -1438,12 +1440,14 @@
("mode dependent icons" "模式工具栏")
("mode" "模式")
("modifier" "")
("Modifying bibliography for %1" "在 %1 中修改参考文献")
("modify cell alignment" "改变单元格对齐")
("modify cell border" "")
("modify cell padding" "")
("modify cell size" "改变单元格大小")
("modify table border" "")
("modify table padding" "")
("modify" "修改")
("mogan" "墨干")
("mongolian" "")
("month" "月")
Expand Down Expand Up @@ -2387,6 +2391,7 @@
("Unknown" "未知")
("up" "")
("up" "上")
("Update buffer" "更新缓冲区")
("update from web" "")
("update image links" "")
("update this buffer" "更新此文档")
Expand Down
47 changes: 30 additions & 17 deletions TeXmacs/plugins/latex/progs/bibtex/bib-widgets.scm
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; MODULE : bib-widgets.scm
;; DESCRIPTION : Widgets for bibliography
;; COPYRIGHT : (C) 2014 Miguel de Benito Delgado
;; COPYRIGHT : (C) 2014 Miguel de Benito Delgado 2026 Yuki Lu
;;
;; This software falls under the GNU general public license version 3 or later.
;; It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
Expand All @@ -15,10 +16,11 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(texmacs-module (bibtex bib-widgets)
(:use (bibtex bib-complete) (generic document-edit)))
(:use (bibtex bib-complete) (bibtex bib-utils) (generic document-edit)))

(define bibwid-url (string->url ""))
(define bibwid-style "tm-plain")
(define bibwid-default-style "tm-plain")
(define bibwid-use-relative? #t)
(define bibwid-update-buffer? #t)
(define bibwid-buffer (string->url ""))
Expand All @@ -30,8 +32,15 @@
(set! bibwid-url (url-append (url-head bibwid-buffer) u)))
(else (set! bibwid-url u))))

(define (safe-bib-standard-styles)
(catch #t (lambda () (bib-standard-styles))
(lambda (key . args) '("tm-plain"))))

(define (bibwid-set-style answer)
(set! bibwid-style answer)
(let ((styles (safe-bib-standard-styles)))
(if (and (string? answer) (in? answer styles))
(set! bibwid-style answer)
(set! bibwid-style bibwid-default-style)))
(refresh-now "bibwid-preview"))

(define (bibwid-output-content t style)
Expand All @@ -43,15 +52,19 @@
(mini-paragraph "480px" ,(bib-process "bib" style (tree->stree t))))))

(define (bibwid-output)
(with style (if (== "tm-" (string-take bibwid-style 3))
(with style (if (and (>= (string-length bibwid-style) 3)
(== "tm-" (string-take bibwid-style 3)))
(string-drop bibwid-style 3)
bibwid-style)
(eval `(use-modules (bibtex ,(string->symbol style))))
(when (== style "")
(set! style bibwid-default-style))
(catch #t (lambda () (eval `(use-modules (bibtex ,(string->symbol style)))))
(lambda (key . args) (noop)))
(with u (if (and bibwid-use-relative? (not (url-rooted? bibwid-url)))
(url-append (url-head bibwid-buffer) bibwid-url)
bibwid-url)
(with t (if (url-exists? u)
(parse-bib (string-load u))
(with t (if (url-exists? u)
(parse-bib (string-load u))
(tree ""))
(stree->tree (bibwid-output-content t style))))))

Expand Down Expand Up @@ -82,8 +95,8 @@
(bibwid-set-filename bibwid-url))

(tm-widget (bibwid-preview)
(resize ("520px" "520px" "9999px") ("100px" "100px" "9999px")
(scrollable
(resize '("520px" "520px" "9999px") '("100px" "100px" "9999px")
(scrollable
(refreshable "bibwid-preview"
(texmacs-output
(bibwid-output)
Expand All @@ -106,18 +119,18 @@
("" (choose-file bibwid-set-filename "Choose" "tmbib"))))))
===
(hlist
;(balloon "Use relative path:" "Select this to use a path relative to the current document. You can use this to be able to move around the folder containing your document and the bibliography.")
(text "Use relative path:") //
(toggle (bibwid-set-relative answer) bibwid-use-relative?)
(toggle (bibwid-set-relative answer)
bibwid-use-relative?)
// //
(text "Update buffer:") //
(text "Update buffer:") //
(toggle (set! bibwid-update-buffer? answer)
bibwid-update-buffer?)
///
// //
(text "Style:") // //
(enum (bibwid-set-style answer) (bib-standard-styles)
bibwid-style "10em"))
=== === ===
(verb (enum (bibwid-set-style answer) (safe-bib-standard-styles)
bibwid-style "10em")))
===
(hlist // (dynamic (bibwid-preview)) //)
===
(bottom-buttons >>>
Expand All @@ -133,7 +146,7 @@
(set! bibwid-buffer (current-buffer))
(let ((u (current-bib-file #f))
(s (current-bib-style #f))
(name (url-tail bibwid-buffer)))
(name (buffer-get-title bibwid-buffer)))
(if (and (not (url-none? u)) (!= s ""))
(with msg (replace "Modifying bibliography for %1" name)
(bibwid-set-url u)
Expand Down
4 changes: 0 additions & 4 deletions TeXmacs/progs/texmacs/menus/preferences-tools.scm
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@
(meti (hlist // (text "Use native menubar"))
(toggle (set-boolean-preference "use native menubar" answer)
(get-boolean-preference "use native menubar"))))
(meti (hlist // (text "New bibliography dialogue"))
(toggle
(set-boolean-preference "gui:new bibliography dialogue" answer)
(get-boolean-preference "gui:new bibliography dialogue")))
(meti (hlist // (text "Program bracket matching"))
(toggle (set-boolean-preference "prog:highlight brackets" answer)
(get-boolean-preference "prog:highlight brackets")))
Expand Down
8 changes: 0 additions & 8 deletions TeXmacs/progs/texmacs/menus/preferences-widgets.scm
Original file line number Diff line number Diff line change
Expand Up @@ -828,10 +828,6 @@ pretty-val : string
(meti (hlist // (text "New style page breaking"))
(toggle (set-boolean-preference "new style page breaking" answer)
(get-boolean-preference "new style page breaking")))
(meti (hlist // (text "New bibliography dialogue"))
(toggle
(set-boolean-preference "gui:new bibliography dialogue" answer)
(get-boolean-preference "gui:new bibliography dialogue")))
(meti (hlist // (text "Encryption"))
(toggle (set-boolean-preference "experimental encryption" answer)
(get-boolean-preference "experimental encryption")))
Expand Down Expand Up @@ -879,10 +875,6 @@ pretty-val : string
(meti (hlist // (text "New style page breaking"))
(toggle (set-boolean-preference "new style page breaking" answer)
(get-boolean-preference "new style page breaking")))
;;(meti (hlist // (text "New bibliography dialogue"))
;; (toggle
;; (set-boolean-preference "gui:new bibliography dialogue" answer)
;; (get-boolean-preference "gui:new bibliography dialogue")))
(meti (hlist // (text "Program bracket matching"))
(toggle (set-boolean-preference "prog:highlight brackets" answer)
(get-boolean-preference "prog:highlight brackets")))
Expand Down
16 changes: 0 additions & 16 deletions TeXmacs/progs/text/text-edit.scm
Original file line number Diff line number Diff line change
Expand Up @@ -542,22 +542,6 @@
(n (if (== (url-suffix r) "bib") (url-unglue r 4) r)))
(url->string n))))

(tm-define (make-bib file-name)
(:argument file-name "Bibliography file")
(let* ((name (normalized-bib-name file-name))
(aux (if (context-has? "bib-prefix") (get-env "bib-prefix") "bib"))
(style (if (context-has? "bib-style") (get-env "bib-style") "tm-gbt7714-2015")))
(if (not (make-return-after))
(insert-go-to `(bibliography ,aux ,style ,name (document ""))
'(3 0 0)))))

(tm-define (make-database-bib)
(with aux (if (context-has? "bib-prefix") (get-env "bib-prefix") "bib")
(with style (if (context-has? "bib-style") (get-env "bib-style") "tm-gbt7714-2015")
(if (not (make-return-after))
(insert-go-to `(bibliography ,aux ,style "" (document ""))
'(3 0 0))))))

(tm-define (automatic-section-context? t)
(tree-in? t (automatic-section-tag-list)))

Expand Down
8 changes: 1 addition & 7 deletions TeXmacs/progs/text/text-menu.scm
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,7 @@

(menu-bind automatic-menu
("Table of contents" (make-aux "table-of-contents" "toc-prefix" "toc"))
(assuming (get-boolean-preference "gui:new bibliography dialogue")
("Bibliography" (open-bibliography-inserter)))
(assuming (not (get-boolean-preference "gui:new bibliography dialogue"))
(if (with-database-tool?)
("Bibliography" (make-database-bib)))
(if (not (with-database-tool?))
("Bibliography" (choose-file make-bib "Bibliography file" "tmbib"))))
("Bibliography" (open-bibliography-inserter))
("Index" (make-aux "the-index" "index-prefix" "idx"))
("Glossary" (make-aux "the-glossary" "glossary-prefix" "gly"))
;;("List of figures" (make-aux* "the-glossary*" "figure-list-prefix" "figure" "List of figures"))
Expand Down
20 changes: 20 additions & 0 deletions devel/204_25.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@
- 空文件测试:从网上选取一些bib文件,并复制标准的参考文献格式,使用 插入 -> 自动 -> 参考文献,然后最下方工具栏的右侧样式里,选择tm-gbt7714-2015-author-year,对比生成效果
- 补充测试
- 测试文档:Texmacs/tests/tmu/204_25_supplement.tmu
- 弹窗测试
- 点击参考文献按钮
- 插入测试

## 2026/02/09 参考文献功能使用弹窗
### What
```scheme
(assuming (get-boolean-preference "gui:new bibliography dialogue")
("Bibliography" (open-bibliography-inserter)))
(assuming (not (get-boolean-preference "gui:new bibliography dialogue"))
(if (with-database-tool?)
("Bibliography" (make-database-bib)))
(if (not (with-database-tool?))
("Bibliography" (choose-file make-bib "Bibliography file" "tmbib"))))
```
简化为
```
("Bibliography" (open-bibliography-inserter))
```
删去首选项选择,改为直接使用,修复部分问题

## 2026/02/03 优化参考文献样式
### What
Expand Down