Skip to content

Commit 465d9be

Browse files
authored
Merge branch 'console-rs:master' into master
2 parents 0fb376f + 5484ea9 commit 465d9be

File tree

8 files changed

+511
-74
lines changed

8 files changed

+511
-74
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,34 @@ on:
55
pull_request:
66
branches: [master]
77
jobs:
8+
build-msrv:
9+
name: Build on MSRV (1.40)
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
include:
14+
- os: ubuntu-latest
15+
target: x86_64-unknown-linux-gnu
16+
rust: 1.40.0
17+
- os: windows-latest
18+
target: i686-pc-windows-msvc
19+
rust: 1.40.0
20+
runs-on: ${{ matrix.os }}
21+
steps:
22+
- name: Install rust
23+
uses: actions-rs/toolchain@v1
24+
with:
25+
profile: minimal
26+
toolchain: ${{ matrix.rust }}
27+
target: ${{ matrix.target }}
28+
override: true
29+
- name: Checkout
30+
uses: actions/checkout@v2
31+
- name: Build
32+
uses: actions-rs/cargo@v1
33+
with:
34+
command: check
35+
args: --target ${{ matrix.target }}
836
test:
937
name: Tests
1038
strategy:
@@ -13,19 +41,19 @@ jobs:
1341
include:
1442
- os: macos-latest
1543
target: x86_64-apple-darwin
16-
rust: 1.40.0
44+
rust: 1.51.0
1745
- os: ubuntu-latest
1846
target: x86_64-unknown-linux-gnu
19-
rust: 1.40.0
47+
rust: 1.51.0
2048
- os: ubuntu-latest
2149
target: i686-unknown-linux-gnu
22-
rust: 1.40.0
50+
rust: 1.51.0
2351
- os: windows-latest
2452
target: i686-pc-windows-msvc
25-
rust: 1.40.0
53+
rust: 1.51.0
2654
- os: windows-latest
2755
target: x86_64-pc-windows-msvc
28-
rust: 1.40.0
56+
rust: 1.51.0
2957
- os: ubuntu-latest
3058
target: x86_64-unknown-linux-gnu
3159
rust: stable
@@ -70,7 +98,7 @@ jobs:
7098
uses: actions-rs/toolchain@v1
7199
with:
72100
profile: minimal
73-
toolchain: 1.40.0
101+
toolchain: 1.51.0
74102
target: ${{ matrix.target }}
75103
override: true
76104
- name: Checkout

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Enhancements
6+
7+
* ANSI support no longer depends on `regex` crate.
8+
59
## 0.15.0
610

711
### Enhancements

Cargo.toml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ readme = "README.md"
1313

1414
[features]
1515
default = ["unicode-width", "ansi-parsing"]
16-
windows-console-colors = ["ansi-parsing", "winapi-util"]
17-
ansi-parsing = ["regex"]
16+
windows-console-colors = ["ansi-parsing", "regex", "winapi-util"]
17+
ansi-parsing = []
1818

1919
[dependencies]
2020
once_cell = "1"
@@ -27,3 +27,12 @@ unicode-width = { version = "0.1", optional = true }
2727
winapi = { version = "0.3", features = ["winbase", "winuser", "consoleapi", "processenv", "wincon"] }
2828
winapi-util = { version = "0.1.3", optional = true }
2929
encode_unicode = "0.3"
30+
31+
[dev-dependencies]
32+
criterion = "0.3.5"
33+
proptest = "1.0.0"
34+
regex = "1.4.2"
35+
36+
[[bench]]
37+
name = "ansi_parser"
38+
harness = false

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# `console`
22

3+
[![Build Status](https://github.com/mitsuhiko/console/workflows/CI/badge.svg?branch=master)](https://github.com/mitsuhiko/console/actions?query=workflow%3ACI)
4+
[![Crates.io](https://img.shields.io/crates/d/console.svg)](https://crates.io/crates/console)
5+
[![License](https://img.shields.io/github/license/mitsuhiko/console)](https://github.com/mitsuhiko/console/blob/master/LICENSE)
6+
[![rustc 1.40.0](https://img.shields.io/badge/rust-1.40%2B-orange.svg)](https://img.shields.io/badge/rust-1.40%2B-orange.svg)
7+
[![Documentation](https://docs.rs/console/badge.svg)](https://docs.rs/console)
8+
39
**console** is a library for Rust that provides access to various terminal
410
features so you can build nicer looking command line interfaces. It
511
comes with various tools and utilities for working with Terminals and

benches/ansi_parser.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use console::{strip_ansi_codes, AnsiCodeIterator};
2+
use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput};
3+
4+
use std::{fs, path::Path};
5+
6+
pub fn parse_throughput(c: &mut Criterion) {
7+
let session_log_path = Path::new("tests")
8+
.join("data")
9+
.join("sample_zellij_session.log");
10+
let session_log = fs::read_to_string(session_log_path).unwrap();
11+
12+
let mut group = c.benchmark_group("ansi-parsing");
13+
group.throughput(Throughput::Bytes(session_log.len() as u64));
14+
group.bench_function("parse", |b| {
15+
b.iter(|| {
16+
let v: Vec<_> = AnsiCodeIterator::new(&session_log).collect();
17+
black_box(v);
18+
})
19+
});
20+
group.bench_function("strip", |b| {
21+
b.iter(|| black_box(strip_ansi_codes(&session_log)))
22+
});
23+
group.finish();
24+
}
25+
26+
criterion_group!(throughput, parse_throughput);
27+
criterion_main!(throughput);

0 commit comments

Comments
 (0)