From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14090 invoked by alias); 18 Dec 2013 18:44:00 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 32153 Received: (qmail 4379 invoked from network); 18 Dec 2013 18:43:55 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 From: Bart Schaefer Message-id: <131218104353.ZM23017@torch.brasslantern.com> Date: Wed, 18 Dec 2013 10:43:53 -0800 In-reply-to: <20131218173853.54435025@pwslap01u.europe.root.pri> Comments: In reply to Peter Stephenson "Re: Simulating ZLE_RPROMPT_INDENT=0" (Dec 18, 5:38pm) References: <131217224337.ZM20989@torch.brasslantern.com> <20131218092738.0dbc94a1@pwslap01u.europe.root.pri> <131218092611.ZM22367@torch.brasslantern.com> <20131218173853.54435025@pwslap01u.europe.root.pri> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: Simulating ZLE_RPROMPT_INDENT=0 MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Dec 18, 5:38pm, Peter Stephenson wrote: } Subject: Re: Simulating ZLE_RPROMPT_INDENT=0 } } On Wed, 18 Dec 2013 09:26:11 -0800 } Bart Schaefer wrote: } > Is it OK to declare ZLE_RPROMPT_INDENT in params.c or should it go in a } > Zle/*.c file? } } It doesn't need to be declared at all; it doesn't need to be special. It does need to be declared if it's going to be "handled like LINES / COLUMNS" as I mentioned in my previous message on this thread. There needs to be a global integer attached to the value so that it doesn't have to be read with getvalue() on every call to moveto(). } It just needs to be read and the value used if it happens to be set. } There are plenty of other variables like this. Yes, but those others aren't referenced for every keystroke typed into the line editor. } > In the event that the terminal has no non-destructive move-left sequence, } > should assigning ZLE_RPROMPT_INDENT=0 print a warning? Should it also } > (or instead) ignore the value and revert to 1 in that case? } } Would make more to have another more programmatically useful way of } testing this if we need to, e.g. with echotc or echoti. I'm not sure what you mean by this. Do you mean e.g. to just document how a shell script would perform the test? Here's what I had so far which does not include changing moveto() yet. --- a/Src/Zle/zle_refresh.c +++ b/Src/Zle/zle_refresh.c @@ -977,7 +977,7 @@ zrefresh(void) int tmpalloced; /* flag to free tmpline when finished */ int remetafy; /* flag that zle line is metafied */ int txtchange; /* attributes set after prompts */ - int rprompt_off = 1; /* Offset of rprompt from right of screen */ + int rprompt_off; /* Offset of rprompt from right of screen */ struct rparams rpms; #ifdef MULTIBYTE_SUPPORT int width; /* width of wide character */ @@ -1579,16 +1579,12 @@ zrefresh(void) !strchr(rpromptbuf, '\t'); if (put_rpmpt) { - struct value vbuf; - char *name = "ZLE_RPROMPT_INDENT"; - if (getvalue(&vbuf, &name, 1)) { - rprompt_off = (int)getintvalue(&vbuf); - /* sanity to avoid horrible things happening */ - if (rprompt_off < 0) - rprompt_off = 0; - } - put_rpmpt = - (int)ZR_strlen(nbuf[0]) + rpromptw < winw - rprompt_off; + rprompt_off = rprompt_indent; + /* sanity to avoid horrible things happening */ + if (rprompt_off < 0) + rprompt_off = 0; + put_rpmpt = + (int)ZR_strlen(nbuf[0]) + rpromptw < winw - rprompt_off; } } } else { --- a/Src/init.c +++ b/Src/init.c @@ -999,6 +999,15 @@ setupvals(void) setiparam("COLUMNS", zterm_columns); setiparam("LINES", zterm_lines); #endif + { + /* handle inherit from environment */ + struct value vbuf; + char *name = "ZLE_RPROMPT_INDENT"; + if (getvalue(&vbuf, &name, 1) && !(vbuf.flags & PM_UNSET)) + rprompt_indent = getintvalue(&vbuf); + else + rprompt_indent = 1; + } #ifdef HAVE_GETRLIMIT for (i = 0; i != RLIM_NLIMITS; i++) { --- a/Src/params.c +++ b/Src/params.c @@ -97,6 +97,7 @@ zlong lastval, /* $? */ lastpid, /* $! */ zterm_columns, /* $COLUMNS */ zterm_lines, /* $LINES */ + rprompt_indent, /* $ZLE_RPROMPT_INDENT */ ppid, /* $PPID */ zsh_subshell; /* $ZSH_SUBSHELL */ /**/ @@ -316,8 +317,10 @@ IPDEF4("PPID", &ppid), IPDEF4("ZSH_SUBSHELL", &zsh_subshell), #define IPDEF5(A,B,F) {{NULL,A,PM_INTEGER|PM_SPECIAL},BR((void *)B),GSU(F),10,0,NULL,NULL,NULL,0} +#define IPDEF5U(A,B,F) {{NULL,A,PM_INTEGER|PM_SPECIAL|PM_UNSET},BR((void *)B),GSU(F),10,0,NULL,NULL,NULL,0} IPDEF5("COLUMNS", &zterm_columns, zlevar_gsu), IPDEF5("LINES", &zterm_lines, zlevar_gsu), +IPDEF5U("ZLE_RPROMPT_INDENT", &rprompt_indent, zlevar_gsu), IPDEF5("OPTIND", &zoptind, varinteger_gsu), IPDEF5("SHLVL", &shlvl, varinteger_gsu), IPDEF5("TRY_BLOCK_ERROR", &try_errflag, varinteger_gsu),