zsh-workers
 help / color / mirror / code / Atom feed
* region_highlight and zle_highlight[paste]
@ 2015-09-07 21:22 Daniel Shahaf
  2015-09-08  8:27 ` Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Shahaf @ 2015-09-07 21:22 UTC (permalink / raw)
  To: zsh-workers

Since region_highlight overrides zle_highlight[paste], as a widget
writer I'd like to know what part of $BUFFER is being paste-highlighted,
in order to avoid setting region_highlight entries for it.

Does this seem reasonable?  

Daniel

diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index 4e93695..51e8a24 100644
--- a/Doc/Zsh/zle.yo
+++ b/Doc/Zsh/zle.yo
@@ -1000,6 +1000,18 @@ executed; the second argument that followed tt(zle -C) when the widget was
 defined.  This is the name of a builtin completion widget.  For widgets
 defined with tt(zle -N) this is set to the empty string.  Read-only.
 )
+vindex(YANK_ACTIVE)
+vindex(YANK_START)
+vindex(YANK_END)
+xitem(tt(YANK_ACTIVE) (integer))
+xitem(tt(YANK_START) (integer))
+xitem(tt(YANK_END) (integer))(
+These three parameters indicate whether text has just been yanked (pasted)
+into the buffer.  tt(YANK_START) and tt(YANK_END) are in the same unit sas
+tt(CURSOR), and are only valid when tt(YANK_ACTIVE) is non-zero.
+
+All three are read-only.
+)
 vindex(ZLE_STATE)
 item(tt(ZLE_STATE) (scalar))(
 Contains a set of space-separated words that describe the current tt(zle)
diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index b84e720..000bc38 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -97,6 +97,12 @@ static const struct gsu_integer undo_change_no_gsu =
 { get_undo_current_change, NULL, zleunsetfn };
 static const struct gsu_integer undo_limit_no_gsu =
 { get_undo_limit_change, set_undo_limit_change, zleunsetfn };
+static const struct gsu_integer yankstart_gsu =
+{ get_yankstart, NULL, zleunsetfn };
+static const struct gsu_integer yankend_gsu =
+{ get_yankend, NULL, zleunsetfn };
+static const struct gsu_integer yankactive_gsu =
+{ get_yankactive, NULL, zleunsetfn };
 
 static const struct gsu_array killring_gsu =
 { get_killring, set_killring, unset_killring };
@@ -143,6 +149,9 @@ static struct zleparam {
     { "WIDGET", PM_SCALAR | PM_READONLY, GSU(widget_gsu), NULL },
     { "WIDGETFUNC", PM_SCALAR | PM_READONLY, GSU(widgetfunc_gsu), NULL },
     { "WIDGETSTYLE", PM_SCALAR | PM_READONLY, GSU(widgetstyle_gsu), NULL },
+    { "YANK_START", PM_INTEGER | PM_READONLY, GSU(yankstart_gsu), NULL },
+    { "YANK_END", PM_INTEGER | PM_READONLY, GSU(yankend_gsu), NULL },
+    { "YANK_ACTIVE", PM_INTEGER | PM_READONLY, GSU(yankactive_gsu), NULL },
     { "ZLE_STATE", PM_SCALAR | PM_READONLY, GSU(zle_state_gsu), NULL },
     { NULL, 0, NULL, NULL }
 };
@@ -477,6 +486,27 @@ get_pending(UNUSED(Param pm))
 }
 
 /**/
+static zlong
+get_yankstart(UNUSED(Param pm))
+{
+    return yankb;
+}
+
+/**/
+static zlong
+get_yankend(UNUSED(Param pm))
+{
+    return yanke;
+}
+
+/**/
+static zlong
+get_yankactive(UNUSED(Param pm))
+{
+    return lastcmd & ZLE_YANK;
+}
+
+/**/
 static char *
 get_cutbuffer(UNUSED(Param pm))
 {


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: region_highlight and zle_highlight[paste]
  2015-09-07 21:22 region_highlight and zle_highlight[paste] Daniel Shahaf
@ 2015-09-08  8:27 ` Peter Stephenson
  2015-09-08 10:27   ` Mikael Magnusson
  2015-09-10 19:12   ` Daniel Shahaf
  0 siblings, 2 replies; 5+ messages in thread
