PageRenderTime 38ms CodeModel.GetById 35ms RepoModel.GetById 1ms app.codeStats 0ms

/vendor/popup/README.md

https://bitbucket.org/exu/emacs.d.prelude
Markdown | 334 lines | 218 code | 116 blank | 0 comment | 0 complexity | dcbe83bed87a7133f391358d102dc420 MD5 | raw file
Possible License(s): CC-BY-SA-4.0, GPL-2.0, GPL-3.0
  1. popup.el
  2. ========
  3. [![Build Status](https://secure.travis-ci.org/auto-complete/popup-el.png)](http://travis-ci.org/auto-complete/popup-el)
  4. Overview
  5. --------
  6. popup.el is a visual popup user interface library for Emacs. This
  7. provides a basic API and common UI widgets such as popup tooltips and
  8. popup menus.
  9. Screenshots
  10. -----------
  11. **Tooltip**
  12. ![](http://cx4a.org/software/popup/popup1.png)
  13. **Popup Menu**
  14. ![](http://cx4a.org/software/popup/popup2.png)
  15. **Popup Cascade Menu**
  16. ![](http://cx4a.org/software/popup/popup3.png)
  17. Installation
  18. ------------
  19. Install `popup.el` into your `load-path` directory. If you have
  20. `install-elisp` or `auto-install`, you also be able to install
  21. `popup.el` like:
  22. ;; install-elisp
  23. (install-elisp "https://github.com/m2ym/popup-el/raw/master/popup.el")
  24. ;; auto-install
  25. (auto-install-from-url "https://github.com/m2ym/popup-el/raw/master/popup.el")
  26. popwin is tested under GNU Emacs 22 or later.
  27. Popup Items
  28. -----------
  29. Elements of `popup-list` have to be popup items. A popup item is
  30. substantially a string but it may involve some text-properties. There
  31. are two ways to make popup items. One is just using strings. Another
  32. is to use the `popup-make-item` function, which just returns the string
  33. after adding text-properties of its keywords. Effective text-properties
  34. are:
  35. * `value` -- This represents the **real** value of the item. This will
  36. be used when returning the value but not the item (or string) from
  37. some synchronous functions such as `popup-menu*`.
  38. * `face` -- The background face of the item. The value of `popup-face`
  39. will be overridden.
  40. * `selection-face` -- The selection face of the item. The value of
  41. `popup-selection-face` will be overridden.
  42. * `document` -- The documentation string or function of the item.
  43. * `summary` -- The summary string of the item. This will be shown
  44. inline with the item.
  45. * `symbol` -- The symbol character of the item.
  46. * `sublist` -- The sublist of the item. This is effective only with
  47. `popup-cascade-menu`.
  48. All of properties can be accessed by `popup-item-<property>` utility function.
  49. ### Function: `popup-item-propertize`
  50. popup-item-propertize item &rest properties => item
  51. Same as `propertize` except that this avoids overriding existed value
  52. with `nil` property.
  53. ### Function: `popup-make-item`
  54. popup-make-item name &key value popup-face selection-face sublist
  55. document symbol summary => item
  56. The utility function of `popup-item-propertize`.
  57. Popups
  58. ------
  59. This section describes the basic data structures and operations of
  60. popups.
  61. ### Struct: `popup`
  62. Any instance of `popup` structure has the following fields (some
  63. unimportant fields are not listed):
  64. * `point`
  65. * `row` -- The line number.
  66. * `column`
  67. * `width` -- Max width of `popup` instance.
  68. * `height` -- Max height of `popup` instance.
  69. * `min-height`
  70. * `current-height`
  71. * `direction` -- Positive number means forward, negative number means
  72. backward.
  73. * `parent` -- The parent of `popup` instance.
  74. * `face` -- The background face.
  75. * `selection-face`
  76. * `margin-left`
  77. * `margin-right`
  78. * `scroll-bar` -- Non-nil means `popup` instance has a scroll bar.
  79. * `symbol` -- Non-nil means `popup` instance has a space for
  80. displaying symbols of item.
  81. * `cursor` -- The current position of `list`.
  82. * `scroll-top` -- The offset of scrolling.
  83. * `list` -- The contents of `popup` instance in a list of items
  84. (strings).
  85. * `original-list` -- Same as `list` except that this is not filtered.
  86. All of these fields can be accessed by `popup-<field>` function.
  87. ### Function: `popup-create`
  88. popup-create point width height &key min-height around face
  89. selection-face scroll-bar margin-left margin-right symbol parent
  90. parent-offset => popup
  91. Create a popup instance at `POINT` with `WIDTH` and `HEIGHT`.
  92. `MIN-HEIGHT` is the minimal height of the popup. The default value is 0.
  93. If `AROUND` is non-nil, the popup will be displayed around the point
  94. but not at the point.
  95. `FACE` is the background face of the popup. The default value is
  96. `popup-face`.
  97. `SELECTION-FACE` is the foreground (selection) face of the popup The
  98. default value is `popup-face`.
  99. If `SCROLL-BAR` is non-nil, the popup will have a scroll bar at the
  100. right.
  101. If `MARGIN-LEFT` is non-nil, the popup will have a margin at the left.
  102. If `MARGIN-RIGHT` is non-nil, the popup will have a margin at the
  103. right.
  104. `SYMBOL` is a single character which indicates the kind of the item.
  105. `PARENT` is the parent popup instance. If `PARENT` is omitted, the popup
  106. will be a root instance.
  107. `PARENT-OFFSET` is a row offset from the parent popup.
  108. Here is an example:
  109. (setq popup (popup-create (point) 10 10))
  110. (popup-set-list popup '("Foo" "Bar" "Baz"))
  111. (popup-draw popup)
  112. ;; do something here
  113. (popup-delete popup)
  114. ### Function: `popup-delete`
  115. popup-delete popup
  116. Delete the `POPUP`.
  117. ### Function: `popup-live-p`
  118. popup-live-p popup => boolean
  119. ### Function: `popup-set-list`
  120. popup-set-list popup list
  121. Set the contents of the `POPUP`. `LIST` has to be popup items.
  122. ### Function: `popup-draw`
  123. popup-draw popup
  124. Draw the contents of the `POPUP`.
  125. ### Function: `popup-hide`
  126. popup-hide popup
  127. Hide the `POPUP`. To show again, call `popup-draw`.
  128. ### Function: `popup-hidden-p`
  129. popup-hidden-p popup
  130. Return non-nil if the `POPUP` is hidden.
  131. ### Function: `popup-select`
  132. popup-select popup index
  133. Select the item of `INDEX` of the `POPUP`.
  134. ### Function: `popup-selected-item`
  135. popup-selected-item popup => item
  136. Return the selected item of the `POPUP`.
  137. Return non-nil if the `POPUP` is still alive.
  138. ### Function: `popup-next`
  139. popup-next popup
  140. Select the next item of the `POPUP`.
  141. ### Function: `popup-previous`
  142. popup-previous popup
  143. Select the next item of the `POPUP`.
  144. ### Function: `popup-scroll-down`
  145. popup-scroll-down popup n
  146. Scroll down `N` items of the `POPUP`. This won't wrap.
  147. ### Function: `popup-scroll-up`
  148. popup-scroll-up popup n
  149. Scroll up `N` items of the `POPUP`. This won't wrap.
  150. ### Function: `popup-isearch`
  151. popup-isearch popup &key cursor-color keymap callback help-delay
  152. => boolean
  153. Enter incremental search event loop of `POPUP`.
  154. Tooltips
  155. --------
  156. A tooltip is an useful visual UI widget for displaying information
  157. something about what cursor points to.
  158. ### Function: `popup-tip`
  159. popup-tip string &key point around width height min-height
  160. truncate margin margin-left margin-right scroll-bar parent
  161. parent-offset nowait prompt
  162. Show a tooltip with message `STRING` at `POINT`. This function is
  163. synchronized unless `NOWAIT` specified. Almost all arguments are same as
  164. `popup-create` except for `TRUNCATE`, `NOWAIT`, and `PROMPT`.
  165. If `TRUNCATE` is non-nil, the tooltip can be truncated.
  166. If `NOWAIT` is non-nil, this function immediately returns the tooltip
  167. instance without entering event loop.
  168. `PROMPT` is a prompt string used when reading events during the event
  169. loop.
  170. Here is an example:
  171. (popup-tip "Hello, World!")
  172. ;; reach here after the tooltip disappeared
  173. Popup Menus
  174. -----------
  175. Popup menu is an useful visual UI widget for prompting users to
  176. select an item of a list.
  177. ### Function: `popup-menu*`
  178. popup-menu* list &key point around width height margin margin-left
  179. margin-right scroll-bar symbol parent parent-offset keymap
  180. fallback help-delay nowait prompt isearch isearch-cursor-color
  181. isearch-keymap isearch-callback => selected-value
  182. Show a popup menu of `LIST` at `POINT`. This function returns the value
  183. of the selected item. Almost all arguments are same as `popup-create`
  184. except for `KEYMAP`, `FALLBACK`, `HELP-DELAY`, `PROMPT`, `ISEARCH`,
  185. `ISEARCH-CURSOR-COLOR`, `ISEARCH-KEYMAP`, and `ISEARCH-CALLBACK`.
  186. If `KEYMAP` is provided, it is a keymap which is used when processing
  187. events during event loop.
  188. If `FALLBACK` is provided, it is a function taking two arguments; a key
  189. and a command. `FALLBACK` is called when no special operation is found
  190. on the key. The default value is `popup-menu-fallback`, which does
  191. nothing.
  192. `HELP-DELAY` is a delay of displaying helps.
  193. If `NOWAIT` is non-nil, this function immediately returns the menu
  194. instance without entering event loop.
  195. `PROMPT` is a prompt string when reading events during event loop.
  196. If `ISEARCH` is non-nil, do isearch as soon as displaying the popup
  197. menu.
  198. `ISEARCH-CURSOR-COLOR` is a cursor color during isearch. The default
  199. value is `popup-isearch-cursor-color'.
  200. `ISEARCH-KEYMAP` is a keymap which is used when processing events
  201. during event loop. The default value is `popup-isearch-keymap`.
  202. `ISEARCH-CALLBACK` is a function taking one argument. `popup-menu`
  203. calls `ISEARCH-CALLBACK`, if specified, after isearch finished or
  204. isearch canceled. The arguments is whole filtered list of items.
  205. Here is an example:
  206. (popup-menu* '("Foo" "Bar" "Baz"))
  207. ;; => "Baz" if you select Baz
  208. (popup-menu* (list (popup-make-item "Yes" :value t)
  209. (popup-make-item "No" :value nil)))
  210. ;; => t if you select Yes
  211. ### Function: `popup-cascade-menu`
  212. Same as `popup-menu` except that an element of `LIST` can be also a
  213. sub-menu if the element is a cons cell formed `(ITEM . SUBLIST)` where
  214. `ITEM` is an usual item and `SUBLIST` is a list of the sub menu.
  215. Here is an example:
  216. (popup-cascade-menu '(("Top1" "Sub1" "Sub2") "Top2"))
  217. ----
  218. Copyright (C) 2011 Tomohiro Matsuyama <<tomo@cx4a.org>>