Emacs - 如何创建一个垂直的穿透效果 [英] Emacs -- How to create a vertical strike-through effect

查看:113
本文介绍了Emacs - 如何创建一个垂直的穿透效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一些建议,如何创建一个垂直的贯穿的视觉效果(顶部的 (>\\\|)仍然可见)。如果可以进行分层,那么垂直条应该在下面,以便字母大多可见。



我搜索了一种叠加字符,叠加叠加的方法,我看了然而,在某些xpm图像中,我没有发现任何远近我正在寻找的东西。目标是具有类似于下面的图像的真正的十字线效果 - 灰色背景将被黄色垂直穿透替代,以使字母仍然可见。



示例http://www.lawlist.com/images/vertical_strike_through_c.jpg



示例http:/ /www.lawlist.com/images/vertical_strike_through_a.png

解决方案

功能请求22873涉及创建多个游标(内置到C源代码库): https://debbugs.gnu .org / cgi / bugreport.cgi?bug = 22873 不知道这些功能是否会被并入官方Emacs,但是我已经创建了一个补丁概念概念(作为第三稿)可以为Windows(XP SP3)和OSX(10.6.8)的Emacs的GUI版本放置多个假光标 - 包括每个假光标的不同颜色和不同的游标类型。 p>

另请参见相关功能请求17684绘制垂直线的窗口长度和字符,超出初始请求的值: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=17684






示例1/3



