mirror of
https://github.com/sharkdp/bat
synced 2026-07-24 17:13:19 +00:00
Merge branch 'master' into makefile-syntax-for-justfiles
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
# On Windows MSVC, statically link the C runtime so that the resulting EXE does
|
||||
# not depend on the vcruntime DLL.
|
||||
#
|
||||
# See: https://github.com/sharkdp/bat/issues/3634
|
||||
|
||||
[target.x86_64-pc-windows-msvc]
|
||||
rustflags = ["-C", "target-feature=+crt-static"]
|
||||
[target.i686-pc-windows-msvc]
|
||||
rustflags = ["-C", "target-feature=+crt-static"]
|
||||
[target.aarch64-pc-windows-msvc]
|
||||
rustflags = ["-C", "target-feature=+crt-static"]
|
||||
@@ -161,12 +161,12 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
job:
|
||||
- { target: aarch64-unknown-linux-musl , os: ubuntu-latest , dpkg_arch: arm64, use-cross: true }
|
||||
- { target: aarch64-unknown-linux-musl , os: ubuntu-latest , dpkg_arch: musl-linux-arm64, use-cross: true }
|
||||
- { target: aarch64-unknown-linux-gnu , os: ubuntu-latest , dpkg_arch: arm64, use-cross: true }
|
||||
- { target: arm-unknown-linux-gnueabihf , os: ubuntu-latest , dpkg_arch: armhf, use-cross: true }
|
||||
- { target: arm-unknown-linux-musleabihf, os: ubuntu-latest , dpkg_arch: musl-linux-armhf, use-cross: true }
|
||||
- { target: i686-pc-windows-msvc , os: windows-2025 , }
|
||||
- { target: i686-unknown-linux-gnu , os: ubuntu-latest , dpkg_arch: i686, use-cross: true }
|
||||
- { target: i686-unknown-linux-gnu , os: ubuntu-latest , dpkg_arch: i386, use-cross: true }
|
||||
- { target: i686-unknown-linux-musl , os: ubuntu-latest , dpkg_arch: musl-linux-i686, use-cross: true }
|
||||
- { target: x86_64-apple-darwin , os: macos-15-intel, }
|
||||
- { target: aarch64-apple-darwin , os: macos-latest , }
|
||||
@@ -195,9 +195,7 @@ jobs:
|
||||
|
||||
- name: Install cross
|
||||
if: matrix.job.use-cross
|
||||
uses: taiki-e/install-action@v2
|
||||
with:
|
||||
tool: cross
|
||||
run: cargo install cross --git https://github.com/cross-rs/cross --rev 588b3c99db52b5a9c5906fab96cfadcf1bde7863
|
||||
|
||||
- name: Overwrite build command env variable
|
||||
if: matrix.job.use-cross
|
||||
@@ -335,7 +333,7 @@ jobs:
|
||||
|
||||
DPKG_BASENAME=${{ needs.crate_metadata.outputs.name }}
|
||||
DPKG_CONFLICTS=${{ needs.crate_metadata.outputs.name }}-musl
|
||||
case ${{ matrix.job.target }} in *-musl) DPKG_BASENAME=${{ needs.crate_metadata.outputs.name }}-musl ; DPKG_CONFLICTS=${{ needs.crate_metadata.outputs.name }} ;; esac;
|
||||
case ${{ matrix.job.target }} in *-musl*) DPKG_BASENAME=${{ needs.crate_metadata.outputs.name }}-musl ; DPKG_CONFLICTS=${{ needs.crate_metadata.outputs.name }} ;; esac;
|
||||
DPKG_VERSION=${{ needs.crate_metadata.outputs.version }}
|
||||
DPKG_ARCH="${{ matrix.job.dpkg_arch }}"
|
||||
DPKG_NAME="${DPKG_BASENAME}_${DPKG_VERSION}_${DPKG_ARCH}.deb"
|
||||
|
||||
+6
-3
@@ -49,9 +49,6 @@
|
||||
[submodule "assets/themes/zenburn"]
|
||||
path = assets/themes/zenburn
|
||||
url = https://github.com/colinta/zenburn.git
|
||||
[submodule "assets/syntaxes/Kotlin"]
|
||||
path = assets/syntaxes/02_Extra/Kotlin
|
||||
url = https://github.com/vkostyukov/kotlin-sublime-package
|
||||
[submodule "assets/syntaxes/Elm"]
|
||||
path = assets/syntaxes/02_Extra/Elm
|
||||
url = https://github.com/elm-community/SublimeElmLanguageSupport
|
||||
@@ -278,3 +275,9 @@
|
||||
[submodule "assets/syntaxes/02_Extra/Gomod"]
|
||||
path = assets/syntaxes/02_Extra/Gomod
|
||||
url = https://github.com/mitranim/sublime-gomod
|
||||
[submodule "assets/syntaxes/02_Extra/COBOL"]
|
||||
path = assets/syntaxes/02_Extra/COBOL
|
||||
url = https://github.com/adukhan99/sublime_cobol.git
|
||||
[submodule "assets/syntaxes/02_Extra/Kotlin"]
|
||||
path = assets/syntaxes/02_Extra/Kotlin
|
||||
url = https://github.com/guille/sublime-kotlin
|
||||
|
||||
+27
-4
@@ -1,20 +1,32 @@
|
||||
# unreleased
|
||||
|
||||
- Fixed bug caused by using `--plain` and `--terminal-width=N` flags simultaneously, see #3529 (@H4k1l)
|
||||
- Fixed syntax tests path, see #3610 (@foxfromworld)
|
||||
|
||||
## Other
|
||||
|
||||
- Add instructions for removing fish help abbreviations to README, see #3655 (@claw-explorer). Closes #3536
|
||||
- Add .NET slnx extension, see #3682 (@ltrzesniewski)
|
||||
|
||||
## Features
|
||||
|
||||
- Map `justfile`, `Justfile`, `.justfile`, and `*.justfile` to Makefile syntax highlighting, see #XXXX (@zachvalenta)
|
||||
- Map justfile, Justfile, .justfile, and *.justfile to Makefile syntax highlighting, see #3623 (@zachvalenta)
|
||||
- Preserve `--diff` change markers and snip separators when `--plain` is set. Closes #3630, see #3643 (@mvanhorn)
|
||||
- Added support for `hidden_file_extensions` from `.sublime-syntax` files, see #3613 (@Matei02355)
|
||||
- Add word wrapping mode via `--wrap=word`, see #3597 (@veeceey)
|
||||
- Support configuring `--terminal-width` via `BAT_WIDTH`, see #3679 (@officialasishkumar)
|
||||
- Implement `--unbuffered` mode for streaming input, allowing partial lines to display immediately (e.g. `tail -f | bat -u`). Closes #3555, see #3583 (@mainnebula)
|
||||
- Added an initial `flake.nix` for a ready made development environment; see #3578 (@vorburger)
|
||||
- Add `--quiet-empty` (`-E`) flag to suppress output when input is empty. Closes #1936, see #3563 (@NORMAL-EX)
|
||||
- Improve native man pages and command help syntax highlighting by stripping overstriking, see #3517 (@akirk)
|
||||
- Add `--fallback-syntax`/`--fallback-language` to apply syntax highlighting only when auto-detection fails, see #1341 (@Xavrir)
|
||||
- Map `BUILD` case sensitively to Python (Starlark) for Bazel, see #3576 (@vorburger)
|
||||
- Syntax highlighting for Python files using uv as script runner in shebang #3689 (@janlarres)
|
||||
|
||||
## Bugfixes
|
||||
- Report initial input read errors instead of treating them as empty input. Closes #3002, see #3706 (@lawrence3699)
|
||||
- Treat ZIP archives as binary content based on their magic header, see #3686 (@officialasishkumar)
|
||||
- Fix i686 `.deb` package using incorrect architecture name (`i686` instead of `i386`), preventing installation on Debian. Closes #3611, see #3650 (@Sim-hu)
|
||||
- Fix inconsistent `.deb` MUSL package names (aarch64-musl used `arm64` instead of `musl-linux-arm64`, and `musleabihf` target missed `bat-musl` prefix). Closes #3482, see #3642 (@mvanhorn)
|
||||
- Fix incorrect text width computation when using `--binary=as-text` with non-printable characters in caret notation, see #3640 and #3631 (@eyupcanakman)
|
||||
- Fix `BAT_CONFIG_DIR` pointing at system config directory causing duplicate flag errors. Closes #3589, see #3620 (@Xavrir)
|
||||
- Fix syntax highlighting for symlinked files when the symlink name has no extension but the target does. Closes #1001, see #3621 (@Xavrir)
|
||||
- Report error when pager is missing instead of silently falling back, see #3588 (@IMaloney)
|
||||
@@ -24,16 +36,27 @@
|
||||
- `--help` now correctly honors `--pager=builtin`. See #3516 (@keith-hall)
|
||||
- `--help` now correctly honors custom themes. See #3524 (@keith-hall)
|
||||
- Fixed test compatibility with future Cargo build directory changes, see #3550 (@nmacl)
|
||||
- Fixed bug caused by using `--plain` and `--terminal-width=N` flags simultaneously, see #3529 (@H4k1l)
|
||||
- Fixed syntax tests path, see #3610 (@foxfromworld)
|
||||
- Fix zsh tab completion word-splitting language names containing spaces (e.g. `HTML (Jinja2)`, `Apache Conf`), see #3693 (@YoshKoz)
|
||||
|
||||
## Other
|
||||
|
||||
- Use git version of cross. See #3533 (@OctopusET)
|
||||
- Bump MSRV to 1.88, update `time` crate to 0.3.47 to fix RUSTSEC-2026-0009, see #3581 (@NORMAL-EX)
|
||||
- Allow home and end keys to be used with builtin pager, see #3651 (@keith-hall)
|
||||
- Builtin syntax mapping: cleanup matcher glob parsing logic #3652 (@cyqsimon)
|
||||
- Statically link the CRT for MSVC builds via Cargo config to avoid runtime DLL dependencies. Closes #3634, see #3692 (@barry3406)
|
||||
|
||||
## Syntaxes
|
||||
|
||||
- Add shebang-based detection for Tcl (`tclsh`, `wish`) and Expect (`expect`) scripts, see #3647 (@mvanhorn)
|
||||
- Change the URL of Zig submodule from GitHub to Codeberg, see #3519 (@sorairolake)
|
||||
- Don't color strings inside CSV files, to make it easier to tell which column they belong to, see #3521 (@keith-hall)
|
||||
- Add syntax highlighting support for COBOL, see #3584 (@adukhan99)
|
||||
- Fixed manpage syntax so that ANSI escape codes don't get incorrectly highlighted and thus broken, see #3586 (@BlueElectivire)
|
||||
- Map several Google Cloud CLI config files to their appropriate syntax #3635 (@victor-gp)
|
||||
- Map all ignore dotfiles to Git Ignore syntax #3636 (@victor-gp)
|
||||
- Improved Kotlin syntax, see #3699 (@guille)
|
||||
|
||||
## Themes
|
||||
|
||||
|
||||
@@ -68,6 +68,8 @@ users, please read the corresponding
|
||||
[documentation](https://github.com/sharkdp/bat/blob/master/doc/assets.md)
|
||||
first.
|
||||
|
||||
To map a file name pattern to an existing syntax, read [the documentation here](https://github.com/sharkdp/bat/blob/master/src/syntax_mapping/builtins/README.md).
|
||||
|
||||
Note: We are currently not accepting new default themes.
|
||||
|
||||
|
||||
|
||||
Generated
+26
-26
@@ -951,9 +951,9 @@ checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.11.0"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039"
|
||||
checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
|
||||
|
||||
[[package]]
|
||||
name = "litemap"
|
||||
@@ -1235,9 +1235,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.40"
|
||||
version = "1.0.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
||||
checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
@@ -1324,14 +1324,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "1.1.2"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e"
|
||||
checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys 0.11.0",
|
||||
"linux-raw-sys 0.12.1",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
@@ -1406,9 +1406,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_spanned"
|
||||
version = "1.0.3"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e24345aa0fe688594e73770a5f6d1b216508b4f93484c0026d521acd30134392"
|
||||
checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
]
|
||||
@@ -1603,14 +1603,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.23.0"
|
||||
version = "3.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16"
|
||||
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
|
||||
dependencies = [
|
||||
"fastrand",
|
||||
"getrandom",
|
||||
"once_cell",
|
||||
"rustix 1.1.2",
|
||||
"rustix 1.1.4",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
@@ -1757,9 +1757,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.9.8"
|
||||
version = "1.1.1+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0dc8b1fb61449e27716ec0e1bdf0f6b8f3e8f6b05391e8497b8b6d7804ea6d8"
|
||||
checksum = "994b95d9e7bae62b34bab0e2a4510b801fa466066a6a8b2b57361fa1eba068ee"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde_core",
|
||||
@@ -1772,27 +1772,27 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.7.3"
|
||||
version = "1.1.1+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2cdb639ebbc97961c51720f858597f7f24c4fc295327923af55b74c3c724533"
|
||||
checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_parser"
|
||||
version = "1.0.4"
|
||||
version = "1.1.1+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0cbe268d35bdb4bb5a56a2de88d0ad0eb70af5384a99d648cd4b3d04039800e"
|
||||
checksum = "39ca317ebc49f06bd748bfba29533eac9485569dc9bf80b849024b025e814fb9"
|
||||
dependencies = [
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_writer"
|
||||
version = "1.0.4"
|
||||
version = "1.1.1+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df8b2b54733674ad286d16267dcfc7a71ed5c776e4ac7aa3c3e2561f7c637bf2"
|
||||
checksum = "756daf9b1013ebe47a8776667b466417e2d4c5679d441c26230efd9ef78692db"
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
@@ -1808,15 +1808,15 @@ checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.12.0"
|
||||
version = "1.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
|
||||
checksum = "9629274872b2bfaf8d66f5f15725007f635594914870f65218920345aa11aa8c"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a1a07cc7db3810833284e8d372ccdc6da29741639ecc70c9ec107df0fa6154c"
|
||||
checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"
|
||||
|
||||
[[package]]
|
||||
name = "unsafe-libyaml"
|
||||
@@ -2186,9 +2186,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.7.14"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829"
|
||||
checksum = "09dac053f1cd375980747450bfc7250c264eaae0583872e845c0c7cd578872b5"
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-rt"
|
||||
|
||||
+5
-5
@@ -56,7 +56,7 @@ minus = { version = "5.6", optional = true, features = [
|
||||
"dynamic_output",
|
||||
"search",
|
||||
] }
|
||||
unicode-width = "0.2.1"
|
||||
unicode-width = "0.2.2"
|
||||
globset = "0.4"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
@@ -73,7 +73,7 @@ bytesize = { version = "2.3.1" }
|
||||
encoding_rs = "0.8.35"
|
||||
execute = { version = "0.2.15", optional = true }
|
||||
terminal-colorsaurus = "1.0"
|
||||
unicode-segmentation = "1.12.0"
|
||||
unicode-segmentation = "1.13.2"
|
||||
itertools = "0.14.0"
|
||||
|
||||
[dependencies.git2]
|
||||
@@ -100,7 +100,7 @@ expect-test = "1.5.0"
|
||||
serial_test = { version = "2.0.0", default-features = false }
|
||||
predicates = "3.1.3"
|
||||
wait-timeout = "0.2.1"
|
||||
tempfile = "3.23.0"
|
||||
tempfile = "3.27.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
||||
[target.'cfg(unix)'.dev-dependencies]
|
||||
@@ -113,13 +113,13 @@ itertools = "0.14.0"
|
||||
once_cell = "1.20"
|
||||
prettyplease = "0.2.37"
|
||||
proc-macro2 = "1.0.106"
|
||||
quote = "1.0.40"
|
||||
quote = "1.0.45"
|
||||
regex = "1.12.2"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
serde_with = { version = "3.17.0", default-features = false, features = ["macros"] }
|
||||
syn = { version = "2.0.104", features = ["full"] }
|
||||
toml = { version = "0.9.8", features = ["preserve_order"] }
|
||||
toml = { version = "1.1.1", features = ["preserve_order"] }
|
||||
walkdir = "2.5"
|
||||
|
||||
[build-dependencies.clap]
|
||||
|
||||
@@ -43,7 +43,7 @@ languages:
|
||||
### Git integration
|
||||
|
||||
`bat` communicates with `git` to show modifications with respect to the index
|
||||
(see left side bar):
|
||||
(see left sidebar):
|
||||
|
||||

|
||||
|
||||
@@ -198,7 +198,7 @@ bat main.cpp | xclip
|
||||
export MANPAGER="bat -plman"
|
||||
man 2 select
|
||||
```
|
||||
(replace `bat` with `batcat` if you are on Debian or Ubuntu)
|
||||
(on some older Debian or Ubuntu releases, the executable is named `batcat` instead of `bat`)
|
||||
|
||||
If you prefer to have this bundled in a new command, you can also use [`batman`](https://github.com/eth-p/bat-extras/blob/master/doc/batman.md).
|
||||
|
||||
@@ -246,6 +246,14 @@ abbr -a --position anywhere -- -h '-h | bat -plhelp'
|
||||
|
||||
This way, you can keep on using `cp --help`, but get colorized help pages.
|
||||
|
||||
> [!TIP]
|
||||
> To remove these abbreviations later, run:
|
||||
> ```fish
|
||||
> abbr -e -- --help
|
||||
> abbr -e -- -h
|
||||
> ```
|
||||
> The `--` before the abbreviation name is required because `--help` and `-h` start with dashes, which would otherwise be interpreted as flags to `abbr` itself.
|
||||
|
||||
Be aware that in some cases, `-h` may not be a shorthand of `--help` (for example with `ls`). In cases where you need to use `-h`
|
||||
as a command argument you can prepend `\` to the argument (eg. `ls \-h`) to escape the aliasing defined above.
|
||||
|
||||
@@ -276,8 +284,8 @@ If your Ubuntu/Debian installation is new enough you can simply run:
|
||||
sudo apt install bat
|
||||
```
|
||||
|
||||
**Important**: If you install `bat` this way, please note that the executable may be installed as `batcat` instead of `bat` (due to [a name
|
||||
clash with another package](https://github.com/sharkdp/bat/issues/982)). You can set up a `bat -> batcat` symlink or alias to prevent any issues that may come up because of this and to be consistent with other distributions:
|
||||
**Important**: On some older Ubuntu/Debian releases, the executable is installed as `batcat` instead of `bat` (due to [a name
|
||||
clash with another package](https://github.com/sharkdp/bat/issues/982)). On newer releases, the executable is available as `bat`. If `bat --version` does not work after installation, try `batcat --version` instead. You can set up a `bat -> batcat` symlink or alias to prevent any issues that may come up because of this and to be consistent with other distributions:
|
||||
``` bash
|
||||
mkdir -p ~/.local/bin
|
||||
ln -s /usr/bin/batcat ~/.local/bin/bat
|
||||
@@ -581,7 +589,8 @@ syntax:
|
||||
|
||||
This works very similar to how we add new syntax definitions.
|
||||
> [!NOTE]
|
||||
> Themes are stored in [`.tmTheme` files](https://www.sublimetext.com/docs/color_schemes_tmtheme.html).
|
||||
> Custom themes must be stored in [`.tmTheme` files](https://www.sublimetext.com/docs/color_schemes_tmtheme.html).
|
||||
> Newer `.sublime-color-scheme` files are currently not supported.
|
||||
|
||||
First, create a folder with the new syntax highlighting themes:
|
||||
```bash
|
||||
|
||||
Vendored
+1
-1
@@ -90,7 +90,7 @@ _{{PROJECT_EXECUTABLE}}_main() {
|
||||
languages)
|
||||
local IFS=$'\n'
|
||||
local -a languages
|
||||
languages=( $({{PROJECT_EXECUTABLE}} --list-languages | awk -F':|,' '{ for (i = 1; i <= NF; ++i) printf("%s:%s\n", $i, $1) }') )
|
||||
languages=( ${(f)"$({{PROJECT_EXECUTABLE}} --list-languages | awk -F':|,' '{ for (i = 1; i <= NF; ++i) printf("%s:%s\n", $i, $1) }')"} )
|
||||
|
||||
_describe 'language' languages && ret=0
|
||||
;;
|
||||
|
||||
+9
@@ -2,6 +2,15 @@ diff --git syntaxes/01_Packages/Python/Python.sublime-syntax syntaxes/01_Package
|
||||
index 2acd86d8..86257f7b 100644
|
||||
--- syntaxes/01_Packages/Python/Python.sublime-syntax
|
||||
+++ syntaxes/01_Packages/Python/Python.sublime-syntax
|
||||
@@ -25,7 +31,7 @@ file_extensions:
|
||||
- wscript
|
||||
- bazel
|
||||
- bzl
|
||||
-first_line_match: ^#!\s*/.*\bpython(\d(\.\d)?)?\b
|
||||
+first_line_match: ^#!\s*/.*\b(python(\d(\.\d)?)?|uv)\b
|
||||
scope: source.python
|
||||
|
||||
variables:
|
||||
@@ -988,10 +988,6 @@ contexts:
|
||||
- match: \}
|
||||
scope: punctuation.section.mapping-or-set.end.python
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
diff --git syntaxes/01_Packages/TCL/Tcl.sublime-syntax syntaxes/01_Packages/TCL/Tcl.sublime-syntax
|
||||
index 1234567..abcdefg 100644
|
||||
--- syntaxes/01_Packages/TCL/Tcl.sublime-syntax
|
||||
+++ syntaxes/01_Packages/TCL/Tcl.sublime-syntax
|
||||
@@ -3,6 +3,7 @@
|
||||
# http://www.sublimetext.com/docs/3/syntax.html
|
||||
name: Tcl
|
||||
file_extensions:
|
||||
- tcl
|
||||
+first_line_match: ^\#!.*\b(tclsh|wish|expect)\b
|
||||
scope: source.tcl
|
||||
variables:
|
||||
+1
Submodule assets/syntaxes/02_Extra/COBOL added at 27825ee022
Vendored
+1
-1
Submodule assets/syntaxes/02_Extra/Idris2 updated: bbfe50e023...4d8eb35a38
Vendored
+1
-1
Submodule assets/syntaxes/02_Extra/Kotlin updated: aeeed2780b...c353694169
-398
@@ -1,398 +0,0 @@
|
||||
%YAML 1.2
|
||||
---
|
||||
# http://www.sublimetext.com/docs/3/syntax.html
|
||||
name: Kotlin
|
||||
file_extensions:
|
||||
- kt
|
||||
- kts
|
||||
scope: source.Kotlin
|
||||
contexts:
|
||||
main:
|
||||
- include: comments
|
||||
- match: '^\s*(package)\b(?:\s*([^ ;$]+)\s*)?'
|
||||
captures:
|
||||
1: keyword.other.kotlin
|
||||
2: entity.name.package.kotlin
|
||||
- include: imports
|
||||
- include: statements
|
||||
classes:
|
||||
- match: (?<!::)(?=\b(?:companion|class|object|interface)\b)
|
||||
push:
|
||||
- match: '(?=$|\})'
|
||||
pop: true
|
||||
- include: comments
|
||||
- match: \b(companion\s*)?(class|object|interface)\b
|
||||
captures:
|
||||
1: storage.modifier.kotlin
|
||||
2: storage.modifier.kotlin
|
||||
push:
|
||||
- match: '(?=<|\{|\(|:|$)'
|
||||
pop: true
|
||||
- include: comments
|
||||
- match: \w+
|
||||
scope: entity.name.type.class.kotlin
|
||||
- match: <
|
||||
push:
|
||||
- match: ">"
|
||||
pop: true
|
||||
- include: generics
|
||||
- match: \(
|
||||
push:
|
||||
- match: \)
|
||||
pop: true
|
||||
- include: parameters
|
||||
- match: (:)
|
||||
captures:
|
||||
1: keyword.operator.declaration.kotlin
|
||||
push:
|
||||
- match: "(?={|$)"
|
||||
pop: true
|
||||
- match: \w+
|
||||
scope: entity.other.inherited-class.kotlin
|
||||
- match: \(
|
||||
push:
|
||||
- match: \)
|
||||
pop: true
|
||||
- include: expressions
|
||||
- match: '\{'
|
||||
push:
|
||||
- match: '\}'
|
||||
pop: true
|
||||
- include: statements
|
||||
comments:
|
||||
- match: /\*
|
||||
captures:
|
||||
0: punctuation.definition.comment.kotlin
|
||||
push:
|
||||
- meta_scope: comment.block.kotlin
|
||||
- match: \*/
|
||||
captures:
|
||||
0: punctuation.definition.comment.kotlin
|
||||
pop: true
|
||||
- match: \s*((//).*$\n?)
|
||||
captures:
|
||||
1: comment.line.double-slash.kotlin
|
||||
2: punctuation.definition.comment.kotlin
|
||||
constants:
|
||||
- match: \b(true|false|null|this|super)\b
|
||||
scope: constant.language.kotlin
|
||||
- match: '\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)([LlFf])?\b'
|
||||
scope: constant.numeric.kotlin
|
||||
- match: '\b([A-Z][A-Z0-9_]+)\b'
|
||||
scope: constant.other.kotlin
|
||||
expressions:
|
||||
- match: \(
|
||||
push:
|
||||
- match: \)
|
||||
pop: true
|
||||
- include: expressions
|
||||
- include: types
|
||||
- include: strings
|
||||
- include: constants
|
||||
- include: comments
|
||||
- include: keywords
|
||||
functions:
|
||||
- match: (?=\s*\b(?:fun)\b)
|
||||
push:
|
||||
- match: '(?=$|\})'
|
||||
pop: true
|
||||
- match: \b(fun)\b
|
||||
captures:
|
||||
1: keyword.other.kotlin
|
||||
push:
|
||||
- match: (?=\()
|
||||
pop: true
|
||||
- match: <
|
||||
push:
|
||||
- match: ">"
|
||||
pop: true
|
||||
- include: generics
|
||||
- match: '([\.<\?>\w]+\.)?(\w+)'
|
||||
captures:
|
||||
2: entity.name.function.kotlin
|
||||
- match: \(
|
||||
push:
|
||||
- match: \)
|
||||
pop: true
|
||||
- include: parameters
|
||||
- match: (:)
|
||||
captures:
|
||||
1: keyword.operator.declaration.kotlin
|
||||
push:
|
||||
- match: "(?={|=|$)"
|
||||
pop: true
|
||||
- include: types
|
||||
- match: '\{'
|
||||
push:
|
||||
- match: '(?=\})'
|
||||
pop: true
|
||||
- include: statements
|
||||
- match: (=)
|
||||
captures:
|
||||
1: keyword.operator.assignment.kotlin
|
||||
push:
|
||||
- match: (?=$)
|
||||
pop: true
|
||||
- include: expressions
|
||||
generics:
|
||||
- match: (:)
|
||||
captures:
|
||||
1: keyword.operator.declaration.kotlin
|
||||
push:
|
||||
- match: (?=,|>)
|
||||
pop: true
|
||||
- include: types
|
||||
- include: keywords
|
||||
- match: \w+
|
||||
scope: storage.type.generic.kotlin
|
||||
getters-and-setters:
|
||||
- match: \b(get)\b\s*\(\s*\)
|
||||
captures:
|
||||
1: entity.name.function.kotlin
|
||||
push:
|
||||
- match: '\}|(?=\bset\b)|$'
|
||||
pop: true
|
||||
- match: (=)
|
||||
captures:
|
||||
1: keyword.operator.assignment.kotlin
|
||||
push:
|
||||
- match: (?=$|\bset\b)
|
||||
pop: true
|
||||
- include: expressions
|
||||
- match: '\{'
|
||||
push:
|
||||
- match: '\}'
|
||||
pop: true
|
||||
- include: expressions
|
||||
- match: \b(set)\b\s*(?=\()
|
||||
captures:
|
||||
1: entity.name.function.kotlin
|
||||
push:
|
||||
- match: '\}|(?=\bget\b)|$'
|
||||
pop: true
|
||||
- match: \(
|
||||
push:
|
||||
- match: \)
|
||||
pop: true
|
||||
- include: parameters
|
||||
- match: (=)
|
||||
captures:
|
||||
1: keyword.operator.assignment.kotlin
|
||||
push:
|
||||
- match: (?=$|\bset\b)
|
||||
pop: true
|
||||
- include: expressions
|
||||
- match: '\{'
|
||||
push:
|
||||
- match: '\}'
|
||||
pop: true
|
||||
- include: expressions
|
||||
imports:
|
||||
- match: '^\s*(import)\s+[^ $]+\s+(as)?'
|
||||
captures:
|
||||
1: keyword.other.kotlin
|
||||
2: keyword.other.kotlin
|
||||
keywords:
|
||||
- match: \b(var|val|public|private|protected|abstract|final|sealed|enum|open|attribute|annotation|override|inline|vararg|in|out|internal|data|tailrec|operator|infix|const|yield|typealias|typeof|reified|suspend)\b
|
||||
scope: storage.modifier.kotlin
|
||||
- match: \b(try|catch|finally|throw)\b
|
||||
scope: keyword.control.catch-exception.kotlin
|
||||
- match: \b(if|else|while|for|do|return|when|where|break|continue)\b
|
||||
scope: keyword.control.kotlin
|
||||
- match: \b(in|is|!in|!is|as|as\?|assert)\b
|
||||
scope: keyword.operator.kotlin
|
||||
- match: (==|!=|===|!==|<=|>=|<|>)
|
||||
scope: keyword.operator.comparison.kotlin
|
||||
- match: (=)
|
||||
scope: keyword.operator.assignment.kotlin
|
||||
- match: (::)
|
||||
scope: keyword.operator.kotlin
|
||||
- match: (:)
|
||||
scope: keyword.operator.declaration.kotlin
|
||||
- match: \b(by)\b
|
||||
scope: keyword.other.by.kotlin
|
||||
- match: (\?\.)
|
||||
scope: keyword.operator.safenav.kotlin
|
||||
- match: (\.)
|
||||
scope: keyword.operator.dot.kotlin
|
||||
- match: (\?:)
|
||||
scope: keyword.operator.elvis.kotlin
|
||||
- match: (\-\-|\+\+)
|
||||
scope: keyword.operator.increment-decrement.kotlin
|
||||
- match: (\+=|\-=|\*=|\/=)
|
||||
scope: keyword.operator.arithmetic.assign.kotlin
|
||||
- match: (\.\.)
|
||||
scope: keyword.operator.range.kotlin
|
||||
- match: (\-|\+|\*|\/|%)
|
||||
scope: keyword.operator.arithmetic.kotlin
|
||||
- match: (!|&&|\|\|)
|
||||
scope: keyword.operator.logical.kotlin
|
||||
- match: (;)
|
||||
scope: punctuation.terminator.kotlin
|
||||
namespaces:
|
||||
- match: \b(namespace)\b
|
||||
scope: keyword.other.kotlin
|
||||
- match: '\{'
|
||||
push:
|
||||
- match: '\}'
|
||||
pop: true
|
||||
- include: statements
|
||||
parameters:
|
||||
- match: (:)
|
||||
captures:
|
||||
1: keyword.operator.declaration.kotlin
|
||||
push:
|
||||
- match: (?=,|\)|=)
|
||||
pop: true
|
||||
- include: types
|
||||
- match: (=)
|
||||
captures:
|
||||
1: keyword.operator.declaration.kotlin
|
||||
push:
|
||||
- match: (?=,|\))
|
||||
pop: true
|
||||
- include: expressions
|
||||
- include: keywords
|
||||
- match: \w+
|
||||
scope: variable.parameter.function.kotlin
|
||||
statements:
|
||||
- include: namespaces
|
||||
- include: typedefs
|
||||
- include: classes
|
||||
- include: functions
|
||||
- include: variables
|
||||
- include: getters-and-setters
|
||||
- include: expressions
|
||||
strings:
|
||||
- match: '"""'
|
||||
captures:
|
||||
0: punctuation.definition.string.begin.kotlin
|
||||
push:
|
||||
- meta_scope: string.quoted.third.kotlin
|
||||
- match: '"""'
|
||||
captures:
|
||||
0: punctuation.definition.string.end.kotlin
|
||||
pop: true
|
||||
- match: '(\$\w+|\$\{[^\}]+\})'
|
||||
scope: variable.parameter.template.kotlin
|
||||
- match: \\.
|
||||
scope: constant.character.escape.kotlin
|
||||
- match: '"'
|
||||
captures:
|
||||
0: punctuation.definition.string.begin.kotlin
|
||||
push:
|
||||
- meta_scope: string.quoted.double.kotlin
|
||||
- match: '"'
|
||||
captures:
|
||||
0: punctuation.definition.string.end.kotlin
|
||||
pop: true
|
||||
- match: '(\$\w+|\$\{[^\}]+\})'
|
||||
scope: variable.parameter.template.kotlin
|
||||
- match: \\.
|
||||
scope: constant.character.escape.kotlin
|
||||
- match: "'"
|
||||
captures:
|
||||
0: punctuation.definition.string.begin.kotlin
|
||||
push:
|
||||
- meta_scope: string.quoted.single.kotlin
|
||||
- match: "'"
|
||||
captures:
|
||||
0: punctuation.definition.string.end.kotlin
|
||||
pop: true
|
||||
- match: \\.
|
||||
scope: constant.character.escape.kotlin
|
||||
- match: "`"
|
||||
captures:
|
||||
0: punctuation.definition.string.begin.kotlin
|
||||
push:
|
||||
- meta_scope: string.quoted.single.kotlin
|
||||
- match: "`"
|
||||
captures:
|
||||
0: punctuation.definition.string.end.kotlin
|
||||
pop: true
|
||||
typedefs:
|
||||
- match: (?=\s*(?:type))
|
||||
push:
|
||||
- match: (?=$)
|
||||
pop: true
|
||||
- match: \b(type)\b
|
||||
scope: keyword.other.kotlin
|
||||
- match: <
|
||||
push:
|
||||
- match: ">"
|
||||
pop: true
|
||||
- include: generics
|
||||
- include: expressions
|
||||
types:
|
||||
- match: \b(Nothing|Any|Unit|String|CharSequence|Int|Boolean|Char|Long|Double|Float|Short|Byte|dynamic)\b
|
||||
scope: storage.type.buildin.kotlin
|
||||
- match: \b(IntArray|BooleanArray|CharArray|LongArray|DoubleArray|FloatArray|ShortArray|ByteArray)\b
|
||||
scope: storage.type.buildin.array.kotlin
|
||||
- match: \b(Array|Collection|List|Map|Set|MutableList|MutableMap|MutableSet|Sequence)<\b
|
||||
captures:
|
||||
1: storage.type.buildin.collection.kotlin
|
||||
push:
|
||||
- match: ">"
|
||||
pop: true
|
||||
- include: types
|
||||
- include: keywords
|
||||
- match: \w+<
|
||||
push:
|
||||
- match: ">"
|
||||
pop: true
|
||||
- include: types
|
||||
- include: keywords
|
||||
- match: '\{'
|
||||
push:
|
||||
- match: '\}'
|
||||
pop: true
|
||||
- include: statements
|
||||
- match: \(
|
||||
push:
|
||||
- match: \)
|
||||
pop: true
|
||||
- include: types
|
||||
- match: (->)
|
||||
scope: keyword.operator.declaration.kotlin
|
||||
variables:
|
||||
- match: (?=\s*\b(?:var|val)\b)
|
||||
push:
|
||||
- match: (?=:|=|(\b(by)\b)|$)
|
||||
pop: true
|
||||
- match: \b(var|val)\b
|
||||
captures:
|
||||
1: keyword.other.kotlin
|
||||
push:
|
||||
- match: (?=:|=|(\b(by)\b)|$)
|
||||
pop: true
|
||||
- match: <
|
||||
push:
|
||||
- match: ">"
|
||||
pop: true
|
||||
- include: generics
|
||||
- match: '([\.<\?>\w]+\.)?(\w+)'
|
||||
captures:
|
||||
2: entity.name.variable.kotlin
|
||||
- match: (:)
|
||||
captures:
|
||||
1: keyword.operator.declaration.kotlin
|
||||
push:
|
||||
- match: (?==|$)
|
||||
pop: true
|
||||
- include: types
|
||||
- include: getters-and-setters
|
||||
- match: \b(by)\b
|
||||
captures:
|
||||
1: keyword.other.kotlin
|
||||
push:
|
||||
- match: (?=$)
|
||||
pop: true
|
||||
- include: expressions
|
||||
- match: (=)
|
||||
captures:
|
||||
1: keyword.operator.assignment.kotlin
|
||||
push:
|
||||
- match: (?=$)
|
||||
pop: true
|
||||
- include: expressions
|
||||
- include: getters-and-setters
|
||||
Vendored
+1
-1
Submodule assets/syntaxes/02_Extra/cmd-help updated: 273cb98817...2757ac1681
+118
-53
@@ -47,12 +47,49 @@ impl ToTokens for MappingTarget {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, DeserializeFromStr)]
|
||||
/// Helper type for deserializing a `Matcher` from either a plain string or a
|
||||
/// `{ glob = "...", case_sensitive = true }` struct.
|
||||
#[derive(Deserialize)]
|
||||
#[serde(untagged)]
|
||||
enum RawMatcher {
|
||||
Simple(String),
|
||||
Full {
|
||||
glob: String,
|
||||
case_sensitive: Option<bool>,
|
||||
},
|
||||
}
|
||||
|
||||
/// Whether a glob pattern should be matched case-sensitively or case-insensitively.
|
||||
///
|
||||
/// Mirrors the runtime `Case` type in `src/syntax_mapping.rs`.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
enum Case {
|
||||
Sensitive,
|
||||
Insensitive,
|
||||
}
|
||||
impl ToTokens for Case {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
let t = match self {
|
||||
Self::Sensitive => quote! { Case::Sensitive },
|
||||
Self::Insensitive => quote! { Case::Insensitive },
|
||||
};
|
||||
tokens.append_all(t);
|
||||
}
|
||||
}
|
||||
|
||||
/// A single matcher.
|
||||
///
|
||||
/// Codegen converts this into a `Lazy<Option<GlobMatcher>>`.
|
||||
struct Matcher(Vec<MatcherSegment>);
|
||||
/// Parse a matcher.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Deserialize)]
|
||||
#[serde(try_from = "RawMatcher")]
|
||||
struct Matcher {
|
||||
segments: Vec<MatcherSegment>,
|
||||
/// Whether the glob pattern should be matched case-sensitively.
|
||||
///
|
||||
/// Defaults to `Case::Insensitive` for backwards compatibility.
|
||||
case: Case,
|
||||
}
|
||||
/// Parse the glob pattern of a matcher.
|
||||
///
|
||||
/// Note that this implementation is rather strict: it will greedily interpret
|
||||
/// every valid environment variable replacement as such, then immediately
|
||||
@@ -66,68 +103,95 @@ struct Matcher(Vec<MatcherSegment>);
|
||||
///
|
||||
/// Revision history:
|
||||
/// - 2024-02-20: allow `{` and `}` (glob brace expansion)
|
||||
impl FromStr for Matcher {
|
||||
type Err = anyhow::Error;
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
use MatcherSegment as Seg;
|
||||
static VAR_REGEX: Lazy<Regex> = Lazy::new(|| Regex::new(r"\$\{([\w\d_]+)\}").unwrap());
|
||||
fn parse_glob(s: &str) -> Result<Vec<MatcherSegment>, anyhow::Error> {
|
||||
use MatcherSegment as Seg;
|
||||
static VAR_REGEX: Lazy<Regex> = Lazy::new(|| Regex::new(r"\$\{([\w\d_]+)\}").unwrap());
|
||||
|
||||
let mut segments = vec![];
|
||||
let mut text_start = 0;
|
||||
for capture in VAR_REGEX.captures_iter(s) {
|
||||
let match_0 = capture.get(0).unwrap();
|
||||
let mut segments = vec![];
|
||||
let mut text_start = 0;
|
||||
for capture in VAR_REGEX.captures_iter(s) {
|
||||
let match_0 = capture.get(0).unwrap();
|
||||
|
||||
// text before this var
|
||||
let text_end = match_0.start();
|
||||
segments.push(Seg::Text(s[text_start..text_end].into()));
|
||||
text_start = match_0.end();
|
||||
// text before this var
|
||||
let text_end = match_0.start();
|
||||
segments.push(Seg::Text(s[text_start..text_end].into()));
|
||||
text_start = match_0.end();
|
||||
|
||||
// this var
|
||||
segments.push(Seg::Env(capture.get(1).unwrap().as_str().into()));
|
||||
// this var
|
||||
segments.push(Seg::Env(capture.get(1).unwrap().as_str().into()));
|
||||
}
|
||||
// possible trailing text
|
||||
segments.push(Seg::Text(s[text_start..].into()));
|
||||
|
||||
// cleanup empty text segments
|
||||
let non_empty_segments = segments
|
||||
.into_iter()
|
||||
.filter(|seg| seg.text().map(|t| !t.is_empty()).unwrap_or(true))
|
||||
.collect_vec();
|
||||
|
||||
// sanity check
|
||||
if non_empty_segments
|
||||
.windows(2)
|
||||
.any(|segs| segs[0].is_text() && segs[1].is_text())
|
||||
{
|
||||
unreachable!("Parsed into consecutive text segments: {non_empty_segments:?}");
|
||||
}
|
||||
|
||||
// guard empty case
|
||||
if non_empty_segments.is_empty() {
|
||||
bail!(r#"Parsed an empty matcher: "{s}""#);
|
||||
}
|
||||
|
||||
// guard variable syntax leftover fragments
|
||||
if non_empty_segments
|
||||
.iter()
|
||||
.filter_map(Seg::text)
|
||||
.any(|t| t.contains('$'))
|
||||
{
|
||||
bail!(r#"Invalid matcher: "{s}""#);
|
||||
}
|
||||
|
||||
Ok(non_empty_segments)
|
||||
}
|
||||
impl TryFrom<RawMatcher> for Matcher {
|
||||
type Error = anyhow::Error;
|
||||
fn try_from(raw: RawMatcher) -> Result<Self, Self::Error> {
|
||||
const DEFAULT_CASE: Case = Case::Insensitive;
|
||||
match &raw {
|
||||
RawMatcher::Simple(s) => {
|
||||
let segments = parse_glob(s)?;
|
||||
Ok(Self {
|
||||
segments,
|
||||
case: DEFAULT_CASE,
|
||||
})
|
||||
}
|
||||
RawMatcher::Full {
|
||||
glob,
|
||||
case_sensitive,
|
||||
} => {
|
||||
let segments = parse_glob(glob)?;
|
||||
let case = match case_sensitive {
|
||||
None => DEFAULT_CASE,
|
||||
Some(false) => Case::Insensitive,
|
||||
Some(true) => Case::Sensitive,
|
||||
};
|
||||
Ok(Self { segments, case })
|
||||
}
|
||||
}
|
||||
// possible trailing text
|
||||
segments.push(Seg::Text(s[text_start..].into()));
|
||||
|
||||
// cleanup empty text segments
|
||||
let non_empty_segments = segments
|
||||
.into_iter()
|
||||
.filter(|seg| seg.text().map(|t| !t.is_empty()).unwrap_or(true))
|
||||
.collect_vec();
|
||||
|
||||
// sanity check
|
||||
if non_empty_segments
|
||||
.windows(2)
|
||||
.any(|segs| segs[0].is_text() && segs[1].is_text())
|
||||
{
|
||||
unreachable!("Parsed into consecutive text segments: {non_empty_segments:?}");
|
||||
}
|
||||
|
||||
// guard empty case
|
||||
if non_empty_segments.is_empty() {
|
||||
bail!(r#"Parsed an empty matcher: "{s}""#);
|
||||
}
|
||||
|
||||
// guard variable syntax leftover fragments
|
||||
if non_empty_segments
|
||||
.iter()
|
||||
.filter_map(Seg::text)
|
||||
.any(|t| t.contains('$'))
|
||||
{
|
||||
bail!(r#"Invalid matcher: "{s}""#);
|
||||
}
|
||||
|
||||
Ok(Self(non_empty_segments))
|
||||
}
|
||||
}
|
||||
impl ToTokens for Matcher {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
let t = match self.0.as_slice() {
|
||||
let case = &self.case;
|
||||
let t = match self.segments.as_slice() {
|
||||
[] => unreachable!("0-length matcher should never be created"),
|
||||
[MatcherSegment::Text(text)] => {
|
||||
quote! { Lazy::new(|| Some(build_matcher_fixed(#text))) }
|
||||
quote! { Lazy::new(|| Some(build_matcher_fixed(#text, #case))) }
|
||||
}
|
||||
// parser logic ensures that this case can only happen when there are dynamic segments
|
||||
segs @ [_, ..] => quote! { Lazy::new(|| build_matcher_dynamic(&[ #(#segs),* ])) },
|
||||
segs @ [_, ..] => {
|
||||
quote! { Lazy::new(|| build_matcher_dynamic(&[ #(#segs),* ], #case)) }
|
||||
}
|
||||
};
|
||||
tokens.append_all(t);
|
||||
}
|
||||
@@ -175,6 +239,7 @@ impl MatcherSegment {
|
||||
/// A struct that models a single .toml file in /src/syntax_mapping/builtins/.
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
struct MappingDefModel {
|
||||
#[serde(default)]
|
||||
mappings: IndexMap<MappingTarget, Vec<Matcher>>,
|
||||
}
|
||||
impl MappingDefModel {
|
||||
|
||||
+2
-1
@@ -77,7 +77,8 @@ Options:
|
||||
--terminal-width <width>
|
||||
Explicitly set the width of the terminal instead of determining it automatically. If
|
||||
prefixed with '+' or '-', the value will be treated as an offset to the actual terminal
|
||||
width. See also: '--wrap'.
|
||||
width. This can also be configured via the BAT_WIDTH environment variable (e.g. export
|
||||
BAT_WIDTH="100"). See also: '--wrap'.
|
||||
|
||||
-n, --number
|
||||
Only show line numbers, no other decorations. This is an alias for '--style=numbers'
|
||||
|
||||
+11
-1
@@ -590,7 +590,17 @@ impl App {
|
||||
|
||||
// Plain if `--plain` is specified at least once.
|
||||
if self.matches.get_count("plain") > 0 {
|
||||
return Some(StyleComponents(HashSet::from([StyleComponent::Plain])));
|
||||
let mut components = HashSet::from([StyleComponent::Plain]);
|
||||
// When --diff is active, preserve change markers and snip separators
|
||||
// so that diff output remains visually useful.
|
||||
if self.matches.try_contains_id("diff").unwrap_or_default()
|
||||
&& self.matches.get_flag("diff")
|
||||
{
|
||||
#[cfg(feature = "git")]
|
||||
components.insert(StyleComponent::Changes);
|
||||
components.insert(StyleComponent::Snip);
|
||||
}
|
||||
return Some(StyleComponents(components));
|
||||
}
|
||||
|
||||
// Default behavior.
|
||||
|
||||
@@ -240,6 +240,7 @@ pub fn build_app(interactive_output: bool) -> Command {
|
||||
.arg(
|
||||
Arg::new("terminal-width")
|
||||
.long("terminal-width")
|
||||
.overrides_with("terminal-width")
|
||||
.value_name("width")
|
||||
.hide_short_help(true)
|
||||
.allow_hyphen_values(true)
|
||||
@@ -255,10 +256,13 @@ pub fn build_app(interactive_output: bool) -> Command {
|
||||
})
|
||||
.map_err(|e| e.to_string())
|
||||
})
|
||||
.help(
|
||||
.help("Explicitly set the width of the terminal instead of determining it automatically.")
|
||||
.long_help(
|
||||
"Explicitly set the width of the terminal instead of determining it \
|
||||
automatically. If prefixed with '+' or '-', the value will be treated \
|
||||
as an offset to the actual terminal width. See also: '--wrap'.",
|
||||
as an offset to the actual terminal width. This can also be configured \
|
||||
via the BAT_WIDTH environment variable (e.g. export BAT_WIDTH=\"100\"). \
|
||||
See also: '--wrap'.",
|
||||
),
|
||||
)
|
||||
.arg(
|
||||
|
||||
@@ -153,6 +153,7 @@ fn get_args_from_str(content: &str) -> Result<Vec<OsString>, shell_words::ParseE
|
||||
pub fn get_args_from_env_vars() -> Vec<OsString> {
|
||||
[
|
||||
("--tabs", "BAT_TABS"),
|
||||
("--terminal-width", "BAT_WIDTH"),
|
||||
("--theme", bat::theme::env::BAT_THEME),
|
||||
("--theme-dark", bat::theme::env::BAT_THEME_DARK),
|
||||
("--theme-light", bat::theme::env::BAT_THEME_LIGHT),
|
||||
|
||||
+26
-1
@@ -285,7 +285,28 @@ fn run_controller(inputs: Vec<Input>, config: &Config, cache_dir: &Path) -> Resu
|
||||
|
||||
#[cfg(feature = "bugreport")]
|
||||
fn invoke_bugreport(app: &App, cache_dir: &Path) {
|
||||
use bugreport::{bugreport, collector::*, format::Markdown};
|
||||
use bugreport::{bugreport, collector::*, format::Markdown, report::ReportEntry};
|
||||
|
||||
struct ColorSchemeCollector;
|
||||
|
||||
impl Collector for ColorSchemeCollector {
|
||||
fn description(&self) -> &str {
|
||||
"Detected terminal color scheme"
|
||||
}
|
||||
|
||||
fn collect(
|
||||
&mut self,
|
||||
_: &bugreport::CrateInfo,
|
||||
) -> std::result::Result<ReportEntry, CollectionError> {
|
||||
let color_scheme = bat::theme::color_scheme(bat::theme::DetectColorScheme::Always);
|
||||
let text = match color_scheme {
|
||||
Some(bat::theme::ColorScheme::Dark) => "dark",
|
||||
Some(bat::theme::ColorScheme::Light) => "light",
|
||||
None => "not detected",
|
||||
};
|
||||
Ok(ReportEntry::Text(text.to_string()))
|
||||
}
|
||||
}
|
||||
let pager = bat::config::get_pager_executable(
|
||||
app.matches.get_one::<String>("pager").map(|s| s.as_str()),
|
||||
)
|
||||
@@ -307,6 +328,9 @@ fn invoke_bugreport(app: &App, cache_dir: &Path) {
|
||||
"BAT_STYLE",
|
||||
"BAT_TABS",
|
||||
"BAT_THEME",
|
||||
"BAT_WIDTH",
|
||||
bat::theme::env::BAT_THEME_DARK,
|
||||
bat::theme::env::BAT_THEME_LIGHT,
|
||||
"COLORTERM",
|
||||
"LANG",
|
||||
"LC_ALL",
|
||||
@@ -326,6 +350,7 @@ fn invoke_bugreport(app: &App, cache_dir: &Path) {
|
||||
custom_assets_metadata,
|
||||
))
|
||||
.info(DirectoryEntries::new("Custom assets", cache_dir))
|
||||
.info(ColorSchemeCollector)
|
||||
.info(CompileTimeInformation::default());
|
||||
|
||||
#[cfg(feature = "paging")]
|
||||
|
||||
+72
-15
@@ -207,7 +207,7 @@ impl<'a> Input<'a> {
|
||||
kind: OpenedInputKind::StdIn,
|
||||
description,
|
||||
metadata: self.metadata,
|
||||
reader: InputReader::new(stdin),
|
||||
reader: InputReader::try_new(stdin)?,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -236,14 +236,14 @@ impl<'a> Input<'a> {
|
||||
file = input_identifier.into_inner().expect("The file was lost in the clircle::Identifier, this should not have happened...");
|
||||
}
|
||||
|
||||
InputReader::new(BufReader::new(file))
|
||||
InputReader::try_new(BufReader::new(file))?
|
||||
},
|
||||
}),
|
||||
InputKind::CustomReader(reader) => Ok(OpenedInput {
|
||||
description,
|
||||
kind: OpenedInputKind::CustomReader,
|
||||
metadata: self.metadata,
|
||||
reader: InputReader::new(BufReader::new(reader)),
|
||||
reader: InputReader::try_new(BufReader::new(reader))?,
|
||||
}),
|
||||
}
|
||||
}
|
||||
@@ -257,28 +257,29 @@ pub(crate) struct InputReader<'a> {
|
||||
}
|
||||
|
||||
impl<'a> InputReader<'a> {
|
||||
pub(crate) fn new<R: BufRead + 'a>(mut reader: R) -> InputReader<'a> {
|
||||
let mut first_line = vec![];
|
||||
reader.read_until(b'\n', &mut first_line).ok();
|
||||
#[cfg(test)]
|
||||
pub(crate) fn new<R: BufRead + 'a>(reader: R) -> InputReader<'a> {
|
||||
Self::try_new(reader).expect("reading the first line failed")
|
||||
}
|
||||
|
||||
let content_type = if first_line.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(content_inspector::inspect(&first_line[..]))
|
||||
};
|
||||
pub(crate) fn try_new<R: BufRead + 'a>(mut reader: R) -> io::Result<InputReader<'a>> {
|
||||
let mut first_line = vec![];
|
||||
reader.read_until(b'\n', &mut first_line)?;
|
||||
|
||||
let content_type = inspect_content_type(&first_line);
|
||||
|
||||
if content_type == Some(ContentType::UTF_16LE) {
|
||||
read_utf16_line(&mut reader, &mut first_line, 0x00, 0x0A).ok();
|
||||
read_utf16_line(&mut reader, &mut first_line, 0x00, 0x0A)?;
|
||||
} else if content_type == Some(ContentType::UTF_16BE) {
|
||||
read_utf16_line(&mut reader, &mut first_line, 0x0A, 0x00).ok();
|
||||
read_utf16_line(&mut reader, &mut first_line, 0x0A, 0x00)?;
|
||||
}
|
||||
|
||||
InputReader {
|
||||
Ok(InputReader {
|
||||
inner: Box::new(reader),
|
||||
first_line,
|
||||
content_type,
|
||||
unbuffered: false,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn read_line(&mut self, buf: &mut Vec<u8>) -> io::Result<bool> {
|
||||
@@ -319,6 +320,25 @@ impl<'a> InputReader<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn inspect_content_type(first_line: &[u8]) -> Option<ContentType> {
|
||||
if first_line.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let content_type = content_inspector::inspect(first_line);
|
||||
if content_type == ContentType::UTF_8 && has_zip_signature(first_line) {
|
||||
Some(ContentType::BINARY)
|
||||
} else {
|
||||
Some(content_type)
|
||||
}
|
||||
}
|
||||
|
||||
fn has_zip_signature(bytes: &[u8]) -> bool {
|
||||
[b"PK\x03\x04", b"PK\x05\x06", b"PK\x07\x08"]
|
||||
.into_iter()
|
||||
.any(|signature| bytes.starts_with(signature))
|
||||
}
|
||||
|
||||
fn read_utf16_line<R: BufRead>(
|
||||
reader: &mut R,
|
||||
buf: &mut Vec<u8>,
|
||||
@@ -374,6 +394,43 @@ fn basic() {
|
||||
assert!(buffer.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zip_magic_headers_are_treated_as_binary() {
|
||||
for content in [b"PK\x03\x04hello", b"PK\x05\x06hello", b"PK\x07\x08hello"] {
|
||||
let reader = InputReader::new(&content[..]);
|
||||
assert_eq!(Some(ContentType::BINARY), reader.content_type);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn non_zip_pk_prefix_is_not_treated_as_binary() {
|
||||
assert_eq!(
|
||||
Some(ContentType::UTF_8),
|
||||
inspect_content_type(b"PK\x03\x03hello")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn input_open_returns_initial_read_errors() {
|
||||
struct FailingRead;
|
||||
|
||||
impl Read for FailingRead {
|
||||
fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> {
|
||||
Err(io::Error::other("initial read failed"))
|
||||
}
|
||||
}
|
||||
|
||||
let input = Input::from_reader(Box::new(FailingRead));
|
||||
let result = input.open(io::empty(), None);
|
||||
|
||||
assert!(result.is_err());
|
||||
assert!(result
|
||||
.err()
|
||||
.unwrap()
|
||||
.to_string()
|
||||
.contains("initial read failed"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn utf16le() {
|
||||
let content = b"\xFF\xFE\x73\x00\x0A\x00\x64\x00";
|
||||
|
||||
+2
-2
@@ -155,7 +155,7 @@ impl LessOpenPreprocessor {
|
||||
|
||||
Ok(OpenedInput {
|
||||
kind,
|
||||
reader: InputReader::new(BufReader::new(
|
||||
reader: InputReader::try_new(BufReader::new(
|
||||
if matches!(self.kind, LessOpenKind::TempFile) {
|
||||
let lessopen_string = match String::from_utf8(lessopen_stdout) {
|
||||
Ok(string) => string,
|
||||
@@ -192,7 +192,7 @@ impl LessOpenPreprocessor {
|
||||
.map(|s| s.replacen("%s", &path_str, 1).replacen("%s", "-", 1)),
|
||||
}
|
||||
},
|
||||
)),
|
||||
))?,
|
||||
metadata: input.metadata,
|
||||
description: input.description,
|
||||
})
|
||||
|
||||
@@ -23,6 +23,18 @@ pub struct BuiltinPager {
|
||||
impl BuiltinPager {
|
||||
fn new() -> Self {
|
||||
let pager = minus::Pager::new();
|
||||
|
||||
let mut input_register = minus::input::HashedEventRegister::default();
|
||||
input_register.add_key_events(&["home"], |_, _| {
|
||||
minus::input::InputEvent::UpdateUpperMark(0)
|
||||
});
|
||||
input_register.add_key_events(&["end"], |_, _| {
|
||||
minus::input::InputEvent::UpdateUpperMark(usize::MAX)
|
||||
});
|
||||
pager
|
||||
.set_input_classifier(Box::new(input_register))
|
||||
.expect("failed to set input classifier on newly created pager");
|
||||
|
||||
let handle = {
|
||||
let pager = pager.clone();
|
||||
Some(spawn(move || {
|
||||
|
||||
+13
-5
@@ -37,6 +37,16 @@ use crate::wrapping::WrappingMode;
|
||||
use crate::BinaryBehavior;
|
||||
use crate::StripAnsiMode;
|
||||
|
||||
// Return the displayed width of a character.
|
||||
//
|
||||
// Control characters (0x00..=0x1F and 0x7F) are rendered by the terminal
|
||||
// in caret notation (e.g. ^@, ^A, ..., ^?), which occupies two columns.
|
||||
// UnicodeWidthChar::width() returns None for these, so we map them to 2
|
||||
// here instead of the previous default of 0.
|
||||
fn char_width(c: char) -> usize {
|
||||
c.width().unwrap_or(if c.is_control() { 2 } else { 0 })
|
||||
}
|
||||
|
||||
const ANSI_UNDERLINE_ENABLE: EscapeSequence = EscapeSequence::CSI {
|
||||
raw_sequence: "\x1B[4m",
|
||||
parameters: "4",
|
||||
@@ -793,7 +803,7 @@ impl Printer for InteractivePrinter<'_> {
|
||||
|
||||
for c in text.chars() {
|
||||
// calculate the displayed width for next character
|
||||
let cw = c.width().unwrap_or(0);
|
||||
let cw = char_width(c);
|
||||
current_width += cw;
|
||||
|
||||
// Track whitespace positions for word wrapping.
|
||||
@@ -868,10 +878,8 @@ impl Printer for InteractivePrinter<'_> {
|
||||
if let Some(rs) = rest_start {
|
||||
// Word wrap: carry remainder to next line.
|
||||
let remainder = line_buf[rs..].to_string();
|
||||
let rem_width: usize = remainder
|
||||
.chars()
|
||||
.map(|ch| ch.width().unwrap_or(0))
|
||||
.sum();
|
||||
let rem_width: usize =
|
||||
remainder.chars().map(char_width).sum();
|
||||
line_buf.clear();
|
||||
line_buf.push_str(&remainder);
|
||||
current_width = rem_width + cw;
|
||||
|
||||
+54
-3
@@ -17,9 +17,16 @@ use ignored_suffixes::IgnoredSuffixes;
|
||||
mod builtin;
|
||||
pub mod ignored_suffixes;
|
||||
|
||||
fn make_glob_matcher(from: &str) -> Result<GlobMatcher> {
|
||||
/// Whether a glob pattern should be matched case-sensitively or case-insensitively.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub(crate) enum Case {
|
||||
Sensitive,
|
||||
Insensitive,
|
||||
}
|
||||
|
||||
fn make_glob_matcher(from: &str, case: Case) -> Result<GlobMatcher> {
|
||||
let matcher = GlobBuilder::new(from)
|
||||
.case_insensitive(true)
|
||||
.case_insensitive(matches!(case, Case::Insensitive))
|
||||
.literal_separator(true)
|
||||
.build()?
|
||||
.compile_matcher();
|
||||
@@ -97,7 +104,14 @@ impl<'a> SyntaxMapping<'a> {
|
||||
}
|
||||
|
||||
pub fn insert(&mut self, from: &str, to: MappingTarget<'a>) -> Result<()> {
|
||||
let matcher = make_glob_matcher(from)?;
|
||||
let matcher = make_glob_matcher(from, Case::Insensitive)?;
|
||||
self.custom_mappings.push((matcher, to));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Like [`Self::insert`], but the glob pattern is matched case-sensitively.
|
||||
pub fn insert_case_sensitive(&mut self, from: &str, to: MappingTarget<'a>) -> Result<()> {
|
||||
let matcher = make_glob_matcher(from, Case::Sensitive)?;
|
||||
self.custom_mappings.push((matcher, to));
|
||||
Ok(())
|
||||
}
|
||||
@@ -261,4 +275,41 @@ mod tests {
|
||||
Some(MappingTarget::MapTo("alpha"))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn case_sensitive_custom_mappings_work() {
|
||||
let mut map = SyntaxMapping::new();
|
||||
map.insert_case_sensitive("MY_SPECIAL_FILE", MappingTarget::MapTo("Python"))
|
||||
.ok();
|
||||
|
||||
// Exact case matches
|
||||
assert_eq!(
|
||||
map.get_syntax_for("/path/to/MY_SPECIAL_FILE"),
|
||||
Some(MappingTarget::MapTo("Python"))
|
||||
);
|
||||
// Different case should NOT match the case-sensitive rule
|
||||
assert_eq!(map.get_syntax_for("/path/to/my_special_file"), None);
|
||||
assert_eq!(map.get_syntax_for("/path/to/My_Special_File"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn builtin_mappings_build_is_case_sensitive() {
|
||||
let map = SyntaxMapping::new();
|
||||
|
||||
// "BUILD" (uppercase) should map to Python via case-sensitive builtin
|
||||
assert_eq!(
|
||||
map.get_syntax_for("/path/to/BUILD"),
|
||||
Some(MappingTarget::MapTo("Python"))
|
||||
);
|
||||
// "build" (lowercase) should still map to MapToUnknown
|
||||
assert_eq!(
|
||||
map.get_syntax_for("/path/to/build"),
|
||||
Some(MappingTarget::MapToUnknown)
|
||||
);
|
||||
// Mixed case should NOT match the Python rule
|
||||
assert_eq!(
|
||||
map.get_syntax_for("/path/to/Build"),
|
||||
Some(MappingTarget::MapToUnknown)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::env;
|
||||
use globset::GlobMatcher;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
use crate::syntax_mapping::{make_glob_matcher, MappingTarget};
|
||||
use crate::syntax_mapping::{make_glob_matcher, Case, MappingTarget};
|
||||
|
||||
// Static syntax mappings generated from /src/syntax_mapping/builtins/ by the
|
||||
// build script (/build/syntax_mapping.rs).
|
||||
@@ -53,8 +53,8 @@ include!(concat!(
|
||||
/// A failure to compile is a fatal error.
|
||||
///
|
||||
/// Used internally by `Lazy<Option<GlobMatcher>>`'s lazy evaluation closure.
|
||||
fn build_matcher_fixed(from: &str) -> GlobMatcher {
|
||||
make_glob_matcher(from).expect("A builtin fixed glob matcher failed to compile")
|
||||
fn build_matcher_fixed(from: &str, case: Case) -> GlobMatcher {
|
||||
make_glob_matcher(from, case).expect("A builtin fixed glob matcher failed to compile")
|
||||
}
|
||||
|
||||
/// Join a list of matcher segments to create a glob string, replacing all
|
||||
@@ -64,7 +64,7 @@ fn build_matcher_fixed(from: &str) -> GlobMatcher {
|
||||
/// to compile.
|
||||
///
|
||||
/// Used internally by `Lazy<Option<GlobMatcher>>`'s lazy evaluation closure.
|
||||
fn build_matcher_dynamic(segs: &[MatcherSegment]) -> Option<GlobMatcher> {
|
||||
fn build_matcher_dynamic(segs: &[MatcherSegment], case: Case) -> Option<GlobMatcher> {
|
||||
// join segments
|
||||
let mut buf = String::new();
|
||||
for seg in segs {
|
||||
@@ -77,7 +77,7 @@ fn build_matcher_dynamic(segs: &[MatcherSegment]) -> Option<GlobMatcher> {
|
||||
}
|
||||
}
|
||||
// compile glob matcher
|
||||
let matcher = make_glob_matcher(&buf).ok()?;
|
||||
let matcher = make_glob_matcher(&buf, case).ok()?;
|
||||
Some(matcher)
|
||||
}
|
||||
|
||||
|
||||
@@ -20,12 +20,10 @@ syntax mappings defined by all TOML files, and embed them into the binary.
|
||||
|
||||
## File syntax
|
||||
|
||||
Each TOML file should contain a single section named `mappings`, with each of
|
||||
its keys being a language identifier (first column of `bat -L`; also referred to
|
||||
as "target").
|
||||
Each TOML file should contain a single section named `mappings`, with each of its keys being a language
|
||||
identifier (first column of `bat -L`; also referred to as "target").
|
||||
|
||||
The value of each key should be an array of strings, with each item being a glob
|
||||
matcher. We will call each of these items a "rule".
|
||||
The value of each key should be an array of "rules". The rules are expected to be objects with a `glob` string and a `case_sensitive` boolean. For simplification, a rule can be just a glob string, which is shorthand for the default case insensitive mode.
|
||||
|
||||
For example, if `foo-application` uses both TOML and YAML configuration files,
|
||||
we could write something like this:
|
||||
@@ -98,6 +96,15 @@ like this:
|
||||
]
|
||||
```
|
||||
|
||||
### Case sensitivity
|
||||
|
||||
By default, all glob patterns are matched case-insensitively. To match a pattern case-sensitively, use the object form of the rule with the `case_sensitive` option:
|
||||
|
||||
```toml
|
||||
[mappings]
|
||||
"Python" = [{ glob = "BUILD", case_sensitive = true }]
|
||||
```
|
||||
|
||||
## Ordering
|
||||
|
||||
At compile time, all TOML files applicable to the target are processed in
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
[mappings]
|
||||
"Python" = [{ glob = "BUILD", case_sensitive = true }]
|
||||
@@ -1,2 +1,2 @@
|
||||
[mappings]
|
||||
"XML" = ["*.csproj", "*.vbproj", "*.props", "*.targets"]
|
||||
"XML" = ["*.csproj", "*.vbproj", "*.props", "*.targets", "*.slnx"]
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
[mappings]
|
||||
"INI" = [".boto", "**/gcloud/configurations/config_*"]
|
||||
"Git Ignore" = [".gcloudignore"]
|
||||
@@ -0,0 +1,2 @@
|
||||
[mappings]
|
||||
"Git Ignore" = [".?*ignore"]
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/expect -f
|
||||
set timeout 30
|
||||
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env tclsh
|
||||
puts "Hello from tclsh"
|
||||
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/wish
|
||||
button .b -text "Click"
|
||||
@@ -1047,6 +1047,57 @@ fn tabs_4_arg_overrides_env_noconfig() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn terminal_width_env_var_is_respected() {
|
||||
let tmp_dir = tempdir().expect("can create temporary directory");
|
||||
let tmp_path = tmp_dir.path().join("long.txt");
|
||||
std::fs::write(
|
||||
&tmp_path,
|
||||
"0123456789abcdef0123456789abcdef0123456789abcdef\n",
|
||||
)
|
||||
.expect("can write temporary file");
|
||||
|
||||
bat()
|
||||
.env("BAT_WIDTH", "20")
|
||||
.arg(&tmp_path)
|
||||
.arg("--paging=never")
|
||||
.arg("--color=never")
|
||||
.arg("--style=numbers")
|
||||
.arg("--decorations=always")
|
||||
.arg("--wrap=character")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(" 1 0123456789abcde\n f0123456789abcd\n ef0123456789abc\n def\n")
|
||||
.stderr("");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn terminal_width_arg_overrides_env() {
|
||||
let tmp_dir = tempdir().expect("can create temporary directory");
|
||||
let tmp_path = tmp_dir.path().join("long.txt");
|
||||
std::fs::write(
|
||||
&tmp_path,
|
||||
"0123456789abcdef0123456789abcdef0123456789abcdef\n",
|
||||
)
|
||||
.expect("can write temporary file");
|
||||
|
||||
bat()
|
||||
.env("BAT_WIDTH", "20")
|
||||
.arg(&tmp_path)
|
||||
.arg("--paging=never")
|
||||
.arg("--color=never")
|
||||
.arg("--style=numbers")
|
||||
.arg("--decorations=always")
|
||||
.arg("--wrap=character")
|
||||
.arg("--terminal-width=10")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(
|
||||
" 1 01234\n 56789\n abcde\n f0123\n 45678\n 9abcd\n ef012\n 34567\n 89abc\n def\n",
|
||||
)
|
||||
.stderr("");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fail_non_existing() {
|
||||
bat().arg("non-existing-file").assert().failure();
|
||||
@@ -1474,6 +1525,7 @@ fn diagnostic_sanity_check() {
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains("BAT_PAGER="))
|
||||
.stdout(predicate::str::contains("BAT_WIDTH="))
|
||||
.stderr("");
|
||||
}
|
||||
|
||||
@@ -2093,6 +2145,24 @@ fn header_binary() {
|
||||
.stderr("");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn header_zip_file_is_binary() {
|
||||
let tmp_dir = tempdir().expect("can create temporary directory");
|
||||
let tmp_path = tmp_dir.path().join("test.zip");
|
||||
std::fs::write(&tmp_path, b"PK\x03\x04hello").expect("can write temporary file");
|
||||
|
||||
bat()
|
||||
.arg(&tmp_path)
|
||||
.arg("--decorations=always")
|
||||
.arg("--style=header")
|
||||
.arg("-r=0:0")
|
||||
.arg("--file-name=test.zip")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout("File: test.zip <BINARY>\n")
|
||||
.stderr("");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn header_full_binary() {
|
||||
bat()
|
||||
@@ -2681,6 +2751,25 @@ fn binary_as_text() {
|
||||
.stderr("");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn binary_as_text_control_char_width() {
|
||||
// Control characters are displayed as caret notation (e.g. ^@) by the
|
||||
// terminal, occupying 2 columns each. With 20 NUL bytes (40 columns) +
|
||||
// "END" (3 columns) = 43 columns, wrapping at terminal width 40 must
|
||||
// produce 2 lines, not 1. See #3631.
|
||||
bat()
|
||||
.arg("--binary=as-text")
|
||||
.arg("--wrap=character")
|
||||
.arg("--terminal-width=40")
|
||||
.arg("--decorations=always")
|
||||
.arg("--style=plain")
|
||||
.arg("--color=never")
|
||||
.arg("regression_tests/issue_3631.txt")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicate::function(|s: &str| s.lines().count() == 2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_strip_overstrike_for_plain_text() {
|
||||
// Overstrike is preserved for plain text files (no syntax highlighting)
|
||||
@@ -3965,3 +4054,184 @@ fn word_wrap_short_line_no_wrap() {
|
||||
.success()
|
||||
.stdout("Single Line\n");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(feature = "git")]
|
||||
fn setup_diff_test_repo() -> tempfile::TempDir {
|
||||
use std::process::Command;
|
||||
|
||||
let dir = tempfile::tempdir().expect("can create temporary directory");
|
||||
let repo = dir.path();
|
||||
|
||||
// Initialize a git repo and commit a file
|
||||
Command::new("git")
|
||||
.args(["init"])
|
||||
.current_dir(repo)
|
||||
.output()
|
||||
.expect("git init");
|
||||
|
||||
Command::new("git")
|
||||
.args(["config", "user.email", "test@test.com"])
|
||||
.current_dir(repo)
|
||||
.output()
|
||||
.expect("git config email");
|
||||
|
||||
Command::new("git")
|
||||
.args(["config", "user.name", "Test"])
|
||||
.current_dir(repo)
|
||||
.output()
|
||||
.expect("git config name");
|
||||
|
||||
std::fs::write(repo.join("test.txt"), "line 1\nline 2\nline 3\n").expect("can write test file");
|
||||
|
||||
Command::new("git")
|
||||
.args(["add", "test.txt"])
|
||||
.current_dir(repo)
|
||||
.output()
|
||||
.expect("git add");
|
||||
|
||||
Command::new("git")
|
||||
.args(["commit", "-m", "initial"])
|
||||
.current_dir(repo)
|
||||
.output()
|
||||
.expect("git commit");
|
||||
|
||||
// Modify the file so --diff has something to show
|
||||
std::fs::write(
|
||||
repo.join("test.txt"),
|
||||
"line 1\nline 2 modified\nline 3\nline 4 added\n",
|
||||
)
|
||||
.expect("can write modified test file");
|
||||
|
||||
dir
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(feature = "git")]
|
||||
#[test]
|
||||
fn diff_plain_preserves_change_markers() {
|
||||
let repo = setup_diff_test_repo();
|
||||
|
||||
// With --diff --plain, output should contain the change marker column
|
||||
// but not other decorations like line numbers or grid
|
||||
let output = bat()
|
||||
.current_dir(repo.path())
|
||||
.arg("--diff")
|
||||
.arg("--plain")
|
||||
.arg("--color=never")
|
||||
.arg("--decorations=always")
|
||||
.arg("test.txt")
|
||||
.assert()
|
||||
.success()
|
||||
.get_output()
|
||||
.stdout
|
||||
.clone();
|
||||
|
||||
let stdout = std::str::from_utf8(&output).expect("valid utf-8");
|
||||
|
||||
// The output should contain the modified and added lines
|
||||
assert!(
|
||||
stdout.contains("line 2 modified"),
|
||||
"diff plain output should contain modified line, got: {stdout}"
|
||||
);
|
||||
assert!(
|
||||
stdout.contains("line 4 added"),
|
||||
"diff plain output should contain added line, got: {stdout}"
|
||||
);
|
||||
|
||||
// Should NOT contain line numbers (a decoration that --plain disables)
|
||||
assert!(
|
||||
!stdout.contains(" 1"),
|
||||
"diff plain output should not contain line numbers, got: {stdout}"
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(feature = "git")]
|
||||
#[test]
|
||||
fn diff_plain_does_not_show_grid_or_header() {
|
||||
let repo = setup_diff_test_repo();
|
||||
|
||||
let output = bat()
|
||||
.current_dir(repo.path())
|
||||
.arg("--diff")
|
||||
.arg("--plain")
|
||||
.arg("--color=never")
|
||||
.arg("--decorations=always")
|
||||
.arg("--terminal-width=80")
|
||||
.arg("test.txt")
|
||||
.assert()
|
||||
.success()
|
||||
.get_output()
|
||||
.stdout
|
||||
.clone();
|
||||
|
||||
let stdout = std::str::from_utf8(&output).expect("valid utf-8");
|
||||
|
||||
// Grid lines use box-drawing characters
|
||||
assert!(
|
||||
!stdout.contains('─'),
|
||||
"diff plain output should not contain grid lines, got: {stdout}"
|
||||
);
|
||||
assert!(
|
||||
!stdout.contains('│'),
|
||||
"diff plain output should not contain grid separators, got: {stdout}"
|
||||
);
|
||||
|
||||
// Header shows "File: <filename>"
|
||||
assert!(
|
||||
!stdout.contains("File:"),
|
||||
"diff plain output should not contain file header, got: {stdout}"
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(feature = "git")]
|
||||
#[test]
|
||||
fn plain_without_diff_still_works() {
|
||||
let repo = setup_diff_test_repo();
|
||||
|
||||
// --plain without --diff should output file content with no decorations at all
|
||||
bat()
|
||||
.current_dir(repo.path())
|
||||
.arg("--plain")
|
||||
.arg("--color=never")
|
||||
.arg("--decorations=always")
|
||||
.arg("test.txt")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout("line 1\nline 2 modified\nline 3\nline 4 added\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tcl_shebang_detection_tclsh() {
|
||||
bat()
|
||||
.arg("--color=always")
|
||||
.arg("--style=plain")
|
||||
.arg("--decorations=always")
|
||||
.arg("regression_tests/issue_3647_tclsh")
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tcl_shebang_detection_wish() {
|
||||
bat()
|
||||
.arg("--color=always")
|
||||
.arg("--style=plain")
|
||||
.arg("--decorations=always")
|
||||
.arg("regression_tests/issue_3647_wish")
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tcl_shebang_detection_expect() {
|
||||
bat()
|
||||
.arg("--color=always")
|
||||
.arg("--style=plain")
|
||||
.arg("--decorations=always")
|
||||
.arg("regression_tests/issue_3647_expect")
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
|
||||
+12
-10
@@ -4,6 +4,7 @@ import itertools
|
||||
import subprocess
|
||||
import pathlib
|
||||
import shutil
|
||||
from typing import Iterable
|
||||
|
||||
|
||||
def generate_snapshots():
|
||||
@@ -19,22 +20,23 @@ def generate_snapshots():
|
||||
|
||||
|
||||
def generate_style_snapshot(style):
|
||||
generate_snapshot(style.replace(",", "_"), "--style={}".format(style))
|
||||
generate_snapshot(style.replace(",", "_"), ["--style={}".format(style)])
|
||||
|
||||
|
||||
def generate_snapshot(name, arguments):
|
||||
command = "cargo run -- --paging=never --color=never --decorations=always "
|
||||
command += "{args} sample.rs > output/{name}.snapshot.txt".format(
|
||||
name=name,
|
||||
args=arguments
|
||||
)
|
||||
def generate_snapshot(name: str, arguments: Iterable[str]):
|
||||
output_file = "output/{name}.snapshot.txt".format(name=name)
|
||||
command = [
|
||||
"cargo", "run", "--", "--paging=never", "--color=never",
|
||||
"--decorations=always", *arguments, "sample.rs"
|
||||
]
|
||||
print("generating snapshot for {}".format(name))
|
||||
subprocess.call(command, shell=True)
|
||||
with open(output_file, "w") as f:
|
||||
subprocess.call(command, stdout=f)
|
||||
|
||||
|
||||
def build_bat():
|
||||
print("building bat")
|
||||
subprocess.call("cargo build", cwd="../..", shell=True)
|
||||
subprocess.call(["cargo", "build"], cwd="../..")
|
||||
|
||||
|
||||
def prepare_output_dir():
|
||||
@@ -49,7 +51,7 @@ def modify_sample_file():
|
||||
|
||||
def undo_sample_file_modification():
|
||||
print("undoing sample.rs modifications")
|
||||
subprocess.call("git checkout -- sample.rs", shell=True)
|
||||
subprocess.call(["git", "checkout", "--", "sample.rs"])
|
||||
|
||||
|
||||
build_bat()
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
[38;2;249;38;114mIDENTIFICATION DIVISION[0m[38;2;248;248;242m.[0m
|
||||
[38;2;249;38;114mPROGRAM-ID[0m[38;2;248;248;242m. [0m[38;2;248;248;242mPAYROLL-CALC[0m[38;2;248;248;242m.[0m
|
||||
|
||||
[38;2;249;38;114mDATA DIVISION[0m[38;2;248;248;242m.[0m
|
||||
[38;2;249;38;114mWORKING-STORAGE SECTION[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m01[0m[38;2;248;248;242m [0m[38;2;248;248;242mEMPLOYEE-DETAILS[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m05[0m[38;2;248;248;242m [0m[38;2;248;248;242mEMPLOYEE-NAME[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mPIC X(30).[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m05[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURS-WORKED[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mPIC 99V9[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m05[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURLY-RATE[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mPIC 99V99[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m01[0m[38;2;248;248;242m [0m[38;2;248;248;242mPAY-CALCULATIONS[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m05[0m[38;2;248;248;242m [0m[38;2;248;248;242mGROSS-PAY[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mPIC 9(5)V99.[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m05[0m[38;2;248;248;242m [0m[38;2;248;248;242mOVERTIME-HOURS[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mPIC 99V9[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m05[0m[38;2;248;248;242m [0m[38;2;248;248;242mOVERTIME-PAY[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mPIC 9(5)V99.[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m05[0m[38;2;248;248;242m [0m[38;2;248;248;242mTAX-RATE[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mPIC V99[0m[38;2;248;248;242m [0m[38;2;249;38;114mVALUE[0m[38;2;248;248;242m [0m[38;2;190;132;255m0.10[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m05[0m[38;2;248;248;242m [0m[38;2;248;248;242mTAX-AMOUNT[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mPIC 9(5)V99.[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m05[0m[38;2;248;248;242m [0m[38;2;248;248;242mNET-PAY[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mPIC 9(5)V99.[0m
|
||||
|
||||
[38;2;249;38;114mPROCEDURE DIVISION[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242mMAIN-LOGIC[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116m--- COBOL Payroll Calculator ---[0m[38;2;230;219;116m"[0m[38;2;248;248;242m.[0m
|
||||
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mEnter Employee Name: [0m[38;2;230;219;116m"[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mACCEPT[0m[38;2;248;248;242m [0m[38;2;248;248;242mEMPLOYEE-NAME[0m[38;2;248;248;242m.[0m
|
||||
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mEnter Hours Worked (e.g., 40.5): [0m[38;2;230;219;116m"[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mACCEPT[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURS-WORKED[0m[38;2;248;248;242m.[0m
|
||||
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mEnter Hourly Rate (e.g., 15.75): [0m[38;2;230;219;116m"[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mACCEPT[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURLY-RATE[0m[38;2;248;248;242m.[0m
|
||||
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mPERFORM[0m[38;2;248;248;242m [0m[38;2;248;248;242mCALCULATE-GROSS-PAY[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mPERFORM[0m[38;2;248;248;242m [0m[38;2;248;248;242mCALCULATE-TAX[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mPERFORM[0m[38;2;248;248;242m [0m[38;2;248;248;242mCALCULATE-NET-PAY[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mPERFORM[0m[38;2;248;248;242m [0m[38;2;248;248;242mDISPLAY-RESULTS[0m[38;2;248;248;242m.[0m
|
||||
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mSTOP RUN[0m[38;2;248;248;242m.[0m
|
||||
|
||||
[38;2;248;248;242mCALCULATE-GROSS-PAY[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mIF[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURS-WORKED[0m[38;2;248;248;242m [0m[38;2;249;38;114m>[0m[38;2;248;248;242m [0m[38;2;190;132;255m40[0m[38;2;248;248;242m [0m[38;2;249;38;114mTHEN[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mCOMPUTE[0m[38;2;248;248;242m [0m[38;2;248;248;242mOVERTIME-HOURS[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURS-WORKED[0m[38;2;248;248;242m [0m[38;2;249;38;114m-[0m[38;2;248;248;242m [0m[38;2;190;132;255m40[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mCOMPUTE[0m[38;2;248;248;242m [0m[38;2;248;248;242mOVERTIME-PAY[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242mOVERTIME-HOURS[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURLY-RATE[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;248;248;242m [0m[38;2;190;132;255m1.5[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mCOMPUTE[0m[38;2;248;248;242m [0m[38;2;248;248;242mGROSS-PAY[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m ([0m[38;2;190;132;255m40[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURLY-RATE[0m[38;2;248;248;242m) [0m[38;2;249;38;114m+[0m[38;2;248;248;242m [0m[38;2;248;248;242mOVERTIME-PAY[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mELSE[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mCOMPUTE[0m[38;2;248;248;242m [0m[38;2;248;248;242mGROSS-PAY[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURS-WORKED[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURLY-RATE[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mEND-IF[0m[38;2;248;248;242m.[0m
|
||||
|
||||
[38;2;248;248;242mCALCULATE-TAX[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mCOMPUTE[0m[38;2;248;248;242m [0m[38;2;248;248;242mTAX-AMOUNT[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242mGROSS-PAY[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;248;248;242m [0m[38;2;248;248;242mTAX-RATE[0m[38;2;248;248;242m.[0m
|
||||
|
||||
[38;2;248;248;242mCALCULATE-NET-PAY[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mCOMPUTE[0m[38;2;248;248;242m [0m[38;2;248;248;242mNET-PAY[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242mGROSS-PAY[0m[38;2;248;248;242m [0m[38;2;249;38;114m-[0m[38;2;248;248;242m [0m[38;2;248;248;242mTAX-AMOUNT[0m[38;2;248;248;242m.[0m
|
||||
|
||||
[38;2;248;248;242mDISPLAY-RESULTS[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116m----------------------------------[0m[38;2;230;219;116m"[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mEmployee Name: [0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;248;248;242mEMPLOYEE-NAME[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mHours Worked: [0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURS-WORKED[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mHourly Rate: [0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURLY-RATE[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mGross Pay: [0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;248;248;242mGROSS-PAY[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mTax (10%): [0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;248;248;242mTAX-AMOUNT[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mNet Pay: [0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;248;248;242mNET-PAY[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116m----------------------------------[0m[38;2;230;219;116m"[0m[38;2;248;248;242m.[0m
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
[38;2;249;38;114mIDENTIFICATION DIVISION[0m[38;2;248;248;242m.[0m
|
||||
[38;2;249;38;114mPROGRAM-ID[0m[38;2;248;248;242m. [0m[38;2;248;248;242mPAYROLL-CALC[0m[38;2;248;248;242m.[0m
|
||||
|
||||
[38;2;249;38;114mDATA DIVISION[0m[38;2;248;248;242m.[0m
|
||||
[38;2;249;38;114mWORKING-STORAGE SECTION[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m01[0m[38;2;248;248;242m [0m[38;2;248;248;242mEMPLOYEE-DETAILS[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m05[0m[38;2;248;248;242m [0m[38;2;248;248;242mEMPLOYEE-NAME[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mPIC X(30).[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m05[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURS-WORKED[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mPIC 99V9[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m05[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURLY-RATE[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mPIC 99V99[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m01[0m[38;2;248;248;242m [0m[38;2;248;248;242mPAY-CALCULATIONS[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m05[0m[38;2;248;248;242m [0m[38;2;248;248;242mGROSS-PAY[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mPIC 9(5)V99.[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m05[0m[38;2;248;248;242m [0m[38;2;248;248;242mOVERTIME-HOURS[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mPIC 99V9[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m05[0m[38;2;248;248;242m [0m[38;2;248;248;242mOVERTIME-PAY[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mPIC 9(5)V99.[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m05[0m[38;2;248;248;242m [0m[38;2;248;248;242mTAX-RATE[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mPIC V99[0m[38;2;248;248;242m [0m[38;2;249;38;114mVALUE[0m[38;2;248;248;242m [0m[38;2;190;132;255m0.10[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m05[0m[38;2;248;248;242m [0m[38;2;248;248;242mTAX-AMOUNT[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mPIC 9(5)V99.[0m
|
||||
[38;2;248;248;242m [0m[38;2;190;132;255m05[0m[38;2;248;248;242m [0m[38;2;248;248;242mNET-PAY[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mPIC 9(5)V99.[0m
|
||||
|
||||
[38;2;249;38;114mPROCEDURE DIVISION[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242mMAIN-LOGIC[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116m--- COBOL Payroll Calculator ---[0m[38;2;230;219;116m"[0m[38;2;248;248;242m.[0m
|
||||
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mEnter Employee Name: [0m[38;2;230;219;116m"[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mACCEPT[0m[38;2;248;248;242m [0m[38;2;248;248;242mEMPLOYEE-NAME[0m[38;2;248;248;242m.[0m
|
||||
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mEnter Hours Worked (e.g., 40.5): [0m[38;2;230;219;116m"[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mACCEPT[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURS-WORKED[0m[38;2;248;248;242m.[0m
|
||||
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mEnter Hourly Rate (e.g., 15.75): [0m[38;2;230;219;116m"[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mACCEPT[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURLY-RATE[0m[38;2;248;248;242m.[0m
|
||||
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mPERFORM[0m[38;2;248;248;242m [0m[38;2;248;248;242mCALCULATE-GROSS-PAY[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mPERFORM[0m[38;2;248;248;242m [0m[38;2;248;248;242mCALCULATE-TAX[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mPERFORM[0m[38;2;248;248;242m [0m[38;2;248;248;242mCALCULATE-NET-PAY[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mPERFORM[0m[38;2;248;248;242m [0m[38;2;248;248;242mDISPLAY-RESULTS[0m[38;2;248;248;242m.[0m
|
||||
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mSTOP RUN[0m[38;2;248;248;242m.[0m
|
||||
|
||||
[38;2;248;248;242mCALCULATE-GROSS-PAY[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mIF[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURS-WORKED[0m[38;2;248;248;242m [0m[38;2;249;38;114m>[0m[38;2;248;248;242m [0m[38;2;190;132;255m40[0m[38;2;248;248;242m [0m[38;2;249;38;114mTHEN[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mCOMPUTE[0m[38;2;248;248;242m [0m[38;2;248;248;242mOVERTIME-HOURS[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURS-WORKED[0m[38;2;248;248;242m [0m[38;2;249;38;114m-[0m[38;2;248;248;242m [0m[38;2;190;132;255m40[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mCOMPUTE[0m[38;2;248;248;242m [0m[38;2;248;248;242mOVERTIME-PAY[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242mOVERTIME-HOURS[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURLY-RATE[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;248;248;242m [0m[38;2;190;132;255m1.5[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mCOMPUTE[0m[38;2;248;248;242m [0m[38;2;248;248;242mGROSS-PAY[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m ([0m[38;2;190;132;255m40[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURLY-RATE[0m[38;2;248;248;242m) [0m[38;2;249;38;114m+[0m[38;2;248;248;242m [0m[38;2;248;248;242mOVERTIME-PAY[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mELSE[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mCOMPUTE[0m[38;2;248;248;242m [0m[38;2;248;248;242mGROSS-PAY[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURS-WORKED[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURLY-RATE[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mEND-IF[0m[38;2;248;248;242m.[0m
|
||||
|
||||
[38;2;248;248;242mCALCULATE-TAX[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mCOMPUTE[0m[38;2;248;248;242m [0m[38;2;248;248;242mTAX-AMOUNT[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242mGROSS-PAY[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;248;248;242m [0m[38;2;248;248;242mTAX-RATE[0m[38;2;248;248;242m.[0m
|
||||
|
||||
[38;2;248;248;242mCALCULATE-NET-PAY[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mCOMPUTE[0m[38;2;248;248;242m [0m[38;2;248;248;242mNET-PAY[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242mGROSS-PAY[0m[38;2;248;248;242m [0m[38;2;249;38;114m-[0m[38;2;248;248;242m [0m[38;2;248;248;242mTAX-AMOUNT[0m[38;2;248;248;242m.[0m
|
||||
|
||||
[38;2;248;248;242mDISPLAY-RESULTS[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116m----------------------------------[0m[38;2;230;219;116m"[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mEmployee Name: [0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;248;248;242mEMPLOYEE-NAME[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mHours Worked: [0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURS-WORKED[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mHourly Rate: [0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;248;248;242mHOURLY-RATE[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mGross Pay: [0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;248;248;242mGROSS-PAY[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mTax (10%): [0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;248;248;242mTAX-AMOUNT[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mNet Pay: [0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;248;248;242mNET-PAY[0m[38;2;248;248;242m.[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mDISPLAY[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116m----------------------------------[0m[38;2;230;219;116m"[0m[38;2;248;248;242m.[0m
|
||||
+52
-52
@@ -1,85 +1,85 @@
|
||||
[38;2;249;38;114mimport[0m[38;2;248;248;242m kotlin.math.*[0m
|
||||
[38;2;249;38;114mimport[0m[38;2;248;248;242m [0m[38;2;248;248;242mkotlin[0m[38;2;248;248;242m.[0m[38;2;248;248;242mmath[0m[38;2;248;248;242m.[0m[38;2;249;38;114m*[0m
|
||||
|
||||
[38;2;249;38;114mdata[0m[38;2;248;248;242m [0m[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[38;2;166;226;46mExample[0m[38;2;248;248;242m([0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mname[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mString[0m[38;2;248;248;242m,[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mnumbers[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mList[0m[38;2;248;248;242m<[0m[3;38;2;102;217;239mInt[0m[38;2;248;248;242m?>[0m
|
||||
[38;2;249;38;114mdata[0m[38;2;248;248;242m [0m[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[4;38;2;102;217;239mExample[0m[38;2;248;248;242m([0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mname[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mString[0m[38;2;248;248;242m,[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mnumbers[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mList[0m[38;2;248;248;242m<[0m[3;38;2;166;226;46mInt[0m[38;2;249;38;114m?[0m[38;2;248;248;242m>[0m
|
||||
[38;2;248;248;242m)[0m
|
||||
|
||||
[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46minterface[0m[38;2;248;248;242m [0m[38;2;166;226;46mJokeInterface[0m[38;2;248;248;242m {[0m
|
||||
[38;2;248;248;242m [0m[38;2;166;226;46mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46misFunny[0m[38;2;248;248;242m()[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mBoolean[0m
|
||||
[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46minterface[0m[38;2;248;248;242m [0m[38;2;248;248;242mJokeInterface[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46misFunny[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mBoolean[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;249;38;114mabstract[0m[38;2;248;248;242m [0m[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[38;2;166;226;46mAbstractJoke[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;4;38;2;166;226;46mJokeInterface[0m[38;2;248;248;242m {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46misFunny[0m[38;2;248;248;242m() [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255mfalse[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mabstract[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46mcontent[0m[38;2;248;248;242m()[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mString[0m
|
||||
[38;2;249;38;114mabstract[0m[38;2;248;248;242m [0m[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[4;38;2;102;217;239mAbstractJoke[0m[38;2;248;248;242m [0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mJokeInterface[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46misFunny[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255mfalse[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mabstract[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46mcontent[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mString[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[38;2;166;226;46mJoke[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;4;38;2;166;226;46mAbstractJoke[0m[38;2;248;248;242m() {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46misFunny[0m[38;2;248;248;242m()[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mBoolean[0m[38;2;248;248;242m {[0m
|
||||
[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[4;38;2;102;217;239mJoke[0m[38;2;248;248;242m [0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mAbstractJoke[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46misFunny[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mBoolean[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;190;132;255mtrue[0m
|
||||
[38;2;248;248;242m }[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46mcontent[0m[38;2;248;248;242m()[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mString[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mcontent of joke here, haha[0m[38;2;230;219;116m"[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46mcontent[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mString[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mcontent of joke here, haha[0m[38;2;230;219;116m"[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[38;2;166;226;46mDelegatedJoke[0m[38;2;248;248;242m([0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mjoke[0m[38;2;249;38;114m:[0m[38;2;248;248;242m Joke) [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;4;38;2;166;226;46mJokeInterface[0m[38;2;248;248;242m [0m[3;4;38;2;166;226;46mby[0m[38;2;248;248;242m [0m[3;4;38;2;166;226;46mjoke[0m[38;2;248;248;242m {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[38;2;166;226;46mnumber[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mLong[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m123L[0m
|
||||
[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[4;38;2;102;217;239mDelegatedJoke[0m[38;2;248;248;242m([0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mjoke[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mJoke[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mJokeInterface[0m[38;2;248;248;242m [0m[38;2;249;38;114mby[0m[38;2;248;248;242m [0m[38;2;255;255;255mjoke[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[38;2;255;255;255mnumber[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mLong[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m123L[0m
|
||||
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mcompanion [0m[38;2;249;38;114mobject[0m[38;2;248;248;242m {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mconst[0m[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[38;2;166;226;46msomeConstant[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116msome constant text[0m[38;2;230;219;116m"[0m
|
||||
[38;2;248;248;242m }[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mcompanion[0m[38;2;248;248;242m [0m[38;2;249;38;114mobject[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mconst[0m[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[38;2;255;255;255msomeConstant[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116msome constant text[0m[38;2;230;219;116m"[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;249;38;114mobject[0m[38;2;248;248;242m [0m[38;2;166;226;46mSomeSingleton[0m
|
||||
[38;2;249;38;114mobject[0m[38;2;248;248;242m [0m[4;38;2;102;217;239mSomeSingleton[0m
|
||||
|
||||
[38;2;249;38;114msealed[0m[38;2;248;248;242m [0m[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[38;2;166;226;46mShape[0m[38;2;248;248;242m {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mabstract[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46marea[0m[38;2;248;248;242m()[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mDouble[0m
|
||||
[38;2;249;38;114msealed[0m[38;2;248;248;242m [0m[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[4;38;2;102;217;239mShape[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mabstract[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46marea[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mDouble[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;249;38;114mdata[0m[38;2;248;248;242m [0m[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[38;2;166;226;46mSquare[0m[38;2;248;248;242m([0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[3;38;2;253;151;31msideLength[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mDouble[0m[38;2;248;248;242m) [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;4;38;2;166;226;46mShape[0m[38;2;248;248;242m() {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46marea[0m[38;2;248;248;242m()[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mDouble[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m sideLength[0m[38;2;249;38;114m.[0m[38;2;248;248;242mpow([0m[38;2;190;132;255m2[0m[38;2;248;248;242m)[0m
|
||||
[38;2;249;38;114mdata[0m[38;2;248;248;242m [0m[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[4;38;2;102;217;239mSquare[0m[38;2;248;248;242m([0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[3;38;2;253;151;31msideLength[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mDouble[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mShape[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46marea[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mDouble[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;255;255;255msideLength[0m[38;2;248;248;242m.[0m[38;2;248;248;242mpow[0m[38;2;248;248;242m([0m[38;2;190;132;255m2[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;249;38;114mobject[0m[38;2;248;248;242m [0m[38;2;166;226;46mPoint[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;4;38;2;166;226;46mShape[0m[38;2;248;248;242m() {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46marea[0m[38;2;248;248;242m() [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;249;38;114m.[0m[38;2;190;132;255m0[0m
|
||||
[38;2;249;38;114mobject[0m[38;2;248;248;242m [0m[4;38;2;102;217;239mPoint[0m[38;2;248;248;242m [0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mShape[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46marea[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m.0[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[38;2;166;226;46mCircle[0m[38;2;248;248;242m([0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mradius[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mDouble[0m[38;2;248;248;242m) [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;4;38;2;166;226;46mShape[0m[38;2;248;248;242m() {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46marea[0m[38;2;248;248;242m()[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mDouble[0m[38;2;248;248;242m {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;190;132;255mPI[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;248;248;242m radius [0m[38;2;249;38;114m*[0m[38;2;248;248;242m radius[0m
|
||||
[38;2;248;248;242m }[0m
|
||||
[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[4;38;2;102;217;239mCircle[0m[38;2;248;248;242m([0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mradius[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mDouble[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mShape[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46marea[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mDouble[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;255;255;255mPI[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;248;248;242m [0m[38;2;255;255;255mradius[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;248;248;242m [0m[38;2;255;255;255mradius[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;249;38;114mfun[0m[38;2;248;248;242m String.[0m[38;2;166;226;46mextensionMethod[0m[38;2;248;248;242m() [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mtest[0m[38;2;230;219;116m"[0m
|
||||
[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mString[0m[38;2;248;248;242m.[0m[38;2;166;226;46mextensionMethod[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mtest[0m[38;2;230;219;116m"[0m
|
||||
|
||||
[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46mmain[0m[38;2;248;248;242m() {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[38;2;166;226;46mname[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"""[0m
|
||||
[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46mmain[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[38;2;255;255;255mname[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"""[0m
|
||||
[38;2;230;219;116m multiline[0m
|
||||
[38;2;230;219;116m string[0m
|
||||
[38;2;230;219;116m [0m
|
||||
[38;2;230;219;116m some numbers: 123123 42[0m
|
||||
[38;2;230;219;116m [0m[38;2;230;219;116m"""[0m[38;2;249;38;114m.[0m[38;2;248;248;242mtrimIndent()[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[38;2;166;226;46mexample[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m Example(name [0m[38;2;249;38;114m=[0m[38;2;248;248;242m name, numbers [0m[38;2;249;38;114m=[0m[38;2;248;248;242m listOf([0m[38;2;190;132;255m512[0m[38;2;248;248;242m, [0m[38;2;190;132;255m42[0m[38;2;248;248;242m, [0m[38;2;190;132;255mnull[0m[38;2;248;248;242m, [0m[38;2;249;38;114m-[0m[38;2;190;132;255m1[0m[38;2;248;248;242m))[0m
|
||||
[38;2;230;219;116m [0m[38;2;230;219;116m"""[0m[38;2;248;248;242m.[0m[38;2;248;248;242mtrimIndent[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[38;2;255;255;255mexample[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242mExample[0m[38;2;248;248;242m([0m[38;2;255;255;255mname[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;255;255;255mname[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;255;255;255mnumbers[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242mlistOf[0m[38;2;248;248;242m([0m[38;2;190;132;255m512[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m42[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255mnull[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;249;38;114m-[0m[38;2;190;132;255m1[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
|
||||
|
||||
[38;2;248;248;242m example[0m[38;2;249;38;114m.[0m[38;2;248;248;242mnumbers[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114m.[0m[38;2;248;248;242mfilterNotNull()[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114m.[0m[38;2;248;248;242mforEach { println(it) }[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255mexample[0m[38;2;248;248;242m.[0m[38;2;255;255;255mnumbers[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;248;248;242mfilterNotNull[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;248;248;242mforEach[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m [0m[38;2;248;248;242mprintln[0m[38;2;248;248;242m([0m[38;2;255;255;255mit[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;248;248;242m setOf(Joke(), DelegatedJoke(Joke())[0m[38;2;249;38;114m.[0m[38;2;248;248;242mjoke)[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114m.[0m[38;2;248;248;242mfilter(JokeInterface[0m[38;2;249;38;114m::[0m[38;2;248;248;242misFunny)[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114m.[0m[38;2;248;248;242mmap(AbstractJoke[0m[38;2;249;38;114m::[0m[38;2;248;248;242mcontent)[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114m.[0m[38;2;248;248;242mforEachIndexed { index[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mInt[0m[38;2;248;248;242m, joke [0m[38;2;249;38;114m->[0m
|
||||
[38;2;248;248;242m println([0m[38;2;230;219;116m"[0m[38;2;230;219;116mI heard a funny joke(#[0m[3;38;2;253;151;31m${index + 1}[0m[38;2;230;219;116m): [0m[3;38;2;253;151;31m$joke[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m }[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242msetOf[0m[38;2;248;248;242m([0m[38;2;248;248;242mJoke[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;248;248;242mDelegatedJoke[0m[38;2;248;248;242m([0m[38;2;248;248;242mJoke[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m.[0m[38;2;255;255;255mjoke[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;248;248;242mfilter[0m[38;2;248;248;242m([0m[38;2;255;255;255mJokeInterface[0m[38;2;248;248;242m::[0m[38;2;248;248;242misFunny[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;248;248;242mmap[0m[38;2;248;248;242m([0m[38;2;255;255;255mAbstractJoke[0m[38;2;248;248;242m::[0m[38;2;248;248;242mcontent[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;248;248;242mforEachIndexed[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m [0m[38;2;255;255;255mindex[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mInt[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mjoke[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242mprintln[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mI heard a funny joke(#[0m[38;2;248;248;242m${[0m[38;2;255;255;255mindex[0m[38;2;248;248;242m [0m[38;2;249;38;114m+[0m[38;2;248;248;242m [0m[38;2;190;132;255m1[0m[38;2;248;248;242m}[0m[38;2;230;219;116m): [0m[38;2;255;255;255m$joke[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;248;248;242m listOf(Square([0m[38;2;190;132;255m12.3[0m[38;2;248;248;242m), Point, Circle([0m[38;2;190;132;255m5.2[0m[38;2;248;248;242m))[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114m.[0m[38;2;248;248;242massociateWith(Shape[0m[38;2;249;38;114m::[0m[38;2;248;248;242marea)[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114m.[0m[38;2;248;248;242mtoList()[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114m.[0m[38;2;248;248;242msortedBy { it[0m[38;2;249;38;114m.[0m[38;2;248;248;242msecond }[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114m.[0m[38;2;248;248;242mforEach {[0m
|
||||
[38;2;248;248;242m println([0m[38;2;230;219;116m"[0m[3;38;2;253;151;31m${it.first}[0m[38;2;230;219;116m: [0m[3;38;2;253;151;31m${it.second}[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m }[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242mlistOf[0m[38;2;248;248;242m([0m[38;2;248;248;242mSquare[0m[38;2;248;248;242m([0m[38;2;190;132;255m12.3[0m[38;2;248;248;242m)[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;255;255;255mPoint[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;248;248;242mCircle[0m[38;2;248;248;242m([0m[38;2;190;132;255m5.2[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;248;248;242massociateWith[0m[38;2;248;248;242m([0m[38;2;255;255;255mShape[0m[38;2;248;248;242m::[0m[38;2;248;248;242marea[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;248;248;242mtoList[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;248;248;242msortedBy[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m [0m[38;2;255;255;255mit[0m[38;2;248;248;242m.[0m[38;2;255;255;255msecond[0m[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;248;248;242mforEach[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242mprintln[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;248;248;242m${[0m[38;2;255;255;255mit[0m[38;2;248;248;242m.[0m[38;2;255;255;255mfirst[0m[38;2;248;248;242m}[0m[38;2;230;219;116m: [0m[38;2;248;248;242m${[0m[38;2;255;255;255mit[0m[38;2;248;248;242m.[0m[38;2;255;255;255msecond[0m[38;2;248;248;242m}[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;248;248;242m println([0m[38;2;230;219;116m"[0m[38;2;230;219;116msome string[0m[38;2;230;219;116m"[0m[38;2;249;38;114m.[0m[38;2;248;248;242mextensionMethod())[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242mprintln[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116msome string[0m[38;2;230;219;116m"[0m[38;2;248;248;242m.[0m[38;2;248;248;242mextensionMethod[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
|
||||
|
||||
[38;2;248;248;242m require(SomeSingleton[0m[38;2;249;38;114m::[0m[38;2;248;248;242mclass[0m[38;2;249;38;114m.[0m[38;2;248;248;242msimpleName [0m[38;2;249;38;114m==[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mSomeSingletonName[0m[38;2;230;219;116m"[0m[38;2;248;248;242m) { [0m[38;2;230;219;116m"[0m[38;2;230;219;116msomething does not seem right...[0m[38;2;230;219;116m"[0m[38;2;248;248;242m }[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242mrequire[0m[38;2;248;248;242m([0m[38;2;255;255;255mSomeSingleton[0m[38;2;248;248;242m::[0m[38;2;249;38;114mclass[0m[38;2;248;248;242m.[0m[38;2;255;255;255msimpleName[0m[38;2;248;248;242m [0m[38;2;249;38;114m==[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mSomeSingletonName[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116msomething does not seem right...[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
[38;2;117;113;94m#[0m[38;2;117;113;94m!/usr/bin/expect -f[0m
|
||||
[38;2;117;113;94m#[0m[38;2;117;113;94m Expect script detected via expect shebang[0m
|
||||
[38;2;249;38;114mset[0m[38;2;248;248;242m timeout [0m[38;2;190;132;255m30[0m
|
||||
[38;2;248;248;242mspawn[0m[38;2;248;248;242m ssh user@host[0m
|
||||
[38;2;248;248;242mexpect[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mpassword:[0m[38;2;230;219;116m"[0m
|
||||
[38;2;248;248;242msend[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116msecret[0m[38;2;190;132;255m\r[0m[38;2;230;219;116m"[0m
|
||||
[38;2;248;248;242mexpect[0m[38;2;248;248;242m [0m[38;2;249;38;114meof[0m
|
||||
@@ -0,0 +1,7 @@
|
||||
[38;2;117;113;94m#[0m[38;2;117;113;94m!/usr/bin/env tclsh[0m
|
||||
[38;2;117;113;94m#[0m[38;2;117;113;94m Tcl script detected via tclsh shebang[0m
|
||||
[38;2;249;38;114mputs[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mHello from tclsh[0m[38;2;230;219;116m"[0m
|
||||
[38;2;249;38;114mset[0m[38;2;248;248;242m x [0m[38;2;190;132;255m42[0m
|
||||
[38;2;249;38;114mif[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;255;255;255m$[0m[38;2;255;255;255mx[0m[38;2;248;248;242m [0m[38;2;249;38;114m>[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m}[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mputs[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mpositive[0m[38;2;230;219;116m"[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
@@ -0,0 +1,5 @@
|
||||
[38;2;117;113;94m#[0m[38;2;117;113;94m!/usr/bin/wish[0m
|
||||
[38;2;117;113;94m#[0m[38;2;117;113;94m Tk script detected via wish shebang[0m
|
||||
[38;2;249;38;114mpackage[0m[38;2;248;248;242m require Tk[0m
|
||||
[38;2;248;248;242mbutton[0m[38;2;248;248;242m .b [0m[38;2;249;38;114m-[0m[38;2;248;248;242mtext [0m[38;2;230;219;116m"[0m[38;2;230;219;116mClick[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;249;38;114m-[0m[38;2;248;248;242mcommand [0m[38;2;248;248;242m{[0m[38;2;249;38;114mputs[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mclicked[0m[38;2;230;219;116m"[0m[38;2;248;248;242m}[0m
|
||||
[38;2;248;248;242mpack[0m[38;2;248;248;242m .b[0m
|
||||
@@ -0,0 +1,7 @@
|
||||
[38;2;255;255;255m<[0m[38;2;249;38;114mSolution[0m[38;2;255;255;255m>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[38;2;249;38;114mFolder[0m[38;2;248;248;242m [0m[38;2;166;226;46mName[0m[38;2;248;248;242m=[0m[38;2;230;219;116m"[0m[38;2;230;219;116m/Build/[0m[38;2;230;219;116m"[0m[38;2;255;255;255m>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[38;2;249;38;114mFile[0m[38;2;248;248;242m [0m[38;2;166;226;46mPath[0m[38;2;248;248;242m=[0m[38;2;230;219;116m"[0m[38;2;230;219;116mDirectory.Build.props[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;255;255;255m/>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[38;2;249;38;114mFile[0m[38;2;248;248;242m [0m[38;2;166;226;46mPath[0m[38;2;248;248;242m=[0m[38;2;230;219;116m"[0m[38;2;230;219;116mprojectname.targets[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;255;255;255m/>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m</[0m[38;2;249;38;114mFolder[0m[38;2;255;255;255m>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[38;2;249;38;114mProject[0m[38;2;248;248;242m [0m[38;2;166;226;46mPath[0m[38;2;248;248;242m=[0m[38;2;230;219;116m"[0m[38;2;230;219;116mconsole.csproj[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;255;255;255m/>[0m
|
||||
[38;2;255;255;255m</[0m[38;2;249;38;114mSolution[0m[38;2;255;255;255m>[0m
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. PAYROLL-CALC.
|
||||
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 EMPLOYEE-DETAILS.
|
||||
05 EMPLOYEE-NAME PIC X(30).
|
||||
05 HOURS-WORKED PIC 99V9.
|
||||
05 HOURLY-RATE PIC 99V99.
|
||||
01 PAY-CALCULATIONS.
|
||||
05 GROSS-PAY PIC 9(5)V99.
|
||||
05 OVERTIME-HOURS PIC 99V9.
|
||||
05 OVERTIME-PAY PIC 9(5)V99.
|
||||
05 TAX-RATE PIC V99 VALUE 0.10.
|
||||
05 TAX-AMOUNT PIC 9(5)V99.
|
||||
05 NET-PAY PIC 9(5)V99.
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
MAIN-LOGIC.
|
||||
DISPLAY "--- COBOL Payroll Calculator ---".
|
||||
|
||||
DISPLAY "Enter Employee Name: ".
|
||||
ACCEPT EMPLOYEE-NAME.
|
||||
|
||||
DISPLAY "Enter Hours Worked (e.g., 40.5): ".
|
||||
ACCEPT HOURS-WORKED.
|
||||
|
||||
DISPLAY "Enter Hourly Rate (e.g., 15.75): ".
|
||||
ACCEPT HOURLY-RATE.
|
||||
|
||||
PERFORM CALCULATE-GROSS-PAY.
|
||||
PERFORM CALCULATE-TAX.
|
||||
PERFORM CALCULATE-NET-PAY.
|
||||
PERFORM DISPLAY-RESULTS.
|
||||
|
||||
STOP RUN.
|
||||
|
||||
CALCULATE-GROSS-PAY.
|
||||
IF HOURS-WORKED > 40 THEN
|
||||
COMPUTE OVERTIME-HOURS = HOURS-WORKED - 40
|
||||
COMPUTE OVERTIME-PAY = OVERTIME-HOURS * HOURLY-RATE * 1.5
|
||||
COMPUTE GROSS-PAY = (40 * HOURLY-RATE) + OVERTIME-PAY
|
||||
ELSE
|
||||
COMPUTE GROSS-PAY = HOURS-WORKED * HOURLY-RATE
|
||||
END-IF.
|
||||
|
||||
CALCULATE-TAX.
|
||||
COMPUTE TAX-AMOUNT = GROSS-PAY * TAX-RATE.
|
||||
|
||||
CALCULATE-NET-PAY.
|
||||
COMPUTE NET-PAY = GROSS-PAY - TAX-AMOUNT.
|
||||
|
||||
DISPLAY-RESULTS.
|
||||
DISPLAY "----------------------------------".
|
||||
DISPLAY "Employee Name: " EMPLOYEE-NAME.
|
||||
DISPLAY "Hours Worked: " HOURS-WORKED.
|
||||
DISPLAY "Hourly Rate: " HOURLY-RATE.
|
||||
DISPLAY "Gross Pay: " GROSS-PAY.
|
||||
DISPLAY "Tax (10%): " TAX-AMOUNT.
|
||||
DISPLAY "Net Pay: " NET-PAY.
|
||||
DISPLAY "----------------------------------".
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. PAYROLL-CALC.
|
||||
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 EMPLOYEE-DETAILS.
|
||||
05 EMPLOYEE-NAME PIC X(30).
|
||||
05 HOURS-WORKED PIC 99V9.
|
||||
05 HOURLY-RATE PIC 99V99.
|
||||
01 PAY-CALCULATIONS.
|
||||
05 GROSS-PAY PIC 9(5)V99.
|
||||
05 OVERTIME-HOURS PIC 99V9.
|
||||
05 OVERTIME-PAY PIC 9(5)V99.
|
||||
05 TAX-RATE PIC V99 VALUE 0.10.
|
||||
05 TAX-AMOUNT PIC 9(5)V99.
|
||||
05 NET-PAY PIC 9(5)V99.
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
MAIN-LOGIC.
|
||||
DISPLAY "--- COBOL Payroll Calculator ---".
|
||||
|
||||
DISPLAY "Enter Employee Name: ".
|
||||
ACCEPT EMPLOYEE-NAME.
|
||||
|
||||
DISPLAY "Enter Hours Worked (e.g., 40.5): ".
|
||||
ACCEPT HOURS-WORKED.
|
||||
|
||||
DISPLAY "Enter Hourly Rate (e.g., 15.75): ".
|
||||
ACCEPT HOURLY-RATE.
|
||||
|
||||
PERFORM CALCULATE-GROSS-PAY.
|
||||
PERFORM CALCULATE-TAX.
|
||||
PERFORM CALCULATE-NET-PAY.
|
||||
PERFORM DISPLAY-RESULTS.
|
||||
|
||||
STOP RUN.
|
||||
|
||||
CALCULATE-GROSS-PAY.
|
||||
IF HOURS-WORKED > 40 THEN
|
||||
COMPUTE OVERTIME-HOURS = HOURS-WORKED - 40
|
||||
COMPUTE OVERTIME-PAY = OVERTIME-HOURS * HOURLY-RATE * 1.5
|
||||
COMPUTE GROSS-PAY = (40 * HOURLY-RATE) + OVERTIME-PAY
|
||||
ELSE
|
||||
COMPUTE GROSS-PAY = HOURS-WORKED * HOURLY-RATE
|
||||
END-IF.
|
||||
|
||||
CALCULATE-TAX.
|
||||
COMPUTE TAX-AMOUNT = GROSS-PAY * TAX-RATE.
|
||||
|
||||
CALCULATE-NET-PAY.
|
||||
COMPUTE NET-PAY = GROSS-PAY - TAX-AMOUNT.
|
||||
|
||||
DISPLAY-RESULTS.
|
||||
DISPLAY "----------------------------------".
|
||||
DISPLAY "Employee Name: " EMPLOYEE-NAME.
|
||||
DISPLAY "Hours Worked: " HOURS-WORKED.
|
||||
DISPLAY "Hourly Rate: " HOURLY-RATE.
|
||||
DISPLAY "Gross Pay: " GROSS-PAY.
|
||||
DISPLAY "Tax (10%): " TAX-AMOUNT.
|
||||
DISPLAY "Net Pay: " NET-PAY.
|
||||
DISPLAY "----------------------------------".
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/expect -f
|
||||
# Expect script detected via expect shebang
|
||||
set timeout 30
|
||||
spawn ssh user@host
|
||||
expect "password:"
|
||||
send "secret\r"
|
||||
expect eof
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env tclsh
|
||||
# Tcl script detected via tclsh shebang
|
||||
puts "Hello from tclsh"
|
||||
set x 42
|
||||
if {$x > 0} {
|
||||
puts "positive"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/wish
|
||||
# Tk script detected via wish shebang
|
||||
package require Tk
|
||||
button .b -text "Click" -command {puts "clicked"}
|
||||
pack .b
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<Solution>
|
||||
<Folder Name="/Build/">
|
||||
<File Path="Directory.Build.props" />
|
||||
<File Path="projectname.targets" />
|
||||
</Folder>
|
||||
<Project Path="console.csproj" />
|
||||
</Solution>
|
||||
Reference in New Issue
Block a user