Skip to content

Commit

Permalink
released 3.11.1
Browse files Browse the repository at this point in the history
Smarter interactive navigation in the TUI when option --tree is used with options -l or -c, enabling the navigation keys CTRL-S (jump forward), CTRL-W jump backward), TAB (chdir into directory and save query state), SHIFT-TAB (chdir .. and restore query state), CTRL-Y (view file).
  • Loading branch information
genivia-inc committed Apr 2, 2023
1 parent 55a9246 commit 5a2c183
Show file tree
Hide file tree
Showing 11 changed files with 289 additions and 206 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1886,17 +1886,17 @@ Same as `sed -n '/begin/,/end/p'`: to match all lines between a line containing
Output NUM lines of trailing context after matching lines. Places
a --group-separator between contiguous groups of matches. If -o is
specified, output the match with context to fit NUM columns after
the match or shortening the match. See also options -B, -C and -y.
the match or shortens the match. See also options -B, -C and -y.
-B NUM, --before-context=NUM
Output NUM lines of leading context before matching lines. Places
a --group-separator between contiguous groups of matches. If -o is
specified, output the match with context to fit NUM columns before
the match or shortening the match. See also options -A, -C and -y.
the match or shortens the match. See also options -A, -C and -y.
-C NUM, --context=NUM
Output NUM lines of leading and trailing context surrounding each
matching line. Places a --group-separator between contiguous
groups of matches. If -o is specified, output the match with
context to fit NUM columns before and after the match or shortening
context to fit NUM columns before and after the match or shortens
the match. See also options -A, -B and -y.
-y, --any-line
Any line is output (passthru). Non-matching lines are output as
Expand Down Expand Up @@ -3916,7 +3916,7 @@ in markdown:
Output NUM lines of trailing context after matching lines. Places
a --group-separator between contiguous groups of matches. If -o
is specified, output the match with context to fit NUM columns
after the match or shortening the match. See also options -B, -C
after the match or shortens the match. See also options -B, -C
and -y.

-a, --text
Expand All @@ -3942,7 +3942,7 @@ in markdown:
Output NUM lines of leading context before matching lines. Places
a --group-separator between contiguous groups of matches. If -o
is specified, output the match with context to fit NUM columns
before the match or shortening the match. See also options -A, -C
before the match or shortens the match. See also options -A, -C
and -y.

-b, --byte-offset
Expand Down Expand Up @@ -3998,8 +3998,8 @@ in markdown:
Output NUM lines of leading and trailing context surrounding each
matching line. Places a --group-separator between contiguous
groups of matches. If -o is specified, output the match with
context to fit NUM columns before and after the match or
shortening the match. See also options -A, -B and -y.
context to fit NUM columns before and after the match or shortens
the match. See also options -A, -B and -y.