以下代码片段与某些操作系统之间的一些字体一起使用 - 例如,它在Windows上开箱即用;但是,它不适用于OSX 10.6.8 Snow Leopard或Snow Leopard Server 10.6.8上的此作者。 [见错误报告编号20537 - https://debbugs.gnu.org/ cgi / bugreport.cgi?bug = 20537 - 尽管Emacs开发团队正式关闭了错误报告,但是作者在bug修复之后,从未能够在Snow Leopard上使用该功能。 :(]用户可能希望尝试使用字形参考点,并且 composite.el reference-point-alist $ c>具有与之相关的详细文档字符串,用户还可以尝试使用 after-string before-string display property。图书馆 vline.el at http://www.emacswiki.org/emacs/vline.el 有一个名为 vline-style 的变量,可以设置到'face 'compose 'mixed - 后两个设置导致 vline 使用此代码段的一些变化[参见所述库的第362至370行]。

 (let *(
(point-min(point-min))
(point-max
(pt(point))
(pt + 1(1+ pt))
(char(char-after pt))
(line-char (string-to-char|))
(str(当char(compose-chars char'(tc。 tc)line-char))))
(overlay-put(make-overlay pt pt + 1)'显示str)
(sit-for 2)
(remove-overlays point- min point-max'display str))






示例2/3



以下代码片段使用一个称为零空格的Unicode字符(即 uFEFF )。因为空间不能接收到前景色,所以使用背景颜色来给零宽度空间提供拉伸整个线高度的细垂直线的可见性。如在此代码片段的上下文中使用的,零宽度空间的宽度为1像素,并且连接的字符大小减小,以使两个组合字符的宽度等于 frame-char -width 。这个代码片段的测试是使用默认字体 - * - Monaco-normal-normal-normal - * - 12 - * - * - * - m-0-iso10646-1在OSX操作系统上完成的。在此示例中,光标在短时间内被删除,以便可以更清晰地看到覆盖。

 (let *(
(point-min(point-min))
(point-max(point-max))
(pt(point))
+1(1+ pt))
(char(char-after pt))
(char-str(当char(char-to-string char)))
(ln-char -str(char-to-string?\\\))
(str(当char
(concat
(propertize ln-char-str'face'(:backgroundred) )
(属性char-str'face'(:height 100))))))
(internal-show-cursor nil nil)
(overlay-put(make-overlay pt pt +1)'display str)
(sit-for 2)
(internal-show-cursor nil t)
(remove-overlays point-min point-max'display str))






示例3/3



以下是使用图形的xpm图像叠加层的示例cal Emacs版本,支持xpm图像格式。宽11像素20像素高;并有4种预选颜色。我正在Mac上运行Snow Leopard 10.6.8,当我使用Emacs时,我喜欢的字体是 - * - Courier-normal-normal-normal - * - 18 - * - * - * - m-0 -iso10646-1 - frame-char-width 是11,而 frame-char-height 是20.我在大写字母A的左侧添加了一条薄的垂直黄线,作为如何绘制自定义图像的示例。可以使用(char-after(point))以数字代替字符,在这种情况下,大写字母A为65 - 替换适当的变量 - 例如(cond((eq(char-after(point))65)cap-lt-a-xpm)... - 并且在覆盖放置中使用该变量 - 例如,(覆盖放置(make-overlay(点)(1+(点)))'显示cap-ltr-a-xpm )。这对两个截断的缓冲区以及单词换行都非常好地工作,因为显示覆盖属性在一个字的中间不会造成word-wrap认为这个单词的第一部分属于上一行的结尾,当然,创建一个喜欢的xpm图像的自定义库将需要一些时间,在此期间短时间内删除光标例如,可以更清晰地看到覆盖图。



ImageMagick能够产生半精确的xpm基于特定字体系列和大小的特定字符,但它并不像我所希望的那样精确 - 这里是使用该外部实用程序的指示的链接: https://stackoverflow.com/a/14168154/2112489 简而言之,用户应该准备好按照自己喜欢的时间自定义xpm图像。

 (let *(
(pt(point))
(pt + 1
(point-min(point-min))
(point-max(point-max))
(cap-ltr-a-xpm`(image:type xpm:mask nil:ascent center:data
/ * XPM * /
static char * letters_xpm [] = {
/ *列行颜色chars-per-pixel * /
/ * columns = 1像素的宽度 - 另请参见(frame-char-width)* /
/ * rows = 1像素的高度 - 另请参见(frame-char-height)* /
\11 20 4 1\,
\。 c#000000\,
\+ c#FF0000\,
\@ c#7F0000\,
\%c yellow\ ,
\%.......... \,
\%.... ++ .... \,
\\ \\%.... ++ .... \,
\%.. ++ .. ++ .. \,
\%.. + + .. ++ .. \,
\%++ ...... ++ \,
\%++ ...... + + \,
\%++ ...... ++ \,
\%++ ...... ++ \,
\%++ ...... ++ \,
\%++ ...... ++ \,
\ %+++++++++++,
\%+++++++++++,
\%++ ... ... ++ \,
\%++ ...... ++ \,
\%++ ...... ++ \\ \\,
\%++ ...... ++ \,
\%++ ...... ++ \,
\%++ ...... ++ \,
\%.......... \};)))
(internal-show-cursor nil nil)
(overlay-put(make-overlay pt pt + 1)'显示cap-ltr-a-
(sit-for 2)
(internal-show-cursor nil t)
(remove-overlays point-min point-max'display cap-ltr-a-xpm))

以下代码段与上述类似,除了使用 after-string 显示属性。在此功能期间,光标在短时间内被移除,以便可以更清晰地看到覆盖。

 (let *(
(point-min(point-min))
(point-max(point-max))
(peol(point-at-eol))
(pilcrow`(image:type xpm:mask nil:ascent center:data
/ * XPM * /
static char * pilcrow_xpm [] = {
\11 20 4 1 \,
\c#000000 \,
\+ c orange\,
\@ c#7F0000\ b $ b \%c yellow\,
\%.......... \,
\%....... ... \,
\%.......... \,
\%.......... \ ,
\%.. ++++++ .. \,
\%。++++。+ ... \,
\\ \\%。++++。+ ... \,
\%。++++。+ ... \,
\%.. + ++。+ ... \,
\%.... +。+ ... \,
\%。 ... +。+ ... \,
\%.... +。+ ... \,
\%.... + ... \,
\%.... +。+ ... \,
\%.......... \ ,
\%.......... \,
\%.......... \,
\\ \\%.......... \,
\%.......... \,
\%... .......... \};))
(pilcrow-str(propertize'显示pilcrow)))
(overlay-put(make-overlay peol peol) -string pilcrow-str)
(sit-for 2)
(remove-overlays point-min point-max'after-string pilcrow-str)






使用第二个示例进行以下截图。



示例http://www.lawlist.com/images/vertical_line_demo_a.png


I'm looking for some suggestions, please, of how to create the visual effect of a vertical strike-through (with the character on top of the vertical bar ("\u007C") still being visible). If layering is possible, then the vertical bar should be underneath so that the letter is mostly visible.

I searched for a method of superimposing characters, layering overlays, and I looked at some xpm images, however, I have not found anything remotely close to what I'm looking for. The goal is to have a true cross-hairs effect similar to the image below -- the gray background would be replaced with a yellow vertical strike-through so that the letters would still be visible.

Example http://www.lawlist.com/images/vertical_strike_through_c.jpg

Example http://www.lawlist.com/images/vertical_strike_through_a.png

解决方案

Feature request 22873 deals with creating multiple cursors (built-in to the C source code base): https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22873 It is unknown if those features will ever be incorporated into the official Emacs, but I have already created a draft patch concept idea that (as of the third draft) is able to place multiple fake cursors for GUI versions of Emacs for Windows (XP SP3) and OSX (10.6.8) -- including, different colors and different cursor types for each fake cursor.

See also related feature request 17684 to draw vertical lines the length of the window and through characters, which has no activity beyond the initial request: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=17684


EXAMPLE 1 of 3:

The following code snippet works with some fonts on some operating systmes -- e.g., it works out of the box on Windows; however, it does not work for this author on OSX 10.6.8 Snow Leopard or Snow Leopard Server 10.6.8. [See bug report number 20537 -- https://debbugs.gnu.org/cgi/bugreport.cgi?bug=20537 -- even though the bug report has been officially closed by the Emacs development team, this author has never been able to get that feature working on Snow Leopard subsequent to the "bug fix". :( ] The user may wish to experiment with the glyph reference points, and the variable reference-point-alist in composite.el has a detailed doc-string in relation thereto. The user may also wish to experiment with using an after-string or before-string display property. The library vline.el at http://www.emacswiki.org/emacs/vline.el has a variable named vline-style, which can be set to 'face, 'compose, or 'mixed -- the latter two settings cause vline to use a slight variation of this code snippet [see lines 362 to 370 of said library].

(let* (
    (point-min (point-min))
    (point-max (point-max))
    (pt (point))
    (pt+1 (1+ pt))
    (char (char-after pt))
    (line-char (string-to-char "|"))
    (str (when char (compose-chars char '(tc . tc) line-char))) ) 
  (overlay-put (make-overlay pt pt+1) 'display str)
  (sit-for 2)
  (remove-overlays point-min point-max 'display str))


EXAMPLE 2 of 3:

The following code snippet uses a unicode character known as a zero-with space (i.e., uFEFF). Because a space cannot receive a foreground color, a background color is used to give the zero-width space the apparance of a thin vertical line that stretches the entire line height. As used in the context of this code snippet, the zero-width space has a width of 1 pixel and the concatenated charcter is reduced in size so that the two combined characters have a width equal to the frame-char-width. Testing of this snippet was done on an OSX operating system using the default font of -*-Monaco-normal-normal-normal-*-12-*-*-*-m-0-iso10646-1. The cursor is removed for a short duration during this example so that the overlay can be seen more clearly.

(let* (
    (point-min (point-min))
    (point-max (point-max))
    (pt (point))
    (pt+1 (1+ pt))
    (char (char-after pt))
    (char-str (when char (char-to-string char)))
    (ln-char-str (char-to-string ?\uFEFF))
    (str (when char
      (concat
        (propertize ln-char-str 'face '(:background "red"))
        (propertize char-str 'face '(:height 100))))) )
  (internal-show-cursor nil nil)
  (overlay-put (make-overlay pt pt+1) 'display str)
  (sit-for 2)
  (internal-show-cursor nil t)
  (remove-overlays point-min point-max 'display str))


EXAMPLE 3 of 3:

The following is an example using an overlay with an xpm image for graphical Emacs versions that support xpm image format. It is 11 pixels wide; 20 pixels high; and has 4 preselected colors. I am on a Mac running Snow Leopard 10.6.8 and the font I prefer when using Emacs is -*-Courier-normal-normal-normal-*-18-*-*-*-m-0-iso10646-1 -- the frame-char-width is 11 and the frame-char-height is 20. I have added a thin vertical yellow line to the left of the capital letter "A" as an example of how to draw custom images. Substitution of the character at point can be made programmatically using (char-after (point)) and taking that number -- which in this case is 65 for the capital letter "A" -- and substituting the appropriate variable -- e.g., (cond ((eq (char-after (point)) 65) cap-ltr-a-xpm) . . . -- and using that variable in the the overlay placement -- e.g., (overlay-put (make-overlay (point) (1+ (point))) 'display cap-ltr-a-xpm). This works very nicely for both truncated buffers and also with word-wrap because the display overlay property on a character in the middle of a word does not cause word-wrap to think that the first part of the word belongs at the end of the previous line. Naturally, it will take time to create a custom library of favorite xpm images. The cursor is removed for a short duration during this example so that the overlay can be seen more clearly.

ImageMagick is capable of producing a semi-accurate xpm of a particular character based on a specific font family and size, but it was not as precise as I had hoped -- here is a link to instructions for using that external utility: https://stackoverflow.com/a/14168154/2112489 In a nutshell, the user should be prepared to spend time customizing the xpm images to his / her liking.

(let* (
    (pt (point))
    (pt+1 (1+ pt))
    (point-min (point-min))
    (point-max (point-max))
    (cap-ltr-a-xpm `(image :type xpm :mask nil :ascent center :data
      "/* XPM */
      static char * letters_xpm[] = {
      /* columns rows colors chars-per-pixel */
      /* columns = 1 pixel in width -- see also (frame-char-width) */
      /* rows = 1 pixel in height -- see also (frame-char-height) */
      \"11 20 4 1\",
      \". c #000000\",
      \"+ c #FF0000\",
      \"@ c #7F0000\",
      \"% c yellow\",
      \"%..........\",
      \"%....++....\",
      \"%....++....\",
      \"%..++..++..\",
      \"%..++..++..\",
      \"%++......++\",
      \"%++......++\",
      \"%++......++\",
      \"%++......++\",
      \"%++......++\",
      \"%++......++\",
      \"%++++++++++\",
      \"%++++++++++\",
      \"%++......++\",
      \"%++......++\",
      \"%++......++\",
      \"%++......++\",
      \"%++......++\",
      \"%++......++\",
      \"%..........\"};"))  )
  (internal-show-cursor nil nil)
  (overlay-put (make-overlay pt pt+1) 'display cap-ltr-a-xpm)
  (sit-for 2)
  (internal-show-cursor nil t)
  (remove-overlays point-min point-max 'display cap-ltr-a-xpm))

The following code snippet is similar to the one above, except it uses the after-string display property. The cursor is removed for a short duration during this function so that the overlay can be seen more clearly.

(let* (
    (point-min (point-min))
    (point-max (point-max))
    (peol (point-at-eol))
    (pilcrow `(image :type xpm :mask nil :ascent center :data
      "/* XPM */
      static char * pilcrow_xpm[] = {
      \"11 20 4 1\",
      \". c #000000\",
      \"+ c orange\",
      \"@ c #7F0000\",
      \"% c yellow\",
      \"%..........\",
      \"%..........\",
      \"%..........\",
      \"%..........\",
      \"%..++++++..\",
      \"%.++++.+...\",
      \"%.++++.+...\",
      \"%.++++.+...\",
      \"%..+++.+...\",
      \"%....+.+...\",
      \"%....+.+...\",
      \"%....+.+...\",
      \"%....+.+...\",
      \"%....+.+...\",
      \"%..........\",
      \"%..........\",
      \"%..........\",
      \"%..........\",
      \"%..........\",
      \"%..........\"};"))
    (pilcrow-str (propertize " " 'display pilcrow)) )
  (overlay-put (make-overlay peol peol) 'after-string pilcrow-str)
  (sit-for 2)
  (remove-overlays point-min point-max 'after-string pilcrow-str))


The following screenshot was made using the second example.

Example http://www.lawlist.com/images/vertical_line_demo_a.png

这篇关于Emacs - 如何创建一个垂直的穿透效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