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_510500
rust_dataset.txt
510,500
512
) => { choices .iter() .map(|choice| choice.chars().count().max(6)) .max() .unwrap_or(6) + 6 }, ArgKind::Bool => 0, ...
rust_dataset_chunk_510501
rust_dataset.txt
510,501
512
Args { spec, .. } => spec.name.chars().count(), _ => 0, } } pub fn is_editing_args(&self) -> bool { matches!(self.stage, Stage::Args { .. }) } fn label_column(&self) -> usize { self.label_width .unwrap_or(0) .max(self.title.chars().count() + 2)...
rust_dataset_chunk_510502
rust_dataset.txt
510,502
512
("Apply").accent_brackets()); group.add(BACK_BUTTON, Button::new("Back").accent_brackets()); group.focus_first(); self.stage = Stage::Args { spec, editing, group, error: None, label_width, }; } fn arg_values(spec: &Actio...
rust_dataset_chunk_510503
rust_dataset.txt
510,503
512
self.returned_to_list = true; self.scroll.follow(); } else { self.open_args(spec, vec![], None); } } fn activate_row(&mut self, row: usize) -> PickerResponse { if row < self.actions.len() { let (spec, values) = parse_action_for(&self.action...
rust_dataset_chunk_510504
rust_dataset.txt
510,504
512
let focused_text = group .focused_key() .map(|focused| group.text_input(focused).is_some()) .unwrap_or(false); if !dropdown_open && (is_plain(key, BareKey::Down) || is_plain(key, BareKey::Up)) { if is_plain(k...
rust_dataset_chunk_510505
rust_dataset.txt
510,505
512
.selected, self.selected - 1); self.selected -= 1; } else if is_delete_key(key) && self.selected < self.actions.len() { self.actions.remove(self.selected); self.selected = self.selected.min(self.row_count() - 1); } else if typed(key, 'a') { self.open_choos...
rust_dataset_chunk_510506
rust_dataset.txt
510,506
512
} if self.scroll.hover(&mouse).is_some() || self.scroll.handle_wheel(&mouse).is_some() { return PickerResponse::Pending; } match &mut self.stage { Stage::List => { let Some((line, column)) = is_click(&mouse) else { return Picker...
rust_dataset_chunk_510507
rust_dataset.txt
510,507
512
![ ("<Enter>", "edit / choose"), ("<a>", "add"), ("<Del>", "delete"), ("<Shift ↓↑>", "order"), ]; if self.base_mode.is_some() { hints.push(("<b>", "then back to base mode")); ...
rust_dataset_chunk_510508
rust_dataset.txt
510,508
512
= count.max(1).min(list_space); let gutter = RowScroll::fitted_width(count, list_height, 0, usize::MAX); let button_width = natural_button_width .min(list_width.saturating_sub(gutter + DELETE_WIDTH)) .max(5); if count == 0 { ...
rust_dataset_chunk_510509
rust_dataset.txt
510,509
512
_height; size_button(&mut self.add_button, button_width); self.add_button.set_focused(selected == count); self.add_button.render(list_x, add_y); let buttons_y = bottom.max(add_y + 2); self.done_button.set_focused(selected == count + 1); ...
rust_dataset_chunk_510510
rust_dataset.txt
510,510
512
} }, Stage::Args { spec, group, error, label_width, .. } => { self.scroll.clear(); group.clear_areas(); let label_width = *label_width; ...
rust_dataset_chunk_510511
rust_dataset.txt
510,511
512
{ if let Stage::Args { group, .. } = &mut self.stage { group.render_overlays(rows, cols); crate::page::note_group(group); } } } #[cfg(test)] mod tests { use super::*; use zellij_utils::input::options::Options; fn parsed(text: &str) -> ContextMenuAction { ...
rust_dataset_chunk_510512
rust_dataset.txt
510,512
512
() .unwrap_or_else(|| panic!("{} cannot be written back", text)); let reparsed = parsed(&written.to_string()); assert_eq!(action, reparsed, "{} changed when written back", text); let (read_spec, read_values) = parse_action(&written.to_string()); if spec.na...
rust_dataset_chunk_510513
rust_dataset.txt
510,513
512
()]); } #[test] fn the_picker_adds_an_action_by_search() { let mut picker = ActionPicker::new("Actions", vec![], None, false); for character in "NewFloat".chars() { picker.handle_key(&KeyWithModifier::new(BareKey::Char(character))); } picker.handle_key(&KeyWithMo...
rust_dataset_chunk_510514
rust_dataset.txt
510,514
512
(scroll, &[String::new()]).unwrap(), "Scroll"); assert_eq!(build_action(scroll, &["5".to_owned()]).unwrap(), "Scroll 5"); let (spec, values) = parse_action_for("ScrollToPrompt \"next\"", true); assert!(spec.mouse_only); assert_eq!(values, vec!["next".to_owned()]); let (spec, _) =...
rust_dataset_chunk_510515
rust_dataset.txt
510,515
512
all_modes() -> Vec<InputMode> { EDITABLE_MODES .iter() .chain(MORE_MODES.iter()) .copied() .collect() } pub fn mode_name(mode: InputMode) -> String { format!("{:?}", mode) } pub const ALL_MODES: &str = "All modes"; pub fn scope_text(mode: Option<InputMode>) -> String { ma...
rust_dataset_chunk_510516
rust_dataset.txt
510,516
512
Page(PageResponse), Add, Edit, } impl From<PageResponse> for ListResponse { fn from(response: PageResponse) -> Self { ListResponse::Page(response) } } pub struct SearchMatch { pub key: Vec<usize>, pub actions: Vec<usize>, pub score: (usize, usize), } pub fn match_columns(query: &...
rust_dataset_chunk_510517
rust_dataset.txt
510,517
512
_range(&text) { styles.push(( label_column + 1, 0, offset + range.start..offset + range.end, )); } offset += length + 2; } } if entry.dim_actions() { let length = entry ...
rust_dataset_chunk_510518
rust_dataset.txt
510,518
512
into_iter().map(mode_name)) .collect(); BindingsList { texts, entries: vec![], mode_selector: Dropdown::new(Text::from("Mode").color_all(0), modes) .label_width(SHORT_LABEL_WIDTH) .accent_brackets(), filter: Dropdown::ne...
rust_dataset_chunk_510519
rust_dataset.txt
510,519
512
-> bool { self.scroll.is_dragging() } pub fn set_entries(&mut self, entries: Vec<E>) { self.entries = entries; self.selected = self.selected.min(self.visible().len().saturating_sub(1)); } pub fn set_focused(&mut self, focused: bool) { self.focused = focused; } pu...
rust_dataset_chunk_510520
rust_dataset.txt
510,520
512
().trim().to_lowercase() } pub fn searching(&self) -> bool { !self.query().is_empty() } fn view(&self) -> (Vec<E>, Vec<ListItem>) { let query = self.query(); let mode = self.selected_mode(); if !query.is_empty() { let mut found: Vec<(E, (usize, usize))> = self...
rust_dataset_chunk_510521
rust_dataset.txt
510,521
512
(); let skipped = targets.len() - resettable.len(); if resettable.is_empty() { self.notice = Some(format!( "None of the marked {} differ from the preset", plural )); return; } self.not...
rust_dataset_chunk_510522
rust_dataset.txt
510,522
512
plural, entries.len() - removed )), (removed, _, _) => Some(format!("Deleted {} {}", removed, plural)), }; self.clear_marks(); } fn request_delete(&mut self) { let plural = self.texts.plural; let targets: Vec<E> = self.targe...
rust_dataset_chunk_510523
rust_dataset.txt
510,523
512
{ let entries = self.visible(); self.marked.clear(); for entry in entries .iter() .skip(from.min(to)) .take(from.max(to) - from.min(to) + 1) { self.marked.insert(entry.id()); } } fn targets(&self) -> Vec<E> { if sel...
rust_dataset_chunk_510524
rust_dataset.txt
510,524
512
label = self.mark_label(category.as_deref()); let mut button = match previous.iter().position(|(_, c)| *c == category) { Some(index) => previous.remove(index).0, None => Button::new(label).accent_brackets(), }; button.set_label(label); if x + button.natural_width...
rust_dataset_chunk_510525
rust_dataset.txt
510,525
512
!(mouse, Mouse::Hover(..)); let mut hover_changed = false; if !self.mode_selector.is_open() && (self.filter.is_open() || matches!(mouse, Mouse::LeftClick(..) | Mouse::Hover(..))) { let (response, filter_changed) = changed_by(&mut self.filter, |filter| filt...
rust_dataset_chunk_510526
rust_dataset.txt
510,526
512
(line, column) = mouse { if !self.scroll.is_dragging() { let row = self.entry_at(line, column); if let (Some(row), Some(anchor)) = (row, self.anchor) { if row != anchor || !self.marked.is_empty() { self.mark_range(anchor, row); ...
rust_dataset_chunk_510527
rust_dataset.txt
510,527
512
} return PageResponse::Handled.into(); } if is_plain(key, BareKey::Esc) && !self.marked.is_empty() { self.clear_marks(); return PageResponse::Handled.into(); } if is_plain(key, BareKey::Down) { if self.selected + 1 < count { ...
rust_dataset_chunk_510528
rust_dataset.txt
510,528
512
return PageResponse::Handled.into(); } if is_plain(key, BareKey::Up) || is_shift_tab(key) { self.focus = ListFocus::Search; return PageResponse::Handled.into(); } if is_plain(key, BareKey::Left) {...
rust_dataset_chunk_510529
rust_dataset.txt
510,529
512
self.scroll.follow(); } else { self.focus = ListFocus::Mode; } return PageResponse::Handled.into(); } if is_plain(key, BareKey::Up) || is_shift_tab(key) { retur...
rust_dataset_chunk_510530
rust_dataset.txt
510,530
512
5 }; let mut previous_buttons = std::mem::take(&mut self.mark_buttons); let (entries, items) = self.view(); let list_y = y + list_offset; let list_height = height.saturating_sub(list_offset).max(1); let selected_item = items .iter() .position(|item...
rust_dataset_chunk_510531
rust_dataset.txt
510,531
512
); let list_width = RowScroll::fitted_width(items.len(), list_height, content_width, width); let visible = self.scroll.layout( x, list_y, list_width, list_height, items.len(), selected_item, ); self.items = items.clo...
rust_dataset_chunk_510532
rust_dataset.txt
510,532
512
.mode_selector.render_overlay(rows, cols); note_dropdown(&self.mode_selector); } } pub fn handle_timer(&mut self) -> bool { let mut changed = false; for (button, _) in self.mark_buttons.iter_mut() { changed |= button.handle_timer(); } changed }...
rust_dataset_chunk_510533
rust_dataset.txt
510,533
512
FieldSpec::text(label, placeholder) } fn pairs_field(label: &'static str) -> FieldSpec { FieldSpec::pairs(label) } pub fn check_plugin_location(text: &str, allow_alias: bool) -> Result<String, String> { let text = text.trim(); let error = if allow_alias { "Use a plugin URL (https://…), zellij:...
rust_dataset_chunk_510534
rust_dataset.txt
510,534
512
= match characters.next() { Some(first) => { (first.is_ascii_alphabetic() || first == '_') && characters.all(|c| c.is_ascii_alphanumeric() || c == '_') }, None => false, }; if valid { Ok(text.to_owned()) } else { Err( "A variab...
rust_dataset_chunk_510535
rust_dataset.txt
510,535
512
)); } summary } pub struct AliasKind; impl EntryKind for AliasKind { type Entry = PluginAliasEntry; fn title(&self) -> String { "Plugin aliases".to_owned() } fn noun(&self) -> &'static str { "plugin alias" } fn identity(&self, entry: &PluginAliasEntry) -> String { ...
rust_dataset_chunk_510536
rust_dataset.txt
510,536
512
any(|default| default.name == entry.name) { Err(format!( "{} is built in and cannot be removed; edit it, or press r to undo your change", entry.name )) } else { Ok(()) } } } pub struct LoadPluginKind; impl EntryKind for LoadPlugin...
rust_dataset_chunk_510537
rust_dataset.txt
510,537
512
for EnvKind { type Entry = EnvVarEntry; fn title(&self) -> String { "Environment variables for new panes (env)".to_owned() } fn short_title(&self) -> String { "Environment variables".to_owned() } fn heading_note(&self) -> Option<String> { Some("new panes, for everyone in...
rust_dataset_chunk_510538
rust_dataset.txt
510,538
512
= "separator"; const MENU_ENTRY_KINDS: &[&str] = &[ITEM, SEPARATOR]; fn section_title(section: &str) -> String { match section { "pane" => "Pane menu (right click on a pane or its frame)".to_owned(), "tab" => "Tab menu (right click on a tab)".to_owned(), "bar" => "Bar menu (right click on ...
rust_dataset_chunk_510539
rust_dataset.txt
510,539
512
} fn fields(&self) -> Vec<FieldSpec> { vec![ FieldSpec::choice("Kind", MENU_ENTRY_KINDS), text_field("Label", "shown in the menu").when(0, ITEM), FieldSpec::actions("Actions").when(0, ITEM), ] } fn to_values(&self, entry: &MenuItemEntry) -> Vec<FieldValue...
rust_dataset_chunk_510540
rust_dataset.txt
510,540
512
bool { true } fn replace_when_reverting(&self) -> bool { true } } const MENU_SECTIONS: [&str; 4] = ["pane", "tab", "bar", "common"]; pub struct BlockPage { note: &'static str, list: SectionedList, plugin_settings_entries: Option<SharedPluginSettingsEntries>, } impl BlockPage ...
rust_dataset_chunk_510541
rust_dataset.txt
510,541
512
BareKey::Tab) || is_plain(key, BareKey::Left) || is_shift_tab(key) || is_plain(key, BareKey::Up) { return PageResponse::LeaveToMenu; } PageResponse::NotHandled } fn handle_mouse(&mut self, mouse: Mouse) -> PageResponse { if self.li...
rust_dataset_chunk_510542
rust_dataset.txt
510,542
512
Entry { plugin_id, title: title.to_owned(), } } #[test] fn plugin_settings_entries_are_listed_last_on_the_plugins_page() { let mut page = BlockPage::plugins_and_environment(); page.set_focused(true); page.set_plugin_settings_entries(vec![settings_entr...
rust_dataset_chunk_510543
rust_dataset.txt
510,543
512
("https://example.com/p.wasm", false).is_ok()); assert!(check_plugin_location("my-alias", false).is_err()); assert_eq!( check_plugin_location("my-alias", true), Ok("my-alias".to_owned()) ); assert!(check_plugin_location("zellij:", false).is_err()); } #[te...
rust_dataset_chunk_510544
rust_dataset.txt
510,544
512
(" ".to_owned(), " ".to_owned()), ]), ]) .unwrap(); assert_eq!( entry.plugin.configuration, vec![ ("label".to_owned(), "tab ".to_owned()), ("spacer".to_owned(), " ".to_owned()), ] ); let...
rust_dataset_chunk_510545
rust_dataset.txt
510,545
512
theme_contrast::{pair_contrasts, PairContrast}; pub const LOW_CONTRAST: f64 = 3.0; #[cfg(test)] pub const GOOD_CONTRAST: f64 = 4.5; fn blend(from: (u8, u8, u8), to: (u8, u8, u8), amount: f64) -> (u8, u8, u8) { let mix = |a: u8, b: u8| (a as f64 + (b as f64 - a as f64) * amount).round() as u8; (mix(from.0, to....
rust_dataset_chunk_510546
rust_dataset.txt
510,546
512
EPSILON || ((margin - previous).abs() <= f64::EPSILON && step < previous_step) }) .unwrap_or(true); if better { best_effort = Some((margin, step, candidate)); } } } let chosen = closest_passing .map(|...
rust_dataset_chunk_510547
rust_dataset.txt
510,547
512
_highest_contrast() { assert!((contrast(BLACK, WHITE) - 21.0).abs() < 0.01); assert!((contrast(WHITE, BLACK) - 21.0).abs() < 0.01); assert!((contrast(WHITE, WHITE) - 1.0).abs() < 0.01); } #[test] fn palette_numbers_are_turned_into_rgb() { assert_eq!(rgb(PaletteColor::EightBi...
rust_dataset_chunk_510548
rust_dataset.txt
510,548
512
.iter() .position(|found| *found == (style, component)) .unwrap(); colours[index].clone() } fn backgrounds_of(found: &SlotContrast) -> Vec<String> { found .pairs .iter() .map(|found| found.pair.background.describe()) ...
rust_dataset_chunk_510549
rust_dataset.txt
510,549
512
== (style, component)) .unwrap() }; colours[index("text_unselected", "background")] = "#000000".to_owned(); colours[index("text_selected", "background")] = "#ffffff".to_owned(); colours[index("text_unselected", "base")] = "#f0f0f0".to_owned(); let found = slot(&s...
rust_dataset_chunk_510550
rust_dataset.txt
510,550
512
=> Some(SettingSection::TerminalTheme), ["attention"] => Some(SettingSection::Attention), ["attention", "desktop_notifications"] => Some(SettingSection::AttentionPopups), ["attention", "tray_badge"] => Some(SettingSection::AttentionBadge), ["attention", "tray_badge_colors"] => Some(Sett...
rust_dataset_chunk_510551
rust_dataset.txt
510,551
512
fn shown_elsewhere(line: &str) -> bool { let line = line.trim(); is_restart_note(line) || line.starts_with("Default:") } fn is_flag_value(line: &str) -> bool { let value = line .trim() .trim_start_matches(['-', '*']) .trim() .to_lowercase(); value.starts_with("true") || ...
rust_dataset_chunk_510552
rust_dataset.txt
510,552
512
_heading(last)).unwrap_or(false) { out.pop(); } if let Some(first) = out.first_mut() { let mut characters = first.chars(); if let Some(initial) = characters.next() { *first = initial.to_uppercase().chain(characters).collect(); } } out.join("\n") } fn finish(l...
rust_dataset_chunk_510553
rust_dataset.txt
510,553
512
_prefix("//") { Some(rest) => (rest.trim(), true), None => (trimmed, false), }; if inner == "}" { path.pop(); block_help.pop(); pending.clear(); previous = None; continue; } if let Some(text) = inner.stri...
rust_dataset_chunk_510554
rust_dataset.txt
510,554
512
, raw)| raw.text().map(|text| (*key, text))) .collect() }) .get(&key) .map(|text| text.as_str()) } #[cfg(test)] pub fn says_it_needs_a_restart(key: SettingKey) -> bool { raw_help_table() .get(&key) .map(|raw| raw.lines().any(|line| is_restart_note(line))) .unwrap_or(...
rust_dataset_chunk_510555
rust_dataset.txt
510,555
512
bar"), "{}", tabs); assert!(!tabs.contains("frame title"), "{}", tabs); let font_size = setting_help(SettingKey::TerminalFontSize).unwrap(); assert!(font_size.contains("points"), "{}", font_size); } #[test] fn options_listed_together_share_their_comment() { let top = settin...
rust_dataset_chunk_510556
rust_dataset.txt
510,556
512
assert!(help.contains("is closed\nOptions:"), "{}", help); } fn without_quotes(text: &str) -> String { text.replace(['"', '\\'], "").trim().to_lowercase() } #[test] fn what_the_settings_screen_already_shows_is_left_out() { let help = setting_help(SettingKey::OnForceClose).unwrap()...
rust_dataset_chunk_510557
rust_dataset.txt
510,557
512
(*key).default); assert!( stated == known || stated.starts_with(&format!("{} (", known)), "{}: the config file says the default is {:?}, the settings screen says {:?}", key, stated, known ); } } #[te...
rust_dataset_chunk_510558
rust_dataset.txt
510,558
512
: &KeybindsSelectionSnapshot, mode: InputMode, key: &KeyWithModifier, ) -> Vec<String> { let mut warnings = vec![]; if let Some(unlock) = selection .active_values .get("unlock") .and_then(|value| KeyWithModifier::from_str(value).ok()) { if &unlock == key { ...
rust_dataset_chunk_510559
rust_dataset.txt
510,559
512
"MoveFocusOrTab" | "FocusNextPane" | "FocusPreviousPane" | "SwitchFocus" | "FocusLastPane" => "Focus", "MovePane" | "MovePaneBackwards" => "Move", "Resize" => "Resize", "NewTab" | "CloseTab" | "GoToTab" | "GoToNextTab" | "GoToPreviousTab" | "Toggl...
rust_dataset_chunk_510560
rust_dataset.txt
510,560
512
{ category_of(&entry.preset_actions.clone().unwrap_or_default()) } else { category_of(&entry.actions) } } const TEXTS: ListTexts = ListTexts { title: "Keybindings", search_placeholder: "/ to search keys and actions", search_hint: "search keys and actions", items_hint: "keys", ...
rust_dataset_chunk_510561
rust_dataset.txt
510,561
512
| KeybindingSource::Shared(_) => { Ok(vec![Effect::ResetKeys(vec![( entry.mode, entry.key.clone(), )])]) }, } } pub fn binding_effects( mode: InputMode, original: Option<&KeybindingEntry>, key: &KeyWithModifier, actions: &[String], ) ...
rust_dataset_chunk_510562
rust_dataset.txt
510,562
512
: Vec<KeybindingEntry>, selection: KeybindsSelectionSnapshot, ) { self.list.set_entries(entries); self.selection = selection; } #[cfg(test)] pub fn visible(&self) -> Vec<KeybindingEntry> { self.list.visible() } fn start_capture(&mut self) { if let Some(for...
rust_dataset_chunk_510563
rust_dataset.txt
510,563
512
) { let Some(form) = self.form.as_ref() else { return; }; let mode = form.mode; if is_save_key(&key) { self.open_dialog( "Ctrl a is the save key", format!( "Ctrl a saves the settings. Bound in {} mode it may no l...
rust_dataset_chunk_510564
rust_dataset.txt
510,564
512
response, UiResponse::Submitted(UiValue::Choice { index: 0, .. }) ); let purpose = if self.dialog.is_open() { None } else { self.dialog_purpose.take() }; match purpose { Some(DialogPurpose::SaveKey(key)) => { ...
rust_dataset_chunk_510565
rust_dataset.txt
510,565
512
(..)) { form.focus = FormFocus::Actions; } let response = form.picker.handle_mouse(mouse); self.handle_picker_response(response); } } fn handle_form_key(&mut self, key: &KeyWithModifier) { let Some(form) = self.form.as_mut() else { ...
rust_dataset_chunk_510566
rust_dataset.txt
510,566
512
Focus::Key; return; } }, } } let response = form.picker.handle_key(key); self.handle_picker_response(response); } fn handle_list_response(&mut self, response: ListResponse) -> PageResponse { match response { ...
rust_dataset_chunk_510567
rust_dataset.txt
510,567
512
icker_rows) => { let height = 3 + picker_rows; let width = (content_column + natural_button_width.max(form.picker.action_name_width()) + 4) .max(FORM_DIALOG_MIN_WIDTH) .min(max_width); (width, height....
rust_dataset_chunk_510568
rust_dataset.txt
510,568
512
(x + content_column, y); form.picker.set_button_width(button_width); let mut row = y + 1; for warning in &form.warnings { print_text_with_coordinates( Text::from(truncate( &format!("⚠ {}", warning), width.saturating_sub(content_...
rust_dataset_chunk_510569
rust_dataset.txt
510,569
512
(x, y, width, height); } fn handle_mouse(&mut self, mouse: Mouse) -> PageResponse { if self.dialog.is_open() { let (response, dialog_changed) = changed_by(&mut self.dialog, |dialog| dialog.handle_mouse(mouse)); self.dialog_response(response); return if...
rust_dataset_chunk_510570
rust_dataset.txt
510,570
512
<Effect> { let mut effects = std::mem::take(&mut self.effects); effects.extend(self.list.take_effects()); effects } fn take_notice(&mut self) -> Option<String> { self.notice.take().or_else(|| self.list.take_notice()) } fn leave(&mut self) { if self.form.is_some() ...
rust_dataset_chunk_510571
rust_dataset.txt
510,571
512
entries, InputMode::Pane, &key("Alt n"), None).is_none()); assert!(same_mode_binding( &entries, InputMode::Normal, &key("Alt n"), Some(&key("Alt n")) ) .is_none()); let mut unbound = entry(InputMode::Normal, "Alt x", KeybindingSource::User)...
rust_dataset_chunk_510572
rust_dataset.txt
510,572
512
KeybindingSource::Preset); let effects = binding_effects( InputMode::Normal, Some(&original), &key("Alt m"), &["NewPane".to_owned()], ) .unwrap(); assert_eq!(effects.len(), 2); match &effects[1] { Effect::Reconfigure(kd...
rust_dataset_chunk_510573
rust_dataset.txt
510,573
512
Alt n", KeybindingSource::Preset), entry(InputMode::Pane, "n", KeybindingSource::Preset), entry(InputMode::Tab, "x", KeybindingSource::Preset), ], selection(), ); assert_eq!(screen.visible().len(), 1); screen.handle_key(&key("/")); ...
rust_dataset_chunk_510574
rust_dataset.txt
510,574
512
my-keybindings"; const MODIFIER_CHOICES: [&str; 8] = [ "Ctrl", "Alt", "Super", "Ctrl Alt", "Ctrl Shift", "Alt Shift", "Ctrl Super", "Alt Super", ]; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum KeysField { Preset, Primary, Secondary, Unlock, SaveAsPreset, ...
rust_dataset_chunk_510575
rust_dataset.txt
510,575
512
!("{} (Avoids Collisions)", label) } else { label } } struct PresetNaming { dialog: ConfirmDialog, input: TextInput, then_switch_to: Option<String>, error: Option<String>, } const NAMING_WIDTH: usize = 60; impl KeysScreen { pub fn new(is_setup_wizard: bool) -> Self { let m...
rust_dataset_chunk_510576
rust_dataset.txt
510,576
512
_ref() } } pub fn set_presets( &mut self, presets: Vec<KeybindPresetInfo>, preset_errors: Vec<KeybindPresetWithError>, ) { if self.presets != presets || self.preset_errors != preset_errors { self.presets = presets; self.preset_errors = preset_e...
rust_dataset_chunk_510577
rust_dataset.txt
510,577
512
} } choices } fn rebuild(&mut self) { let focused = self.elements.focused_key().copied(); self.elements = FocusGroup::new().wrap(self.is_setup_wizard); if self.is_custom() { let mut names = vec![CUSTOM_PRESET.to_owned()]; names.extend(s...
rust_dataset_chunk_510578
rust_dataset.txt
510,578
512
a key…".to_owned() } else { self.leader_value("unlock") .unwrap_or_else(|| "not set".to_owned()) }; self.elements.add( KeysField::Unlock, Button::new(format!( " {:...
rust_dataset_chunk_510579
rust_dataset.txt
510,579
512
(format!("keybinds preset={}", kdl_string(name))); } fn modifier_set(value: &str) -> BTreeSet<String> { value .split_whitespace() .map(|part| part.to_lowercase()) .collect() } fn set_leader(&mut self, placeholder: &str, value: String) { if value.trim()...
rust_dataset_chunk_510580
rust_dataset.txt
510,580
512
} } fn start_naming(&mut self, then_switch_to: Option<String>) { let name = if self.is_custom() { self.unique_preset_name(SAVED_PRESET_NAME) } else { self.copy_name_for(&self.selection.active.name) }; let mut input = TextInput::new(name).label("Nam...
rust_dataset_chunk_510581
rust_dataset.txt
510,581
512
{} already exists", name)); } return; } if !self.is_custom() { let preset = self.selection.active.name.clone(); match copy_keybind_preset(&preset, &name) { Ok(saved) => { self.naming = None; self.not...
rust_dataset_chunk_510582
rust_dataset.txt
510,582
512
UiResponse::Submitted(_) | UiResponse::Cancelled => self.cancel_naming(), _ => {}, } } fn handle_naming_key(&mut self, key: &KeyWithModifier) { let Some(naming) = self.naming.as_mut() else { return; }; let is_tab = key.bare_key == BareKey::Tab;...
rust_dataset_chunk_510583
rust_dataset.txt
510,583
512
candidate = format!("{}-{}", base, index); if !taken(&candidate) { return candidate; } index += 1; } } fn open_switch_dialog(&mut self, preset: String) { let mut message = if self.selection.has_own_mousebindings { format!("Your key...
rust_dataset_chunk_510584
rust_dataset.txt
510,584
512
; } overwrite_config_file(); request_close(); } fn leave(&mut self) { if self.step_of_setup { self.wants_back = true; } else { request_close(); } } fn handle_focus_event(&mut self, event: FocusEvent<KeysField>) -> bool { mat...
rust_dataset_chunk_510585
rust_dataset.txt
510,585
512
(key); return true; } if self.naming.is_some() { self.handle_naming_key(&key); return true; } self.notice = None; if self.is_setup_wizard && key.is_key_with_ctrl_modifier(BareKey::Char('a')) { self.save(); return true; ...
rust_dataset_chunk_510586
rust_dataset.txt
510,586
512
&self.footer_areas); let footer_changed = hovered != self.footer_hovered; self.footer_hovered = hovered; let link_hovered = !self.elements.has_open_overlay() && !crate::page::under_overlay(line, column) && self.file_link_at(line, c...
rust_dataset_chunk_510587
rust_dataset.txt
510,587
512
= keys_end + 1; let mut offset = 0; for word in text.split(' ') { let word_length = word.chars().count(); let is_mode_name = word_length > 1 && word.chars().all(|c| c.is_ascii_uppercase()); if is_mode_name && text_start + offset + word_length <= width { ...
rust_dataset_chunk_510588
rust_dataset.txt
510,588
512
, usize)> = vec![]; let mut link_row: Option<(usize, usize, String)> = None; let fit = |text: &str| truncate(text, width); let mut row = 0; if self.step_of_setup { lines.push(( row, Text::from(fit("Please Choose a Keybinding Preset")).color_all...
rust_dataset_chunk_510589
rust_dataset.txt
510,589
512
((KeysField::SaveAsPreset, row)); } if self.selection.set_on_command_line { lines.push(( row + 1, Text::from(fit( "Given on the command line for this session; choosing here replaces it", )) ...
rust_dataset_chunk_510590
rust_dataset.txt
510,590
512
choice while it is loaded.", )) .dim_all(), )); row += 1; } if let Some(error) = &self.selection.error { lines.push(( row, Text::from(fit(&format!("Using the default preset instead: {}", error))) ...
rust_dataset_chunk_510591
rust_dataset.txt
510,591
512
_row) .unwrap_or(0); let offset = (focused_row + 1).saturating_sub(height); let visible = |content_row: usize| content_row >= offset && content_row < offset + height; let lines: Vec<(usize, Text)> = lines .into_iter() .filter(|(line_row, _)| visible(*line_row)...
rust_dataset_chunk_510592
rust_dataset.txt
510,592
512
_width + 2 } else { crate::page::BESIDE_SHORT_FIELD }; let field_width = FIELD_WIDTH.min(width); let element_rows = self.element_rows.clone(); for (field, field_row) in element_rows { if field_row >= height { continue; } ...
rust_dataset_chunk_510593
rust_dataset.txt
510,593
512
::note_group(&self.elements); self.dialog.render_centered(rows, cols); if let Some(naming) = self.naming.as_mut() { naming.dialog.render_centered(rows, cols); let (x, y, width) = Self::naming_input_position(naming, rows, cols); naming.input.set_show_cursor(true); ...
rust_dataset_chunk_510594
rust_dataset.txt
510,594
512
preset_label; #[test] fn preset_names_are_capitalised_and_unlock_first_is_marked() { assert_eq!(preset_label("default"), "Default"); assert_eq!(preset_label("my_own-keys"), "My Own Keys"); assert_eq!( preset_label("unlock-first"), "Unlock First (Avoids Collisions...
rust_dataset_chunk_510595
rust_dataset.txt
510,595
512
static str]) -> Self { FieldSpec { label, kind: FieldKind::Choice(choices), placeholder: "", shown_when: None, } } pub fn when(mut self, field: usize, value: &'static str) -> Self { self.shown_when = Some((field, value)); self }...
rust_dataset_chunk_510596
rust_dataset.txt
510,596
512
; fn entries(&self, blocks: &ConfigBlocks) -> Vec<Self::Entry>; fn refresh(&mut self, _snapshot: &ConfigSnapshot) {} fn new_values(&self) -> Vec<FieldValue> { self.fields() .iter() .map(|field| match field.kind { FieldKind::Text => FieldValue::Text(String::new...
rust_dataset_chunk_510597
rust_dataset.txt
510,597
512
: Option<InputMode>, for_menu: bool, } impl EntryForm { fn new( title: String, editing: Option<usize>, specs: Vec<FieldSpec>, values: Vec<FieldValue>, extra_buttons: Vec<FormKey>, ) -> Self { let mut form = EntryForm { editing, insert_...
rust_dataset_chunk_510598
rust_dataset.txt
510,598
512
continue; } match (&spec.kind, self.values.get(index)) { (FieldKind::Text, Some(FieldValue::Text(text))) => group.add( FormKey::Text(index), TextInput::new(text.clone()) .label(spec.label) ...
rust_dataset_chunk_510599
rust_dataset.txt
510,599
512
Key>) { let mut group = FocusGroup::new(); for (index, spec) in self.specs.iter().enumerate() { if !self.is_shown(index) { continue; } match (&spec.kind, self.values.get(index)) { (FieldKind::Text, Some(FieldValue::Text(text))) => group...