[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/popup 69d5bf9 095/184: Support max-width for popup instanc
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/popup 69d5bf9 095/184: Support max-width for popup instance |
Date: |
Wed, 6 Oct 2021 00:01:19 -0400 (EDT) |
branch: elpa/popup
commit 69d5bf9e42bdf11b0d5d78800c1c6d97289ea4aa
Author: Syohei YOSHIDA <syohex@gmail.com>
Commit: Syohei YOSHIDA <syohex@gmail.com>
Support max-width for popup instance
Patch of pull request #29 cannot be merged now. I fix it for
current popup.el.
---
README.md | 8 ++++++--
popup.el | 19 ++++++++++++++++++-
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index f4b1814..c2e2c3c 100644
--- a/README.md
+++ b/README.md
@@ -117,7 +117,7 @@ All of these fields can be accessed by `popup-<field>`
function.
### Function: `popup-create`
- popup-create point width height &key min-height around face
+ popup-create point width height &key min-height max-width around face
selection-face scroll-bar margin-left margin-right symbol parent
parent-offset => popup
@@ -125,6 +125,10 @@ Create a popup instance at `POINT` with `WIDTH` and
`HEIGHT`.
`MIN-HEIGHT` is the minimal height of the popup. The default value is 0.
+`MAX-WIDTH` is the maximum width of the popup. The default value is
+nil (no limit). If a floating point, the value refers to the ratio of
+the window. If an integer, limit is in characters.
+
If `AROUND` is non-nil, the popup will be displayed around the point
but not at the point.
@@ -244,7 +248,7 @@ something about what cursor points to.
### Function: `popup-tip`
- popup-tip string &key point around width height min-height
+ popup-tip string &key point around width height min-height max-width
truncate margin margin-left margin-right scroll-bar parent
parent-offset nowait nostrip prompt
diff --git a/popup.el b/popup.el
index b00c6b8..7767cb0 100644
--- a/popup.el
+++ b/popup.el
@@ -37,6 +37,13 @@
;;; Utilities
+(defun popup-calculate-max-width (max-width)
+ "Determines whether the width desired is
+character or window proportion based, And returns the result."
+ (cl-typecase max-width
+ (integer max-width)
+ (float (* (ceiling (/ (round (* max-width (window-width))) 10.0)) 10))))
+
(defvar popup-use-optimized-column-computation t
"Use the optimized column computation routine.
If there is a problem, please set it nil.")
@@ -474,6 +481,7 @@ number at the point."
height
&key
min-height
+ max-width
around
(face 'popup-face)
mouse-face
@@ -491,6 +499,10 @@ number at the point."
MIN-HEIGHT is a minimal height of the popup. The default value is
0.
+MAX-WIDTH is the maximum width of the popup. The default value is
+nil (no limit). If a floating point, the value refers to the ratio of
+the window. If an integer, limit is in characters.
+
If AROUND is non-nil, the popup will be displayed around the
point but not at the point.
@@ -521,7 +533,8 @@ KEYMAP is a keymap that will be put on the popup contents."
(unless point
(setq point
(if parent (popup-child-point parent parent-offset) (point))))
-
+ (when max-width
+ (setq width (min width (popup-calculate-max-width max-width))))
(save-excursion
(goto-char point)
(let* ((row (line-number-at-pos))
@@ -996,6 +1009,7 @@ HELP-DELAY is a delay of displaying helps."
width
(height 15)
min-height
+ max-width
truncate
margin
margin-left
@@ -1036,6 +1050,7 @@ PROMPT is a prompt string when reading events during
event loop."
(setq tip (popup-create point width height
:min-height min-height
+ :max-width max-width
:around around
:margin-left margin-left
:margin-right margin-right
@@ -1272,6 +1287,7 @@ PROMPT is a prompt string when reading events during
event loop."
(around t)
(width (popup-preferred-width list))
(height 15)
+ max-width
margin
margin-left
margin-right
@@ -1332,6 +1348,7 @@ isearch canceled. The arguments is whole filtered list of
items."
;; Make scroll-bar space as margin-right
(cl-decf margin-right))
(setq menu (popup-create point width height
+ :max-width max-width
:around around
:face 'popup-menu-face
:mouse-face 'popup-menu-mouse-face
- [nongnu] elpa/popup 357f037 045/184: Add test case:popup-tip(height), (continued)
- [nongnu] elpa/popup 357f037 045/184: Add test case:popup-tip(height), ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup b8c1cb4 054/184: At least one space before summary, if possible, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 7533efe 078/184: Merge pull request #53 from auto-complete/fix-travis, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 64102c2 046/184: Add test case:popup-tip(scroll-bar, min-height), ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 487c0a8 109/184: add :initial-index parameter test, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 8719cd9 105/184: Merge pull request #71 from auto-complete/use-cask, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 1510820 100/184: activate isearch in cascade menu, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 58f55de 096/184: Merge pull request #62 from auto-complete/support-max-width, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup afeaed3 082/184: Merge branch 'master' into use-cl-lib, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 70c2583 093/184: Add 'nostrip' parameter explanation to docstring, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 69d5bf9 095/184: Support max-width for popup instance,
ELPA Syncer <=
- [nongnu] elpa/popup 9587ace 085/184: Merge pull request #55 from auto-complete/fix-bytecompile-warnings, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup d70cff9 101/184: Merge pull request #64 from aki2o/cascade-isearch, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup c02ec73 111/184: Apply the patch of #8., ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 895d031 123/184: Add MELPA badges, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup d8fe6b0 102/184: Use Cask instead of 'git submodule', ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 649242e 118/184: :initial-index respects real popup height(beyond first popup page), ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 2bb4bce 115/184: fix error on popup-delete when char-before return nil, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 1f817d6 097/184: fixed deficient help-delay, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup becfbdd 099/184: Merge pull request #63 from aki2o/fix-deficient-help-delay, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup c3ebfba 094/184: Merge pull request #61 from auto-complete/add-nostrip-documentation, ELPA Syncer, 2021/10/06