Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
lynnux committed May 28, 2022
1 parent 84af741 commit 881ce3f
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 24 deletions.
91 changes: 67 additions & 24 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,101 @@
* 功能介绍
本工具是为Windows Emacs用户定制的小工具集,目前主要实现的功能都跟窗口有关,含:
1. `pop-select/gui-set-transparent`
设置Emacs窗口透明,设置代码:
功能介绍
===
本Emacs module专为windows设计。主要功能有:
# 1. 设置Emacs窗口透明 #
有两种方式
- 设置整个emacs透明。
```
(ignore-errors (module-load "pop_select.dll全路径,如果没有加入bin路径的话"))
(when (functionp 'pop-select/gui-set-transparent)
(pop-select/transparent-set-all-frame ALPHA) ;; 对所有frame设置透明,ALPHA范围0-255,0全透明,255不透明
(pop-select/transparent-set-current-frame ALPHA) ;; 只对当前frame设置透明,其它同上
```
示例设置:
```
(ignore-errors (module-load "pop_select.dll全路径,如果没有加入bin路径的话"))
(when (functionp 'pop-select/transparent-set-all-frame)
(pop-select/transparent-set-all-frame 220))
```
- 设置文字不透明,背景透明。由于实现的限制,该功能打开时会使Emacs置顶,当设置为255即不透明时取消置顶
```
(pop-select/transparent-set-background ALPHA R G B) ;; ALPHA范围0-255,0全透明,255不透明。R G B为rgb拆分数值。
```
示例设置,用CTRL+鼠标滚轮调整当前的透明度:
```
(ignore-errors (module-load "pop_select.dll全路径,如果没有加入bin路径的话"))
(when (functionp 'pop-select/transparent-set-background)
(defvar cur-transparent 255)
(defconst step-transparent 20) ;; 每次增大/减小透明度的数值
(pop-select/gui-set-transparent cur-transparent)
(defconst step-transparent 20)
(defun dec-transparent()
(interactive)
(setq cur-transparent (min 255 (+ cur-transparent step-transparent)))
(pop-select/gui-set-transparent cur-transparent))
(let* ((rgb (color-name-to-rgb (face-background 'default)))
(r (round (*(nth 0 rgb) 255)))
(g (round (*(nth 1 rgb) 255)))
(b (round (*(nth 2 rgb) 255))))
(pop-select/transparent-set-background cur-transparent r g b)
)
)
(defun inc-transparent()
(interactive)
(setq cur-transparent (max 0 (- cur-transparent step-transparent)))
(pop-select/gui-set-transparent cur-transparent))
(let* ((rgb (color-name-to-rgb (face-background 'default)))
(r (round (*(nth 0 rgb) 255)))
(g (round (*(nth 1 rgb) 255)))
(b (round (*(nth 2 rgb) 255))))
(pop-select/transparent-set-background cur-transparent r g b)
))
(global-set-key (kbd "<C-wheel-up>") 'dec-transparent)
(global-set-key (kbd "<C-wheel-down>") 'inc-transparent)
)
```
2. `pop-select/pop-select`
弹出一个竖型列表窗口,然后可以按ctrl+tab切换到下一项,ctrl+tab+shift切换到上一项,释放按键后返回所选项给emacs
后面这种效果图:
![gif](gif/1.gif)

# 2. CTRL+TAB弹出窗口选择列表 #
`pop-select/pop-select`弹出一个竖型列表窗口,然后可以按ctrl+tab切换到下一项,ctrl+tab+shift切换到上一项,释放按键后返回所选项给emacs
```
(pop-select/pop-select NAME TO-SEL) ;; NAME为vector列表,TO-SEL是初始选中哪项
```
```
(when (fboundp 'pop-select/pop-select)
(defun my-pop-select(&optional backward)
(interactive)
(let* ((myswitch-buffer-list (copy-sequence (buffer-list)
)
)
) (vec_name [])
sel
)
(cl-dolist (buf myswitch-buffer-list)
(setq vec_name (vconcat vec_name (list (buffer-name buf)))))
;; 返回序号
;; 返回序号
(setq sel (pop-select/pop-select vec_name (if backward
(1- (length vec_name))
1
)))
(let ((buf (switch-to-buffer (nth sel myswitch-buffer-list))))
(when (and (bufferp buf) (featurep 'wcy-desktop))
(with-current-buffer buf
(when (eq major-mode 'not-loaded-yet)
(wcy-desktop-load-file))))
(with-current-buffer buf
(when (eq major-mode 'not-loaded-yet)
(wcy-desktop-load-file))))
)
)
)
(global-set-key (kbd "<C-tab>") 'my-pop-select)
(global-set-key (if (string-equal system-type "windows-nt")
(kbd "<C-S-tab>")
(kbd "<C-S-iso-lefttab>"))
(kbd "<C-S-tab>")
(kbd "<C-S-iso-lefttab>"))
(lambda ()(interactive)
(my-pop-select t)))
)
```
3. `pop-select/beacon-blink``pop-select/beacon-set-parameters`
用于替换beacon的闪烁效果,完全不卡Emacs窗口,因为是另起了一个专门的ui线程来画beacon
效果图:
![gif](gif/2.gif)

# 3. "异步"beacon效果 #
用于替换beacon的闪烁效果,完全不卡Emacs窗口,因为是另起了一个专门的ui线程来画beacon。实现函数`pop-select/beacon-blink``pop-select/beacon-set-parameters`
```
(pop-select/beacon-set-parameters WIDTH HEIGHT R G B DURATION-STEP) ;; 可设置宽度,高度,rgb色,以及blink效果显示时间
(pop-select/beacon-blink X Y TIMER DELAY) ;; 在X, Y坐标显示TIMER时长,DELAY是延迟显示时间
```
```
(when (fboundp 'pop-select/beacon-set-parameters)
;; 51afef
Expand All @@ -66,13 +106,13 @@
(setq beacon-blink-when-focused t)
(setq beacon-blink-delay 0.01)
(setq beacon-blink-duration 0.2)
(setq beacon-blink-when-window-scrolls nil) ; 开启了auto save,保存时都会闪故而屏蔽
(setq beacon-blink-when-window-scrolls nil) ; 开启了auto save,保存时都会闪故而屏蔽
:config
(beacon-mode 1)
(defadvice beacon-blink (around my-beacon-blink activate)
;; 目前偶尔不是emacs时也弹窗
;; 目前偶尔不是emacs时也弹窗
;; (message (concat (symbol-name this-command) " " (symbol-name last-command)))
(when (frame-visible-p (window-frame)) ;; 可以阻止最小化时弹窗
(when (frame-visible-p (window-frame)) ;; 可以阻止最小化时弹窗
(let ((p (window-absolute-pixel-position)))
(when p
(pop-select/beacon-blink (car p) ; x
Expand All @@ -82,3 +122,6 @@
))))))
)
```
效果图跟上面一样:
![gif](gif/2.gif)

Binary file added gif/1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gif/2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 881ce3f

Please sign in to comment.