Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Pasting UTF-8 characters with bracketed-paste-magic seems broken in 5.1



On Sep 10,  5:28pm, Peter Stephenson wrote:
} Subject: Re: Pasting UTF-8 characters with bracketed-paste-magic seems bro
}
} On Thu, 10 Sep 2015 09:16:49 -0700
} Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
} 
} > Should be possible to handle that in the loop in bracketed-paste-magic
} > with a test of $KEYS and a call to read -k.  Might try to get to this
} > later, out of time now ... or someone else can jump in.
} 
} Not really clear to me what level the "right" fix is, since this was all
} designed for a pre-multibyte world... I don't think we have a test for a
} valid/invalid multibyte character at the shell level currently, do we?

We can probably get by with some variant of this:

    read-multibyte() {
	local K=$KEYS[-1]
	if (( ##K & 0x80 )); then
	    if (( ##K & 0xe0 == 0xc0 )); then
		read -k 1 K
	    elif (( ##K & 0xf0 == 0xe0 )); then
		read -k 2 K
	    elif (( ##K & 0xf8 == 0xf0 )); then
		read -k 3 K
	    fi
	    KEYS+="$K"
	fi
    }

    while zle .read-command; do
	read-multibyte
	# etc.
    done

Except "read -k" is supposed to read a full multibyte character, so I
don't know if it behaves consistently when invoked in the middle of one.

-- 
Barton E. Schaefer



Messages sorted by: Reverse Date, Date, Thread, Author