mirror of
https://github.com/alacritty/alacritty.git
synced 2025-02-17 15:57:08 -05:00
parent
6018590d7b
commit
75b0005619
5 changed files with 33 additions and 5 deletions
|
@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Escape sequence to set underline color (`CSI 58 : 2 : Ps : Ps : Ps m`/`CSI 58 : 5 : Ps m`)
|
||||
- Escape sequence to reset underline color (`CSI 59 m`)
|
||||
- Vi mode keybinding (z) to center view around vi mode cursor
|
||||
- Accept hexadecimal values starting with `0x` for `--embed`
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use std::cmp::max;
|
||||
use std::os::raw::c_ulong;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[cfg(unix)]
|
||||
|
@ -25,7 +26,7 @@ pub struct Options {
|
|||
#[clap(long)]
|
||||
pub ref_test: bool,
|
||||
|
||||
/// Defines the X11 window ID (as a decimal integer) to embed Alacritty within.
|
||||
/// X11 window ID to embed Alacritty within (decimal or hexadecimal with "0x" prefix).
|
||||
#[clap(long)]
|
||||
pub embed: Option<String>,
|
||||
|
||||
|
@ -100,7 +101,7 @@ impl Options {
|
|||
}
|
||||
|
||||
config.window.dynamic_title &= self.window_options.window_identity.title.is_none();
|
||||
config.window.embed = self.embed.as_ref().and_then(|embed| embed.parse().ok());
|
||||
config.window.embed = self.embed.as_ref().and_then(|embed| parse_hex_or_decimal(embed));
|
||||
config.debug.print_events |= self.print_events;
|
||||
config.debug.log_level = max(config.debug.log_level, self.log_level());
|
||||
config.debug.ref_test |= self.ref_test;
|
||||
|
@ -173,6 +174,14 @@ fn parse_class(input: &str) -> Result<Class, String> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Convert to hex if possible, else decimal
|
||||
fn parse_hex_or_decimal(input: &str) -> Option<c_ulong> {
|
||||
input
|
||||
.strip_prefix("0x")
|
||||
.and_then(|value| c_ulong::from_str_radix(value, 16).ok())
|
||||
.or_else(|| input.parse().ok())
|
||||
}
|
||||
|
||||
/// Terminal specific cli options which can be passed to new windows via IPC.
|
||||
#[derive(Serialize, Deserialize, Args, Default, Debug, Clone, PartialEq, Eq)]
|
||||
pub struct TerminalOptions {
|
||||
|
@ -393,6 +402,24 @@ mod tests {
|
|||
assert!(class.is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valid_decimal() {
|
||||
let value = parse_hex_or_decimal("10485773");
|
||||
assert_eq!(value, Some(10485773));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valid_hex_to_decimal() {
|
||||
let value = parse_hex_or_decimal("0xa0000d");
|
||||
assert_eq!(value, Some(10485773));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_hex_to_decimal() {
|
||||
let value = parse_hex_or_decimal("0xa0xx0d");
|
||||
assert_eq!(value, None);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[test]
|
||||
fn completions() {
|
||||
|
|
|
@ -52,7 +52,7 @@ Alacritty looks for the configuration file at the following paths:
|
|||
On Windows, the configuration file is located at %APPDATA%\\alacritty\\alacritty.yml.
|
||||
.TP
|
||||
\fB\-\-embed\fR <parent>
|
||||
Defines the X11 window ID (as a decimal integer) to embed Alacritty within
|
||||
X11 window ID to embed Alacritty within (decimal or hexadecimal with "0x" prefix)
|
||||
.TP
|
||||
\fB\-o\fR, \fB\-\-option\fR <option>...
|
||||
Override configuration file options [example: cursor.style=Beam]
|
||||
|
|
|
@ -15,7 +15,7 @@ _alacritty() {
|
|||
|
||||
local context curcontext="$curcontext" state line
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'--embed=[Defines the X11 window ID (as a decimal integer) to embed Alacritty within]:EMBED: ' \
|
||||
'--embed=[X11 window ID to embed Alacritty within (decimal or hexadecimal with "0x" prefix)]:EMBED: ' \
|
||||
'--config-file=[Specify alternative configuration file \[default: $XDG_CONFIG_HOME/alacritty/alacritty.yml\]]:CONFIG_FILE:_files' \
|
||||
'--socket=[Path for IPC socket creation]:SOCKET:_files' \
|
||||
'*-o+[Override configuration file options \[example: cursor.style=Beam\]]:OPTION: ' \
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
complete -c alacritty -n "__fish_use_subcommand" -l embed -d 'Defines the X11 window ID (as a decimal integer) to embed Alacritty within' -r
|
||||
complete -c alacritty -n "__fish_use_subcommand" -l embed -d 'X11 window ID to embed Alacritty within (decimal or hexadecimal with "0x" prefix)' -r
|
||||
complete -c alacritty -n "__fish_use_subcommand" -l config-file -d 'Specify alternative configuration file [default: $XDG_CONFIG_HOME/alacritty/alacritty.yml]' -r -F
|
||||
complete -c alacritty -n "__fish_use_subcommand" -l socket -d 'Path for IPC socket creation' -r -F
|
||||
complete -c alacritty -n "__fish_use_subcommand" -s o -l option -d 'Override configuration file options [example: cursor.style=Beam]' -r
|
||||
|
|
Loading…
Add table
Reference in a new issue