-c, --count
Only a count of selected lines is written to standard output. If
Expand Down Expand Up @@ -4515,7 +4515,8 @@ in markdown:
--separator[=SEP]
Use SEP as field separator between file name, line number, column
number, byte offset and the matched line. The default is a colon
(`:').
(`:'), a plus (`+') for additional matches on the same line, and a
bar (`|') for multi-line pattern matches.

--sort[=KEY]
Displays matching files in the order specified by KEY in recursive
Expand Down Expand Up @@ -5258,7 +5259,7 @@ in markdown:



ugrep 3.11.0 March 18, 2023 UGREP(1)
ugrep 3.11.1 April 2, 2023 UGREP(1)

🔝 [Back to table of contents](#toc)

Expand Down
Binary file modified bin/win32/ugrep.exe
Binary file not shown.
Binary file modified bin/win64/ugrep.exe
Binary file not shown.
11 changes: 6 additions & 5 deletions man/ugrep.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH UGREP "1" "March 18, 2023" "ugrep 3.11.0" "User Commands"
.TH UGREP "1" "April 02, 2023" "ugrep 3.11.1" "User Commands"
.SH NAME
\fBugrep\fR, \fBug\fR -- file pattern searcher
.SH SYNOPSIS
Expand Down Expand Up @@ -58,7 +58,7 @@ The following options are available:
Output NUM lines of trailing context after matching lines. Places
a \fB\-\-group\-separator\fR between contiguous groups of matches. If \fB\-o\fR is
specified, output the match with context to fit NUM columns after
the match or shortening the match. See also options \fB\-B\fR, \fB\-C\fR and \fB\-y\fR.
the match or shortens the match. See also options \fB\-B\fR, \fB\-C\fR and \fB\-y\fR.
.TP
\fB\-a\fR, \fB\-\-text\fR
Process a binary file as if it were text. This is equivalent to
Expand All @@ -83,7 +83,7 @@ Combines \fB\-\-and\fR \fB\-\-not\fR. See also options \fB\-\-and\fR, \fB\-\-no
Output NUM lines of leading context before matching lines. Places
a \fB\-\-group\-separator\fR between contiguous groups of matches. If \fB\-o\fR is
specified, output the match with context to fit NUM columns before
the match or shortening the match. See also options \fB\-A\fR, \fB\-C\fR and \fB\-y\fR.
the match or shortens the match. See also options \fB\-A\fR, \fB\-C\fR and \fB\-y\fR.
.TP
\fB\-b\fR, \fB\-\-byte\-offset\fR
The offset in bytes of a matched line is displayed in front of the
Expand Down Expand Up @@ -136,7 +136,7 @@ terminal.
Output NUM lines of leading and trailing context surrounding each
matching line. Places a \fB\-\-group\-separator\fR between contiguous
groups of matches. If \fB\-o\fR is specified, output the match with
context to fit NUM columns before and after the match or shortening
context to fit NUM columns before and after the match or shortens
the match. See also options \fB\-A\fR, \fB\-B\fR and \fB\-y\fR.
.TP
\fB\-c\fR, \fB\-\-count\fR
Expand Down Expand Up @@ -643,7 +643,8 @@ a `\-', write the configuration to standard output.
\fB\-\-separator\fR[=\fISEP\fR]
Use SEP as field separator between file name, line number, column
number, byte offset and the matched line. The default is a colon
(`:').
(`:'), a plus (`+') for additional matches on the same line, and a
bar (`|') for multi\-line pattern matches.
.TP
\fB\-\-sort\fR[=\fIKEY\fR]
Displays matching files in the order specified by KEY in recursive
Expand Down
3 changes: 3 additions & 0 deletions src/flag.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ extern const char *flag_pager;
extern const char *flag_replace;
extern const char *flag_save_config;
extern const char *flag_separator;
extern const char *flag_separator_dash;
extern const char *flag_separator_plus;
extern const char *flag_separator_bar;
extern const char *flag_sort;
extern const char *flag_stats;
extern const char *flag_tag;
Expand Down
46 changes: 34 additions & 12 deletions src/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@file output.cpp
@brief Output management
@author Robert van Engelen - engelen@genivia.com
@copyright (c) 2019-2022, Robert van Engelen, Genivia Inc. All rights reserved.
@copyright (c) 2019-2023, Robert van Engelen, Genivia Inc. All rights reserved.
@copyright (c) BSD-3 License - see LICENSE.txt
*/

Expand Down Expand Up @@ -224,7 +224,7 @@ void Output::header(const char *& pathname, const std::string& partname, size_t
dump.done();

bool sep = false; // when a separator is needed
bool nul = false; // -Q: mark pathname with three NUL bytes unless -a
bool nul = false; // -Q: mark pathname with three \0 markers unless -a

if (flag_with_filename && pathname != NULL)
{
Expand Down Expand Up @@ -360,10 +360,10 @@ void Output::header(const char *& pathname, const std::string& partname, size_t
}
}

// output the pathname header for --files_with_matches and --count
// output the short pathname header for --files_with_matches and --count
void Output::header(const char *pathname, const std::string& partname)
{
bool nul = flag_query > 0; // -Q: mark pathname with three NUL bytes
bool nul = flag_query > 0; // -Q: mark pathname with three \0 markers for quick navigation

if (flag_tree)
{
Expand All @@ -377,6 +377,7 @@ void Output::header(const char *pathname, const std::string& partname)
Tree::path.pop_back();

size_t len = Tree::path.rfind(PATHSEPCHR);

if (len == std::string::npos)
Tree::path.clear();
else
Expand All @@ -390,38 +391,54 @@ void Output::header(const char *pathname, const std::string& partname)
{
for (int i = 0; i < Tree::depth; ++i)
str(Tree::bar);
while (--up > 0)
for (int i = 1; i < up; ++i)
str(Tree::end);
nl();

// make sure to add a break between trees with terminated leafs
if (up > 1 && *Tree::end != '\0' && Tree::depth == 0)
nl();
}
else if (Tree::path.empty() && strchr(pathname, PATHSEPCHR) != NULL)
{
// add a break between the list of filenames without path and filenames with paths
nl();
}

const char *sep;

while ((sep = strchr(pathname + Tree::path.size(), PATHSEPCHR)) != NULL)
{
if (nul)
chr('\0');

for (int i = 1; i < Tree::depth; ++i)
str(Tree::bar);

if (Tree::depth > 0)
str(Tree::ptr);
else if (nul)
str("\0\0", 2);

if (nul)
chr('\0');

str(pathname + Tree::path.size(), sep - (pathname + Tree::path.size()) + 1);

if (nul && Tree::depth == 0)
if (nul)
chr('\0');
nl();

Tree::path.assign(pathname, sep - pathname + 1);
++Tree::depth;
}

if (nul)
chr('\0');

for (int i = 1; i < Tree::depth; ++i)
str(Tree::bar);

if (Tree::depth > 0)
str(Tree::ptr);
else if (nul)
chr('\0');

str(color_fn);

Expand All @@ -433,12 +450,12 @@ void Output::header(const char *pathname, const std::string& partname)
str(color_st);
}

if (nul && Tree::depth == 0)
if (nul)
chr('\0');

str(pathname + Tree::path.size());

if (nul && Tree::depth == 0)
if (nul)
chr('\0');

}
Expand Down Expand Up @@ -488,9 +505,11 @@ void Output::binary_file_matches(const char *pathname, const std::string& partna
{
if ((mode_ & BINARY) != 0)
return;

str(color_off);
str("Binary file");
str(color_fn);

if (pathname != NULL)
{
chr(' ');
Expand All @@ -508,6 +527,7 @@ void Output::binary_file_matches(const char *pathname, const std::string& partna
str(color_st);
}
}

if (!partname.empty())
{
if (pathname == NULL)
Expand All @@ -516,9 +536,11 @@ void Output::binary_file_matches(const char *pathname, const std::string& partna
str(partname);
chr('}');
}

str(color_off);
str(" matches");
nl();

mode_ |= BINARY;
}

Expand Down
2 changes: 1 addition & 1 deletion src/output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@file output.hpp
@brief Output management
@author Robert van Engelen - engelen@genivia.com
@copyright (c) 2019-2022, Robert van Engelen, Genivia Inc. All rights reserved.
@copyright (c) 2019-2023, Robert van Engelen, Genivia Inc. All rights reserved.
@copyright (c) BSD-3 License - see LICENSE.txt
*/

Expand Down
Loading

0 comments on commit 5a2c183

Please sign in to comment.