From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Discovered pattern that ideally parses any quoting. Brackets highlighting in FSH.
Date: Mon, 30 Jul 2018 09:09:02 +0200 [thread overview]
Message-ID: <CAKc7PVAbwaZr6Pr8weACs7W7E1A6GF5y7QpwRanssYFdGnzSww@mail.gmail.com> (raw)
Hello,
not only (z) can handle quoting, turns out regular pattern with while
loop can do it too:
while [[ $_mybuf = (#b)[^"{}()[]\\\"'"]#((["({[]})\"'"])|[\\](*))(*) ]]; do
[[ -n "${match[3]}" ]] && {
__idx+=${mbegin[1]}+1
_mybuf="${match[3]:1}" # also skip 1 quoted char
} || {
the main point is [\\](*). Parentheses are placed in ${match[3]} and
allow to restart processing skipping e.g. a quoted backslash.
The rest is matching braces – it's an example from
Fast-Syntax-Highlighting, it now has ideal brackets highlighting – AND
ALSO ", '. Simple handling of those two quotings allows to switch mode
"in quoting" "outside quoting". That's all. The effect:
https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/brackets.gif
--
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
next reply other threads:[~2018-07-30 7:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-30 7:09 Sebastian Gniazdowski [this message]
2018-07-31 4:16 ` Sebastian Gniazdowski
2018-07-31 5:13 ` Sebastian Gniazdowski
2018-08-01 18:18 ` Bart Schaefer
2018-08-02 7:32 ` Sebastian Gniazdowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKc7PVAbwaZr6Pr8weACs7W7E1A6GF5y7QpwRanssYFdGnzSww@mail.gmail.com \
--to=sgniazdowski@gmail.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).