Skip to content

Commit c16cd71

Browse files
authored
[201_47 ] 退出搜索替换窗口时光标传入主文档 (#2411)
1 parent 14a1cb3 commit c16cd71

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

TeXmacs/progs/generic/search-widgets.scm

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ search-buffer
140140
----
141141
url
142142
如果当前缓冲区已经是 tmfs://aux/search 类型的辅助缓冲区,则返回该缓冲区URL;
143-
否则返回基于当前视图URL MD5哈希的唯一搜索缓冲区URL
143+
否则返回基于当前视图URL MD5哈希的唯一搜索缓冲区URL和当前窗口
144144

145145
逻辑
146146
----
@@ -156,10 +156,13 @@ url
156156
(tm-define (search-buffer)
157157
(with u (current-buffer)
158158
(if (and (url-rooted-tmfs? u)
159-
(== (url-head u) (string->url "tmfs://aux/search")))
159+
(== (url-head(url-head u)) (string->url "tmfs://aux/search")))
160160
u
161161
(string->url
162-
(string-append "tmfs://aux/search/" (md5 (url->string (current-view-url))))))))
162+
(string-append "tmfs://aux/search/"
163+
(md5 (url->string (current-view-url)))
164+
"/"
165+
(url->string (url-tail (current-window))))))))
163166

164167
#|
165168
replace-buffer
@@ -177,7 +180,7 @@ replace-buffer
177180
----
178181
url
179182
如果当前缓冲区已经是 tmfs://aux/replace 类型的辅助缓冲区,则返回该缓冲区URL;
180-
否则返回基于当前视图URL MD5哈希的唯一替换缓冲区URL
183+
否则返回基于当前视图URL MD5哈希的唯一替换缓冲区URL和当前窗口
181184

182185
逻辑
183186
----
@@ -193,10 +196,16 @@ url
193196
(tm-define (replace-buffer)
194197
(with u (current-buffer)
195198
(if (and (url-rooted-tmfs? u)
196-
(== (url-head u) (string->url "tmfs://aux/replace")))
199+
(== (url-head(url-head u)) (string->url "tmfs://aux/replace")))
197200
u
198201
(string->url
199-
(string-append "tmfs://aux/replace/" (md5 (url->string (current-view-url))))))))
202+
(string-append "tmfs://aux/replace/"
203+
(md5 (url->string (current-view-url)))
204+
"/"
205+
(url->string (url-tail (current-window))))))))
206+
207+
(tm-define (auxiliary-buffer->window x)
208+
(url-append (string->url "tmfs://window") (url-tail x)))
200209

201210
(tm-define (master-buffer)
202211
(and (buffer-exists? (search-buffer))
@@ -427,7 +436,10 @@ url
427436
(set! search-serial (+ search-serial 1))
428437
(with-buffer (master-buffer)
429438
(cancel-alt-selection "alternate"))
430-
(set-search-window-state #f #f))
439+
(set-search-window-state #f #f)
440+
(buffer-focus
441+
(window->buffer
442+
(auxiliary-buffer->window (search-buffer)))))
431443

432444
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
433445
;; Replace occurrences

devel/201_47.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# 201_47
22

33
## 如何测试
4-
1. 按下`编辑->查找`,光标被自动传入查找框。观察能否往里面输入内容
5-
2. 按下`编辑->替换`,光标被自动传入查找框,观察能否往里面输入内容
6-
3. 按下`插入->注记->折叠的批注`,光标自动传入输入框,观察能否往里面输入内容
4+
1. 按下`编辑->查找`,光标被自动传入查找框。观察能否往里面输入内容,按下下面的红色x,窗口被关闭,并且光标被传入主文档。
5+
2. 按下`编辑->替换`,光标被自动传入查找框,观察能否往里面输入内容,按下下面的红色x,窗口被关闭,并且光标被传入主文档。
6+
3. 按下`插入->注记->折叠的批注`,光标自动传入输入框,观察能否往里面输入内容。
7+
8+
## 2025/12/30 退出搜索替换窗口时光标传入主文档
79

810
## 2025/12/29 按下插入->注记->折叠的批注时传入光标
9-
## 2025/12/29 调用查找替换时将光标传入查找框中
11+
12+
## 2025/12/29 调用查找替换时将光标传入查找框中

src/Plugins/Qt/QTMAuxiliaryWidget.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ QTMAuxiliaryWidget::keyPressEvent (QKeyEvent* event) {
4343
switch (event->key ()) {
4444
case Qt::Key_Escape:
4545
// 隐藏辅助窗口
46-
exec_delayed (scheme_cmd (
47-
"(when (defined? 'close-auxiliary-widget) (close-auxiliary-widget))"));
46+
this->close ();
4847
break;
4948
default:
5049
QDockWidget::keyPressEvent (event);

0 commit comments

Comments
 (0)