forked from jorgenschaefer/elpy
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathflight-attendant-ui.el
93 lines (84 loc) · 3.03 KB
/
flight-attendant-ui.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
;;; flight-attendant-ui.el --- Description -*- lexical-binding: t; -*-
;;
;; Copyright (C) 2021
;;
;; Author: fkr <https://github.com/fkr-0>
;; Maintainer: also me
;; Created: December 02, 2021
;; Modified: December 02, 2021
;; Version: 0.0.1
;; Keywords: abbrev bib c calendar comm convenience data docs emulations extensions faces files frames games hardware help hypermedia i18n internal languages lisp local maint mail matching mouse multimedia news outlines processes terminals tex tools unix vc wp
;; Homepage: https://github.com/fkr_0/flight-attendant.el
;; Package-Requires: ((emacs "24.3"))
;;
;; This file is not part of GNU Emacs.
;;
;;; Commentary:
;;
;; Description
;;
;;; Code:
(defface fa-overlay-face
'((t :inherit shadow))
"The face used for code lens overlays."
:group 'fa-overlay)
(defface fa-overlay-mouse-face
'((t :box t))
"The face used for code lens overlays."
:group 'fa-overlay)
(defvar fa-overlay nil)
(defun fa-display-overlay-str (str line col)
"Displays STR at LINE, COL."
(overlay-recenter (point-max))
(fa-clear-overlay)
(save-excursion
(widen)
(goto-char 1)
(let* ((l1 (+ line 1))
ov
start
end
(propstr (propertize str
'face 'fa-overlay-face
'mouse-face 'fa-overlay-mouse-face)))
;; 'local-map map
;; (pcase ccls-code-lens-position
;; ('end
;; (forward-line (- l0 line))
;; (if (and ov (= l0 line))
;; (overlay-put ov 'display
;; (concat (overlay-get ov 'display)
;; str))
;; (when ov
;; (overlay-put ov 'display (concat (overlay-get ov 'display) "\n")))
;; (let ((p (point-at-eol)))
;; (setq ov (make-overlay p (1+ p) nil 'front-advance))
;; (overlay-put ov 'fa-overlay-str t)
;; (overlay-put ov 'display str)))
;; (setq line l0 col c0))
;; ('inplace
(forward-line line)
(forward-char col)
(setq line l1)
(setq start (point))
(insert propstr)
(setq end (point))
(setq ov (make-overlay start end nil t))
(overlay-put ov 'fa-overlay-str t)
(overlay-put ov 'face 'fa-overlay-face)
(overlay-put ov 'insert-before-hooks (lambda (st en reg) (message "imthere")))
(setq fa-overlay ov))))
;; (overlay-put ov 'after-string propstr))))
;; (When (and (eq ccls-code-lens-position 'end) ov)
;; (overlay-put ov 'display (concat (overlay-get ov 'display) "\n"))))))
(defun fa-clear-overlay ()
"Clear all overlays from this buffer."
(interactive)
(and fa-overlay
(let ((ov-start (overlay-start fa-overlay))
(ov-end (overlay-end fa-overlay)))
(and ov-start ov-end
(delete-region (overlay-start fa-overlay) (overlay-end fa-overlay)))))
(remove-overlays (point-min) (point-max) 'fa-overlay-str t))
(provide 'flight-attendant-ui)
;;; flight-attendant-ui.el ends here