id stringlengths 20 30 | source stringclasses 1
value | chunk_index int64 0 520k | token_count int32 154 512 | content stringlengths 185 57.5k |
|---|---|---|---|---|
rust_dataset_chunk_1700 | rust_dataset.txt | 1,700 | 512 | if !self.requested_redraw {
self.requested_redraw = true;
self.window.request_redraw();
}
}
#[inline]
pub fn set_mouse_cursor(&mut self, cursor: CursorIcon) {
if cursor != self.current_mouse_cursor {
self.current_mouse_cursor = cursor;
... |
rust_dataset_chunk_1701 | rust_dataset.txt | 1,701 | 512 | ations != Decorations::None)
.with_window_icon(icon.as_ref().ok().cloned())
.with_taskbar_icon(icon.ok())
}
#[cfg(target_os = "macos")]
pub fn get_platform_window(
_: &Identity,
window_config: &WindowConfig,
tabbing_id: &Option<String>,
) -> WindowAttribu... |
rust_dataset_chunk_1702 | rust_dataset.txt | 1,702 | 512 | to the window.
///
/// Should be called right before presenting to the window with e.g. `eglSwapBuffers`.
pub fn pre_present_notify(&self) {
self.window.pre_present_notify();
}
pub fn set_theme(&self, theme: Option<Theme>) {
self.window.set_theme(theme);
}
#[cfg(target_os ... |
rust_dataset_chunk_1703 | rust_dataset.txt | 1,703 | 512 | some compositors don't like excluding too much and try to render popup at the
// bottom right corner of the provided area, so exclude just the full-width char to not
// obscure the cursor and not render popup at the end of the window.
let width = size.cell_width() as f64 * 2.;
let heigh... |
rust_dataset_chunk_1704 | rust_dataset.txt | 1,704 | 512 | use_srgb_color_space(window: &WinitWindow) {
let view = match window.window_handle().unwrap().as_raw() {
RawWindowHandle::AppKit(handle) => {
assert!(MainThreadMarker::new().is_some());
unsafe { handle.ns_view.cast::<NSView>().as_ref() }
},
_ => return,
};
v... |
rust_dataset_chunk_1705 | rust_dataset.txt | 1,705 | 512 | _terminal::term::search::{Match, RegexSearch};
use alacritty_terminal::term::{self, ClipboardType, Term, TermMode};
use alacritty_terminal::vte::ansi::NamedColor;
#[cfg(unix)]
use crate::cli::{IpcConfig, ParsedOptions};
use crate::cli::{Options as CliOptions, WindowOptions};
use crate::clipboard::Clipboard;
use crate:... |
rust_dataset_chunk_1706 | rust_dataset.txt | 1,706 | 512 | _options: CliOptions,
config: Rc<UiConfig>,
}
impl Processor {
/// Create a new event processor.
pub fn new(
config: UiConfig,
cli_options: CliOptions,
event_loop: &EventLoop<Event>,
) -> Processor {
let proxy = event_loop.create_proxy();
let scheduler = Schedule... |
rust_dataset_chunk_1707 | rust_dataset.txt | 1,707 | 512 | config with CLI/IPC options.
let mut config_overrides = options.config_overrides();
#[cfg(unix)]
config_overrides.extend_from_slice(&self.global_ipc_options);
let mut config = self.config.clone();
config = config_overrides.override_config_rc(config);
let window_context ... |
rust_dataset_chunk_1708 | rust_dataset.txt | 1,708 | 512 | fn window_event(
&mut self,
_event_loop: &ActiveEventLoop,
window_id: WindowId,
event: WindowEvent,
) {
if self.config.debug.print_events {
info!(target: LOG_TARGET_WINIT, "{event:?}");
}
// Ignore all events we do not care about.
if S... |
rust_dataset_chunk_1709 | rust_dataset.txt | 1,709 | 512 | .
let config = match self.windows.iter().find(|(id, _)| window_id == Some(*id)) {
Some((_, window_context)) => window_context.config(),
None => &self.global_ipc_options.override_config_rc(self.config.clone()),
};
// Convert config ... |
rust_dataset_chunk_1710 | rust_dataset.txt | 1,710 | 512 | = self.create_window(event_loop, options) {
error!("Could not open window: {err:?}");
}
},
// Shutdown all windows.
#[cfg(unix)]
(EventType::Shutdown, _) => event_loop.exit(),
// Process events affecting all windows.
... |
rust_dataset_chunk_1711 | rust_dataset.txt | 1,711 | 512 | mut self.scheduler,
WinitEvent::UserEvent(Event::new(payload, *window_id)),
);
}
},
};
}
fn about_to_wait(&mut self, event_loop: &ActiveEventLoop) {
if self.config.debug.print_events {
info!(target: LOG_TARGET_W... |
rust_dataset_chunk_1712 | rust_dataset.txt | 1,712 | 512 | : Event) -> Self {
WinitEvent::UserEvent(event)
}
}
/// Alacritty events.
#[derive(Debug, Clone)]
pub enum EventType {
Terminal(TerminalEvent),
ConfigReload(PathBuf),
Message(Message),
Scroll(Scroll),
CreateWindow(WindowOptions),
#[cfg(unix)]
IpcConfig(IpcConfig),
#[cfg(unix... |
rust_dataset_chunk_1713 | rust_dataset.txt | 1,713 | 512 | regex_mut(&mut self) -> Option<&mut String> {
self.history_index.and_then(move |index| self.history.get_mut(index))
}
}
impl Default for SearchState {
fn default() -> Self {
Self {
direction: Direction::Right,
display_offset_delta: Default::default(),
focuse... |
rust_dataset_chunk_1714 | rust_dataset.txt | 1,714 | 512 | u8]>>>(&self, val: B) {
self.notifier.notify(val);
}
/// Request a redraw.
#[inline]
fn mark_dirty(&mut self) {
*self.dirty = true;
}
#[inline]
fn size_info(&self) -> SizeInfo {
self.display.size_info
}
fn scroll(&mut self, scroll: Scroll) {
let old... |
rust_dataset_chunk_1715 | rust_dataset.txt | 1,715 | 512 | _empty)
}
fn clear_selection(&mut self) {
// Clear the selection on the terminal.
let selection = self.terminal.selection.take();
// Mark the terminal as dirty when selection wasn't empty.
*self.dirty |= selection.is_some_and(|s| !s.is_empty());
}
fn update_selection(&m... |
rust_dataset_chunk_1716 | rust_dataset.txt | 1,716 | 512 | mut self) -> &mut Modifiers {
self.modifiers
}
#[inline]
fn window(&mut self) -> &mut Window {
&mut self.display.window
}
#[inline]
fn display(&mut self) -> &mut Display {
self.display
}
#[inline]
fn terminal(&self) -> &Term<T> {
self.terminal
}... |
rust_dataset_chunk_1717 | rust_dataset.txt | 1,717 | 512 | (not(windows))]
let result = spawn_daemon(program, args, self.master_fd, self.shell_pid);
#[cfg(windows)]
let result = spawn_daemon(program, args);
match result {
Ok(_) => debug!("Launched {program} with args {args:?}"),
Err(err) => warn!("Unable to launch {progr... |
rust_dataset_chunk_1718 | rust_dataset.txt | 1,718 | 512 | )) - 1;
let viewport_bottom = viewport_top + self.terminal.bottommost_line();
let last_column = self.terminal.last_column();
self.search_state.origin = match direction {
Direction::Right => Point::new(viewport_top, Column(0)),
Direction::Left => Point:... |
rust_dataset_chunk_1719 | rust_dataset.txt | 1,719 | 512 | contains(TermMode::VI) {
self.cancel_search();
return;
}
// Force unlimited search if the previous one was interrupted.
let timer_id = TimerId::new(Topic::DelayedSearch, self.display.window.id());
if self.scheduler.scheduled(timer_id) {
self.goto_matc... |
rust_dataset_chunk_1720 | rust_dataset.txt | 1,720 | 512 | ));
self.update_search();
}
}
/// Go to the previous regex in the search history.
#[inline]
fn search_history_previous(&mut self) {
let index = match &mut self.search_state.history_index {
None => return,
Some(index) if *index + 1 >= self.search_state... |
rust_dataset_chunk_1721 | rust_dataset.txt | 1,721 | 512 | .scroll_to_point(new_origin);
let new_display_offset = self.terminal.grid().display_offset() as i32;
self.search_state.display_offset_delta = new_display_offset - old_display_offset;
// Store origin and scroll back to the match.
self.terminal.scroll_display(Scroll::Delta(-self.search_st... |
rust_dataset_chunk_1722 | rust_dataset.txt | 1,722 | 512 | (&mut self, hint: &HintMatch) {
if self.mouse.block_hint_launcher {
return;
}
let hint_bounds = hint.bounds();
let text = match hint.text(self.terminal) {
Some(text) => text,
None => return,
};
match &hint.action() {
// La... |
rust_dataset_chunk_1723 | rust_dataset.txt | 1,723 | 512 | (selection) => selection,
None => return,
};
selection.ty = selection_type;
self.update_selection(point, cell_side);
// Move vi mode cursor to mouse click position.
if self.terminal().mode().contains(TermMode::VI) && !self.search_active() {
self.terminal... |
rust_dataset_chunk_1724 | rust_dataset.txt | 1,724 | 512 | self, text: &str, bracketed: bool) {
if self.search_active() {
for c in text.chars() {
self.search_input(c);
}
} else if self.inline_search_state.char_pending {
self.inline_search_input(text);
} else if bracketed && self.terminal().mode().cont... |
rust_dataset_chunk_1725 | rust_dataset.txt | 1,725 | 512 | mark_fully_damaged();
}
} else {
self.clear_selection();
}
if self.search_active() {
self.cancel_search();
}
// We don't want IME in Vi mode.
self.window().set_ime_inhibitor(ImeInhibitor::VI, !was_in_vi_mode);
self.terminal.t... |
rust_dataset_chunk_1726 | rust_dataset.txt | 1,726 | 512 | <'a, N, T> {
fn update_search(&mut self) {
let regex = match self.search_state.regex() {
Some(regex) => regex,
None => return,
};
// Hide cursor while typing into the search bar.
if self.config.mouse.hide_when_typing {
self.display.window.set_mous... |
rust_dataset_chunk_1727 | rust_dataset.txt | 1,727 | 512 | Side::Left, limit) {
Some(regex_match) => {
let old_offset = self.terminal.grid().display_offset() as i32;
if self.terminal.mode().contains(TermMode::VI) {
// Move vi cursor to the start of the match.
self.terminal.vi_goto_point(*rege... |
rust_dataset_chunk_1728 | rust_dataset.txt | 1,728 | 512 | if vi_mode {
cursor_style = self.config.cursor.vi_mode_style.unwrap_or(cursor_style);
}
// Check terminal cursor style.
let terminal_blinking = self.terminal.cursor_style().blinking;
let mut blinking = cursor_style.blinking_override().unwrap_or(terminal_blinking);
... |
rust_dataset_chunk_1729 | rust_dataset.txt | 1,729 | 512 | let point = match direction {
Direction::Right => self.terminal.inline_search_right(vi_point, search_character),
Direction::Left => self.terminal.inline_search_left(vi_point, search_character),
};
// Jump to point if there's a match.
if let Ok(mut point) = point {
... |
rust_dataset_chunk_1730 | rust_dataset.txt | 1,730 | 512 | .location.x - self.slots.1.location.x;
let delta_y = self.slots.0.location.y - self.slots.1.location.y;
delta_x.hypot(delta_y) as f32
}
}
/// State of the mouse.
#[derive(Debug)]
pub struct Mouse {
pub left_button_state: ElementState,
pub middle_button_state: ElementState,
pub right_but... |
rust_dataset_chunk_1731 | rust_dataset.txt | 1,731 | 512 | derive(Default, Debug)]
pub struct AccumulatedScroll {
/// Scroll we should perform along `x` axis.
pub x: f64,
/// Scroll we should perform along `y` axis.
pub y: f64,
}
impl input::Processor<EventProxy, ActionContext<'_, Notifier, EventProxy>> {
/// Handle events from winit.
pub fn handle_ev... |
rust_dataset_chunk_1732 | rust_dataset.txt | 1,732 | 512 | self.ctx.display.visual_bell.ring();
// Execute bell command.
if let Some(bell_command) = &self.ctx.config.bell.command {
if self
.ctx
.prev_bell_cmd
... |
rust_dataset_chunk_1733 | rust_dataset.txt | 1,733 | 512 | terminal.exit();
},
WindowEvent::ScaleFactorChanged { scale_factor, .. } => {
let old_scale_factor =
mem::replace(&mut self.ctx.window().scale_factor, scale_factor);
let display_update_pending = &mut sel... |
rust_dataset_chunk_1734 | rust_dataset.txt | 1,734 | 512 | !is_focused);
},
WindowEvent::Occluded(occluded) => {
*self.ctx.occluded = occluded;
},
WindowEvent::DroppedFile(path) => {
let path: String = path.to_string_lossy().into();
... |
rust_dataset_chunk_1735 | rust_dataset.txt | 1,735 | 512 | DeviceEvent { .. }
| WinitEvent::LoopExiting
| WinitEvent::Resumed
| WinitEvent::MemoryWarning
| WinitEvent::AboutToWait => (),
}
}
}
#[derive(Debug, Clone)]
pub struct EventProxy {
proxy: EventLoopProxy<Event>,
window_id: WindowId,
}
impl EventProxy... |
rust_dataset_chunk_1736 | rust_dataset.txt | 1,736 | 512 | ime_inhibitor(ImeInhibitor::VI, false);
}
self.key_release(key, mode, mods);
return;
}
let text = key.text_with_all_modifiers().unwrap_or_default();
// All key bindings are disabled while a hint is being selected.
if self.ctx.display().hint_state.act... |
rust_dataset_chunk_1737 | rust_dataset.txt | 1,737 | 512 | macos")]
let alt_send_esc = {
let option_as_alt = self.ctx.config().window.option_as_alt();
self.ctx.modifiers().state().alt_key()
&& (option_as_alt == OptionAsAlt::Both
|| (option_as_alt == OptionAsAlt::OnlyLeft
&& self.ctx.mod... |
rust_dataset_chunk_1738 | rust_dataset.txt | 1,738 | 512 | }
}
/// Attempt to find a binding and execute its action.
///
/// The provided mode, mods, and key must match what is allowed by a binding
/// for its action to be executed.
fn process_key_bindings(&mut self, key: &KeyEvent) -> bool {
let mode = BindingMode::new(self.ctx.terminal().mod... |
rust_dataset_chunk_1739 | rust_dataset.txt | 1,739 | 512 | .
for i in 0..self.ctx.config().key_bindings().len() {
let binding = &self.ctx.config().key_bindings()[i];
if let Some(action) = binding_action(binding) {
action.execute(&mut self.ctx);
}
}
// Trigger key bindings for hints.
for i in 0... |
rust_dataset_chunk_1740 | rust_dataset.txt | 1,740 | 512 | inside the bindings.
#[inline(never)]
fn build_sequence(key: KeyEvent, mods: ModifiersState, mode: TermMode) -> Vec<u8> {
let mut modifiers = mods.into();
let kitty_seq = mode.intersects(
TermMode::REPORT_ALL_KEYS_AS_ESC
| TermMode::DISAMBIGUATE_ESC_CODES
| TermMode::REPORT_EVE... |
rust_dataset_chunk_1741 | rust_dataset.txt | 1,741 | 512 | format!(";{codepoint}"));
}
for codepoint in codepoints {
payload.push_str(&format!(":{codepoint}"));
}
}
payload.push(terminator.encode_esc_sequence());
payload.into_bytes()
}
/// Helper to build escape sequence payloads from [`KeyEvent`].
pub struct SequenceBuilder {... |
rust_dataset_chunk_1742 | rust_dataset.txt | 1,742 | 512 | Fallback when need to report text, but we don't have any key associated with this
// text.
Some(SequenceBase::new("0".into(), SequenceTerminator::Kitty))
} else {
None
}
}
/// Try building from numpad key.
///
/// `None` is returned when the key is n... |
rust_dataset_chunk_1743 | rust_dataset.txt | 1,743 | 512 | try_build_named_kitty(&self, key: &KeyEvent) -> Option<SequenceBase> {
let named = match key.logical_key {
Key::Named(named) if self.kitty_seq => named,
_ => return None,
};
let (base, terminator) = match named {
// F3 in kitty protocol diverges from alacrit... |
rust_dataset_chunk_1744 | rust_dataset.txt | 1,744 | 512 | ::Kitty),
NamedKey::F35 => ("57398", SequenceTerminator::Kitty),
NamedKey::ScrollLock => ("57359", SequenceTerminator::Kitty),
NamedKey::PrintScreen => ("57361", SequenceTerminator::Kitty),
NamedKey::Pause => ("57362", SequenceTerminator::Kitty),
NamedKey::Con... |
rust_dataset_chunk_1745 | rust_dataset.txt | 1,745 | 512 | ::PageDown => ("6", SequenceTerminator::Normal('~')),
NamedKey::Insert => ("2", SequenceTerminator::Normal('~')),
NamedKey::Delete => ("3", SequenceTerminator::Normal('~')),
NamedKey::Home => (one_based, SequenceTerminator::Normal('H')),
NamedKey::End => (one_based, Seque... |
rust_dataset_chunk_1746 | rust_dataset.txt | 1,746 | 512 | ator::Normal('~')),
NamedKey::F20 => ("34", SequenceTerminator::Normal('~')),
_ => return None,
};
Some(SequenceBase::new(base.into(), terminator))
}
/// Try building escape from control characters (e.g. Enter) and modifiers.
fn try_build_control_char_or_mod(
... |
rust_dataset_chunk_1747 | rust_dataset.txt | 1,747 | 512 | // itself apply the state based on keysyms and not the _actual_ modifiers
// state, which is how kitty is doing so and what is suggested in such case.
let press = key.state.is_pressed();
match named {
NamedKey::Shift => mods.set(SequenceModifiers::SHIFT, press),
N... |
rust_dataset_chunk_1748 | rust_dataset.txt | 1,748 | 512 | From<ModifiersState> for SequenceModifiers {
fn from(mods: ModifiersState) -> Self {
let mut modifiers = Self::empty();
modifiers.set(Self::SHIFT, mods.shift_key());
modifiers.set(Self::ALT, mods.alt_key());
modifiers.set(Self::CONTROL, mods.control_key());
modifiers.set(Sel... |
rust_dataset_chunk_1749 | rust_dataset.txt | 1,749 | 512 | , Point, Side};
use alacritty_terminal::selection::SelectionType;
use alacritty_terminal::term::search::Match;
use alacritty_terminal::term::{ClipboardType, Term, TermMode};
use alacritty_terminal::vi_mode::ViMotion;
use alacritty_terminal::vte::ansi::{ClearMode, Handler};
use crate::clipboard::Clipboard;
#[cfg(target... |
rust_dataset_chunk_1750 | rust_dataset.txt | 1,750 | 512 | : SelectionType, _point: Point, _side: Side) {}
fn toggle_selection(&mut self, _ty: SelectionType, _point: Point, _side: Side) {}
fn update_selection(&mut self, _point: Point, _side: Side) {}
fn clear_selection(&mut self) {}
fn selection_is_empty(&self) -> bool;
fn mouse_mut(&mut self) -> &mut Mouse... |
rust_dataset_chunk_1751 | rust_dataset.txt | 1,751 | 512 | -> Direction;
fn search_active(&self) -> bool;
fn on_typing_start(&mut self) {}
fn toggle_vi_mode(&mut self) {}
fn inline_search_state(&mut self) -> &mut InlineSearchState;
fn start_inline_search(&mut self, _direction: Direction, _stop_short: bool) {}
fn inline_search_next(&mut self) {}
fn ... |
rust_dataset_chunk_1752 | rust_dataset.txt | 1,752 | 512 | contains(TermMode::VI) =>
{
debug!("Ignoring {action:?}: Vi mode inactive");
},
Action::ViMotion(motion) => {
ctx.on_typing_start();
ctx.terminal_mut().vi_motion(*motion);
ctx.mark_dirty();
},
Act... |
rust_dataset_chunk_1753 | rust_dataset.txt | 1,753 | 512 | }
},
Action::Vi(ViAction::SearchStart) => {
let terminal = ctx.terminal();
let origin = terminal.vi_mode_cursor.point.sub(terminal, Boundary::None, 1);
if let Some(regex_match) = ctx.search_next(origin, Direction::Left, Side::Left) {
... |
rust_dataset_chunk_1754 | rust_dataset.txt | 1,754 | 512 | self {
Action::Vi(ViAction::SemanticSearchForward) => Direction::Right,
_ => Direction::Left,
};
ctx.start_seeded_search(direction, seed_text);
}
},
action @ Action::Search(_) if !ctx.search_... |
rust_dataset_chunk_1755 | rust_dataset.txt | 1,755 | 512 | cfg(not(target_os = "macos"))]
Action::Hide => ctx.window().set_visible(false),
Action::Minimize => ctx.window().set_minimized(true),
Action::Quit => {
ctx.window().hold = false;
ctx.terminal_mut().exit();
},
Action::IncreaseFon... |
rust_dataset_chunk_1756 | rust_dataset.txt | 1,756 | 512 | .vi_motion(ViMotion::FirstOccupied);
term.vi_motion(ViMotion::FirstOccupied);
ctx.mark_dirty();
},
Action::ClearHistory => ctx.terminal_mut().clear_screen(ClearMode::Saved),
Action::ClearLogNotice => ctx.pop_message(),
#[cfg(not(target_os =... |
rust_dataset_chunk_1757 | rust_dataset.txt | 1,757 | 512 | }
}
impl<T: EventListener, A: ActionContext<T>> Processor<T, A> {
pub fn new(ctx: A) -> Self {
Self { ctx, _phantom: Default::default() }
}
#[inline]
pub fn mouse_moved(&mut self, position: PhysicalPosition<f64>) {
let size_info = self.ctx.size_info();
let (x, y) = position.i... |
rust_dataset_chunk_1758 | rust_dataset.txt | 1,758 | 512 | .ctx.terminal().mode().intersects(TermMode::MOUSE_MOTION | TermMode::MOUSE_DRAG)
{
if lmb_pressed {
self.mouse_report(32, ElementState::Pressed);
} else if self.ctx.mouse().middle_button_state == ElementState::Pressed {
self.mouse_report(33, ElementState::... |
rust_dataset_chunk_1759 | rust_dataset.txt | 1,759 | 512 | , state);
} else if let ElementState::Released = state {
self.normal_mouse_report(point, 3 + mods);
} else {
self.normal_mouse_report(point, button + mods);
}
}
fn normal_mouse_report(&mut self, point: Point, button: u8) {
let Point { line, column } = poi... |
rust_dataset_chunk_1760 | rust_dataset.txt | 1,760 | 512 | => 2,
// Can't properly report more than three buttons..
MouseButton::Back | MouseButton::Forward | MouseButton::Other(_) => return,
};
self.mouse_report(code, ElementState::Pressed);
} else {
// Calculate time since the last click to handle ... |
rust_dataset_chunk_1761 | rust_dataset.txt | 1,761 | 512 | => (),
};
// Move vi mode cursor to mouse click position.
if self.ctx.terminal().mode().contains(TermMode::VI) && !self.ctx.search_active() {
self.ctx.terminal_mut().vi_mode_cursor.point = point;
self.ctx.mark_dirty();
}
}
fn on_mouse_release(&mut self,... |
rust_dataset_chunk_1762 | rust_dataset.txt | 1,762 | 512 | // (cosine is larger that 0.9) we consider this scrolling as horizontal.
if lpos.x.abs() / lpos.x.hypot(lpos.y) > 0.9 {
lpos.y = 0.;
} else {
lpos.x = 0.;
}
... |
rust_dataset_chunk_1763 | rust_dataset.txt | 1,763 | 512 | | TermMode::ALTERNATE_SCROLL)
&& !self.ctx.modifiers().state().shift_key()
{
// The chars here are the same as for the respective arrow keys.
let line_cmd = if is_scroll_up { b'A' } else { b'B' };
let column_cmd = if new_scroll_x_px > 0. { b'D' } else { b'C' };
... |
rust_dataset_chunk_1764 | rust_dataset.txt | 1,764 | 512 | TouchPurpose::None => TouchPurpose::Tap(touch),
TouchPurpose::Tap(start) => TouchPurpose::Zoom(TouchZoom::new((start, touch))),
TouchPurpose::ZoomPendingSlot(slot) => {
TouchPurpose::Zoom(TouchZoom::new((slot, touch)))
},
TouchPurpose::Zoom(zoom) => {
... |
rust_dataset_chunk_1765 | rust_dataset.txt | 1,765 | 512 | ., delta_y, 1.0);
},
TouchPurpose::Select(_) => self.mouse_moved(touch.location),
TouchPurpose::ZoomPendingSlot(_) | TouchPurpose::Invalid(_) => (),
}
}
/// Handle end of touch input.
pub fn on_touch_end(&mut self, touch: TouchEvent) {
// Finalize the tou... |
rust_dataset_chunk_1766 | rust_dataset.txt | 1,766 | 512 | true;
// Update mouse state and check for URL change.
let mouse_state = self.cursor_state();
self.ctx.window().set_mouse_cursor(mouse_state);
}
pub fn mouse_input(&mut self, state: ElementState, button: MouseButton) {
match button {
MouseButton::Left => self.ctx.mo... |
rust_dataset_chunk_1767 | rust_dataset.txt | 1,767 | 512 | shift.
let fallback_allowed = mouse_mode && mods.contains(ModifiersState::SHIFT);
let mut match_found: bool = false;
for binding in &mouse_bindings {
// Don't trigger normal bindings in mouse mode unless Shift is pressed.
if binding.is_triggered_by(mode, mods, &event) &... |
rust_dataset_chunk_1768 | rust_dataset.txt | 1,768 | 512 | (mouse_state) = self.message_bar_cursor_state() {
mouse_state
} else if self.ctx.display().highlighted_hint.as_ref().is_some_and(hint_highlighted) {
CursorIcon::Pointer
} else if !self.ctx.modifiers().state().shift_key() && self.ctx.mouse_mode() {
CursorIcon::Default
... |
rust_dataset_chunk_1769 | rust_dataset.txt | 1,769 | 512 | message_bar::MessageBuffer;
const KEY: Key<&'static str> = Key::Character("0");
struct MockEventProxy;
impl EventListener for MockEventProxy {}
struct ActionContext<'a, T> {
pub terminal: &'a mut Term<T>,
pub size_info: &'a SizeInfo,
pub mouse: &'a mut Mouse,
pub clipb... |
rust_dataset_chunk_1770 | rust_dataset.txt | 1,770 | 512 | Message> {
self.message_buffer.message()
}
fn config(&self) -> &UiConfig {
self.config
}
fn clipboard_mut(&mut self) -> &mut Clipboard {
self.clipboard
}
#[cfg(target_os = "macos")]
fn event_loop(&self) -> &ActiveEventLoop {
... |
rust_dataset_chunk_1771 | rust_dataset.txt | 1,771 | 512 | }
}
macro_rules! test_process_binding {
{
name: $name:ident,
binding: $binding:expr,
triggers: $triggers:expr,
mode: $mode:expr,
mods: $mods:expr,
} => {
#[test]
fn $name() {
if $triggers {
... |
rust_dataset_chunk_1772 | rust_dataset.txt | 1,772 | 512 | _id: WindowId::dummy(),
},
end_state: ClickState::DoubleClick,
input_delay: Duration::ZERO,
}
test_clickstate! {
name: double_click_failed,
initial_state: ClickState::Click,
initial_button: MouseButton::Left,
input: WinitEvent::WindowEvent {
e... |
rust_dataset_chunk_1773 | rust_dataset.txt | 1,773 | 512 | ::empty() },
triggers: true,
mode: BindingMode::empty(),
mods: ModifiersState::SHIFT,
}
test_process_binding! {
name: process_binding_nomode_nomod_require_shift,
binding: Binding { trigger: KEY, mods: ModifiersState::SHIFT, action: Action::from("\x1b[1;2D"), mode: Bindin... |
rust_dataset_chunk_1774 | rust_dataset.txt | 1,774 | 512 | ifiersState::empty(), action: Action::from("\x1bOD"), mode: BindingMode::APP_CURSOR, notmode: BindingMode::empty() },
triggers: true,
mode: BindingMode::APP_CURSOR | BindingMode::APP_KEYPAD,
mods: ModifiersState::empty(),
}
test_process_binding! {
name: process_binding_fail_with... |
rust_dataset_chunk_1775 | rust_dataset.txt | 1,775 | 512 | _log_targets() -> &'static [String] {
static EXTRA_LOG_TARGETS: OnceLock<Vec<String>> = OnceLock::new();
EXTRA_LOG_TARGETS.get_or_init(|| {
env::var(ALACRITTY_EXTRA_LOG_TARGETS_ENV)
.map_or(Vec::new(), |targets| targets.split(';').map(ToString::to_string).collect())
})
}
/// List of ta... |
rust_dataset_chunk_1776 | rust_dataset.txt | 1,776 | 512 | #[cfg(windows)]
let env_var = format!("%{}%", ALACRITTY_LOG_ENV);
let message = format!(
"[{}] {}\nSee log at {} ({})",
record.level(),
record.args(),
logfile_path,
env_var,
);
let mut message = Message::new(message, message_... |
rust_dataset_chunk_1777 | rust_dataset.txt | 1,777 | 512 | lines = record.args().to_string();
for line in lines.split('\n') {
let line = format!("{}\n{:width$}", line, "", width = alignment);
message.push_str(&line);
}
// Drop extra trailing alignment.
message.truncate(message.len() - alignment);
message
}
/// Check if log messages from a... |
rust_dataset_chunk_1778 | rust_dataset.txt | 1,778 | 512 | impl Write for OnDemandLogFile {
fn write(&mut self, buf: &[u8]) -> Result<usize, io::Error> {
self.file()?.write(buf)
}
fn flush(&mut self) -> Result<(), io::Error> {
self.file()?.flush()
}
}
--- FILE: alacritty/alacritty/src/macos/locale.rs ---
#![allow(clippy::let_unit_value)]
use... |
rust_dataset_chunk_1779 | rust_dataset.txt | 1,779 | 512 | macOS. This is not a valid locale, so we use
// `languageCode` and `countryCode`, if they're available (macOS 10.12+):
//
// https://developer.apple.com/documentation/foundation/nslocale/1416263-localeidentifier?language=objc
// https://developer.apple.com/documentation/foundation/nslocale/1643060-coun... |
rust_dataset_chunk_1780 | rust_dataset.txt | 1,780 | 512 | self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Error::InvalidSize => None,
Error::Io(err) => err.source(),
Error::IntoString(err) => err.source(),
}
}
}
impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
... |
rust_dataset_chunk_1781 | rust_dataset.txt | 1,781 | 512 | , Copy, Clone)]
pub struct fsid {
pub val: [i32; 2usize],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vinfo_stat {
pub vst_dev: u32,
pub vst_mode: u16,
pub vst_nlink: u16,
pub vst_ino: u64,
pub vst_uid: uid_t,
pub vst_gid: gid_t,
... |
rust_dataset_chunk_1782 | rust_dataset.txt | 1,782 | 512 | env::current_dir().ok());
}
}
--- FILE: alacritty/alacritty/src/main.rs ---
//! Alacritty - The GPU Enhanced Terminal.
#![warn(rust_2018_idioms, future_incompatible)]
#![deny(clippy::all, clippy::if_not_else, clippy::enum_glob_use)]
#![cfg_attr(clippy, deny(warnings))]
// With the default subsystem, 'console', ... |
rust_dataset_chunk_1783 | rust_dataset.txt | 1,783 | 512 | ::macos::locale;
#[cfg(unix)]
use crate::polling::{IoListener, ipc};
fn main() -> Result<(), Box<dyn Error>> {
#[cfg(windows)]
panic::attach_handler();
// When linked with the windows subsystem windows won't automatically attach
// to the console of the parent process, so we do it explicitly. This fai... |
rust_dataset_chunk_1784 | rust_dataset.txt | 1,784 | 512 | and runs the main display loop.
fn alacritty(mut options: Options) -> Result<(), Box<dyn Error>> {
// Setup winit event loop.
let window_event_loop = EventLoop::<Event>::with_user_event().build()?;
// Initialize the logger as soon as possible as to capture output from other subsystems.
let log_file = ... |
rust_dataset_chunk_1785 | rust_dataset.txt | 1,785 | 512 | {
#[cfg(unix)]
socket_path,
log_file: log_cleanup,
};
// Event processor.
let mut processor = Processor::new(config, options, &window_event_loop);
// Start event loop and block until shutdown.
let result = processor.run(window_event_loop);
// `Processor` must be dropp... |
rust_dataset_chunk_1786 | rust_dataset.txt | 1,786 | 512 | the message.
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
pub enum MessageType {
/// A message represents an error.
Error,
/// A message represents a warning.
Warning,
}
impl Message {
/// Create a new message.
pub fn new(text: String, ty: MessageType) -> Message {
Message { text, ty,... |
rust_dataset_chunk_1787 | rust_dataset.txt | 1,787 | 512 | = lines.iter_mut().last() {
*line = Self::pad_text(TRUNCATED_MESSAGE.into(), num_cols);
}
}
}
// Append close button to first line.
if button_len <= num_cols {
if let Some(line) = lines.get_mut(0) {
line.truncate(num_c... |
rust_dataset_chunk_1788 | rust_dataset.txt | 1,788 | 512 | self.messages.push_back(message);
}
/// Check whether the message is already queued in the message bar.
#[inline]
pub fn is_queued(&self, message: &Message) -> bool {
self.messages.contains(message)
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::display::SizeInfo;
#[t... |
rust_dataset_chunk_1789 | rust_dataset.txt | 1,789 | 512 | let mut message_buffer = MessageBuffer::default();
message_buffer.push(Message::new(input.into(), MessageType::Error));
let size = SizeInfo::new(6., 0., 1., 1., 0., 0., false);
let lines = message_buffer.message().unwrap().text(&size);
assert_eq!(lines.len(), 0);
}
#[test]
... |
rust_dataset_chunk_1790 | rust_dataset.txt | 1,790 | 512 | ));
let size = SizeInfo::new(5., 10., 1., 1., 0., 0., false);
let lines = message_buffer.message().unwrap().text(&size);
assert_eq!(lines, vec![String::from("t [X]"), String::from("est ")]);
}
#[test]
fn remove_target() {
let mut message_buffer = MessageBuffer::default();... |
rust_dataset_chunk_1791 | rust_dataset.txt | 1,791 | 512 | ., false);
let lines = message_buffer.message().unwrap().text(&size);
assert_eq!(lines, vec![
String::from("ab [X]"),
String::from("c 👩 d "),
String::from("fgh ")
]);
}
#[test]
fn strip_whitespace_at_linebreak() {
let input = "\n0 ... |
rust_dataset_chunk_1792 | rust_dataset.txt | 1,792 | 512 | None => {
eprintln!("No configuration file found");
std::process::exit(1);
},
};
// If we're doing a wet run, perform a dry run first for safety.
if !options.dry_run {
#[allow(clippy::redundant_clone)]
let mut options = options.clone();
options.silen... |
rust_dataset_chunk_1793 | rust_dataset.txt | 1,793 | 512 | oml(toml)?;
// Recursively migrate imports.
migrate_imports(options, path, &mut migrated, recursion_limit)?;
// Write migrated TOML file.
write_results(options, path, &migrated.to_string())?;
Ok(Migration::Toml(path))
}
/// Migrate TOML config to the latest version.
fn migrate_toml(toml: String)... |
rust_dataset_chunk_1794 | rust_dataset.txt | 1,794 | 512 | depth".into());
}
// Migrate each import.
for import in imports.into_iter().filter_map(|item| item.as_str()) {
let normalized_path = config::normalize_import(path, import);
if !normalized_path.exists() {
if options.dry_run {
println!("Skipping migration for non... |
rust_dataset_chunk_1795 | rust_dataset.txt | 1,795 | 512 | // Create missing parent tables.
target_item = target_item[element].or_insert(toml_edit::table());
}
}
Ok(())
}
/// Write migrated TOML to its target location.
fn write_results<P>(options: &MigrateOptions, path: P, toml: &str) -> Result<(), String>
where
P: AsRef<Path> + De... |
rust_dataset_chunk_1796 | rust_dataset.txt | 1,796 | 512 | mod tests {
use super::*;
#[test]
fn move_values() {
let input = r#"
# This is a root_value.
#
# Use it with care.
root_value = 3
[table]
table_value = 5
[preexisting]
not_moved = 9
"#;
let mut document = input.parse::<DocumentMut>().unwrap();
move_value(&mut document, &... |
rust_dataset_chunk_1797 | rust_dataset.txt | 1,797 | 512 | without recursing through imports.
toml = migrate_toml(toml)?.to_string();
// Write migrated TOML config.
write_results(options, &new_path, &toml)?;
Ok(new_path)
}
/// Migrate the imports of a config.
fn migrate_imports(
options: &MigrateOptions,
config: &mut Value,
base_path: &Path,
... |
rust_dataset_chunk_1798 | rust_dataset.txt | 1,798 | 512 | panic_info);
unsafe {
MessageBoxW(
ptr::null_mut(),
win32_string(&msg).as_ptr(),
win32_string("Alacritty: Runtime Error").as_ptr(),
MB_ICONERROR | MB_OK | MB_SETFOREGROUND | MB_TASKMODAL,
);
}
}));
}
--- FILE:... |
rust_dataset_chunk_1799 | rust_dataset.txt | 1,799 | 512 | .data) {
Ok(0) | Err(_) => return Ok(()),
Ok(_) => (),
};
let message: SocketMessage = match serde_json::from_str(&self.data) {
Ok(message) => message,
Err(err) => {
warn!("Failed to parse IPC message: {err}");
return Ok(()... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.