From: Peter Stephenson @ 2015-09-08  8:27 UTC (permalink / raw)
  To: zsh-workers

On Mon, 7 Sep 2015 21:22:11 +0000
Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> Since region_highlight overrides zle_highlight[paste], as a widget
> writer I'd like to know what part of $BUFFER is being paste-highlighted,
> in order to avoid setting region_highlight entries for it.
> 
> Does this seem reasonable?  

It's not much code, so if this is useful in practice, I'd say yes.

pws


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: region_highlight and zle_highlight[paste]
  2015-09-08  8:27 ` Peter Stephenson
@ 2015-09-08 10:27   ` Mikael Magnusson
  2015-09-08 10:41     ` Peter Stephenson
  2015-09-10 19:12   ` Daniel Shahaf
  1 sibling, 1 reply; 5+ messages in thread
From: Mikael Magnusson @ 2015-09-08 10:27 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh workers

On Tue, Sep 8, 2015 at 10:27 AM, Peter Stephenson
<p.stephenson@samsung.com> wrote:
> On Mon, 7 Sep 2015 21:22:11 +0000
> Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
>> Since region_highlight overrides zle_highlight[paste], as a widget
>> writer I'd like to know what part of $BUFFER is being paste-highlighted,
>> in order to avoid setting region_highlight entries for it.
>>
>> Does this seem reasonable?
>
> It's not much code, so if this is useful in practice, I'd say yes.

I noticed that a specification for fg=red overrides a bg=blue
specification to no background. Would it be easy to merge these
instead? (for example bold + bg=blue works already).

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: region_highlight and zle_highlight[paste]
  2015-09-08 10:27   ` Mikael Magnusson
@ 2015-09-08 10:41     ` Peter Stephenson
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2015-09-08 10:41 UTC (permalink / raw)
  To: zsh workers

On Tue, 8 Sep 2015 12:27:13 +0200
Mikael Magnusson <mikachu@gmail.com> wrote:
> I noticed that a specification for fg=red overrides a bg=blue
> specification to no background. Would it be easy to merge these
> instead? (for example bold + bg=blue works already).

I think that's probably doable, though I have no interest in doing it
myself.  At the point in the code I indicated to Daniel you'd need to
check if the attrribute currently being set didn't have TXTBGCOLOUR but
what was previously in effect did, and in that case transfer the
attribute.  That doesn't sound too hard, but I haven't looked at this
stuff for years (so the flags may not behave quite the way I'm
assuming).

pws


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: region_highlight and zle_highlight[paste]
  2015-09-08  8:27 ` Peter Stephenson
  2015-09-08 10:27   ` Mikael Magnusson
@ 2015-09-10 19:12   ` Daniel Shahaf
  1 sibling, 0 replies; 5+ messages in thread
From: Daniel Shahaf @ 2015-09-10 19:12 UTC (permalink / raw)
  To: zsh-workers

Peter Stephenson wrote on Tue, Sep 08, 2015 at 09:27:46 +0100:
> On Mon, 7 Sep 2015 21:22:11 +0000
> Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> > Since region_highlight overrides zle_highlight[paste], as a widget
> > writer I'd like to know what part of $BUFFER is being paste-highlighted,
> > in order to avoid setting region_highlight entries for it.
> > 
> > Does this seem reasonable?  
> 
> It's not much code, so if this is useful in practice, I'd say yes.

It is: zsh-syntax-highlighting needs to know what byte range in BUFFER
is being paste-highlighted in order to avoid overriding that.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-09-10 19:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-07 21:22 region_highlight and zle_highlight[paste] Daniel Shahaf
2015-09-08  8:27 ` Peter Stephenson
2015-09-08 10:27   ` Mikael Magnusson
2015-09-08 10:41     ` Peter Stephenson
2015-09-10 19:12   ` Daniel Shahaf

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).