Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nu-ansi-term overhaul #53

Closed
wants to merge 62 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
a14625d
Creating macros as replacement for write! that are AnyWrite aware. This
Oct 4, 2023
f960695
Fix a minor warning that has an auto-fix, in an example.
Oct 4, 2023
04d54de
Content is now working.
Oct 4, 2023
d0629c5
Content is now working
Oct 4, 2023
ceabbca
Rename Content to Writeable; making some attempts to allow String to …
Oct 4, 2023
006aa10
Use WriteResult to clean up noise.
Oct 4, 2023
c55405b
Issues with plurals not being able to accept multiple types as per their
Oct 4, 2023
6c7f33b
Everything finally compiles.
Oct 5, 2023
132014c
All tests pass, except for unimplemented ones that use plural functio…
Oct 5, 2023
9f5cd78
Implemented new incremental update of styles.
Oct 5, 2023
99e4b7e
Updated tests in difference.rs
Oct 5, 2023
8550239
Undo changes done by mistake to selected ranges of write.rs
Oct 5, 2023
984e444
More fixes.
Oct 5, 2023
dbdd0c7
Plural strings implemented.
Oct 5, 2023
8d044dd
Addressing test fails.
Oct 5, 2023
515bac1
Trying to figure out why reset is not being printed correctly.
Oct 6, 2023
1ca0931
Using bitflags for Style
Oct 6, 2023
bfab51f
Re-implemented tests.
Oct 7, 2023
2b4dfe3
All non-doc tests are passing.
Oct 8, 2023
af866e5
All tests (including doc tests) for not(gnu_legacy) are passing.
Oct 9, 2023
9b0bdc5
All gnu_legacy tests are also passing now.
Oct 9, 2023
baa2da6
Write documentation.
Oct 9, 2023
7b29684
Remove unnecssary content_from! macro, which is not needed because we…
Oct 9, 2023
9b2b298
Don't use bitflags for prefix_with_reset and coloring.
Oct 9, 2023
2d9358f
Allowing AnsiGenericStrings to use Cow in order to mitigate cloning c…
Oct 9, 2023
091871a
making some progress on lifetimes
Oct 9, 2023
5f43162
lifetimes work now
Oct 9, 2023
1562a75
Change AnsiGenericStrings so that it just holds AnsiGenericString ins…
Oct 9, 2023
9334e60
wip
Oct 9, 2023
ddadb46
Allow updating of styles.
Oct 10, 2023
b62a2f4
Looks like a proc_macro is needed to create the ansi_generics! macro.
Oct 10, 2023
eaaeef7
Initializing creation of ansi_generics_macro.
Oct 10, 2023
c523ca6
Deconstructing InputStringKind
Oct 10, 2023
013e036
Removed places where is_string_literal showed up, because we want those
Oct 10, 2023
ca9249e
Remove `snippet` because it is related to the code we just deleted.
Oct 10, 2023
9f62d32
Removed ParseMode; only interested in format not inline_asm.
Oct 10, 2023
76ce23a
Remove `style` because of hypothesis: we will not be dealing with raw…
Oct 10, 2023
95cbe6d
We can now extract named arguments from a format literal string.
Oct 10, 2023
468e0ab
Getting the explicit arguments in order.
Oct 10, 2023
7d3637c
Correctly removing items from inline_named_args, instead of filtering…
Oct 10, 2023
35ad77c
Functionality for matching explicit arguments discovered in macro inp…
Oct 11, 2023
65dd0e9
ANSI generic macro is complete.
Oct 11, 2023
83764af
Format args macro seems to work.
Oct 11, 2023
83d1eb6
Playing around with structure of AnsiGenericFmtArgs.
Oct 11, 2023
aab52ca
By-passing the object cloning restriction by creating a method which …
Oct 12, 2023
213a5ee
Sort of working, good enough for now.
Oct 12, 2023
40e1fe1
Working fully.
Oct 12, 2023
1173edb
rename macro to ansi_format
Oct 12, 2023
e5a4d9b
More docs.
Oct 12, 2023
2f908e8
Test fixes.
Oct 12, 2023
f184b9e
Remove functionality that allows nesting of styled format_arg-likes.
Oct 12, 2023
e821103
Rename the color based foreground/background functions
Oct 12, 2023
fe478b3
More renaming back to original-ish.
Oct 12, 2023
72fa2ae
Rename prefix_with_reset back to reset_before_style
Oct 12, 2023
954a860
Color's fg method was actually called 'normal' in the past
Oct 12, 2023
3c40068
hidden occurrences of prefix_with_reset --- some of these renamings a…
Oct 12, 2023
60c0731
gradient related rename to original
Oct 12, 2023
4dac9d7
remove nested strings example
Oct 12, 2023
d9e43fc
re-adding utils.rs
Oct 12, 2023
ce84b30
more changes to match the original, some docs as well
Oct 12, 2023
a4dbb5f
more changes to match the original, this time to do with write functi…
Oct 12, 2023
d29ecb1
make lots of functions const that weren't before; it is also technica…
Oct 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ derive_serde_style = ["serde"]
gnu_legacy = []

[dependencies]
bitflags = "2.4.0"
itertools = "0.11.0"
paste = "1.0.14"
serde = { version="1.0.152", features=["derive"], optional=true }

[target.'cfg(windows)'.dependencies.windows]
Expand Down
2 changes: 1 addition & 1 deletion examples/256_colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ fn main() {
fn glow(c: u8, light_bg: bool) {
let base = if light_bg { Color::Black } else { Color::White };
let style = base.on(Color::Fixed(c));
print!("{}", style.paint(&format!(" {:3} ", c)));
print!("{}", style.paint(format_args!(" {:3} ", c)));
}
12 changes: 12 additions & 0 deletions examples/format_args.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use nu_ansi_term::{Color, Style};

fn main() {
let yes = Color::Yellow.normal().bold().paint("yes!");
let exclamation = Color::Yellow.bg().fg(Color::Black).italic().paint("true!");
println!(
"{} {} {}",
Style::new().italic().underline().paint("hello"),
Color::Cyan.paint("world!"),
format_args!("{yes} it's {exclamation}")
);
}
2 changes: 1 addition & 1 deletion examples/hyperlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn main() {
let link = Color::Blue
.underline()
.paint("Link to example.com")
.hyperlink("https://example.com");
.hyperlink_content("https://example.com");

println!("{}", link);
sleep(sleep_ms);
Expand Down
4 changes: 2 additions & 2 deletions examples/may_sleep/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ pub fn parse_cmd_args() -> Option<u16> {
.unwrap_or(String::from("5000u16"))
.parse::<u16>()
.ok()
.and_then(|parsed| {
.map(|parsed| {
skip_next = true;
Some(parsed)
parsed
});
}
_ => {}
Expand Down
Loading