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_511000 | rust_dataset.txt | 511,000 | 512 | _id, true, false),
Effect::WatchNames => subscribe(&[EventType::PaneUpdate, EventType::TabUpdate]),
}
}
}
#[cfg(not(target_family = "wasm"))]
fn apply(_effects: Vec<Effect>) {}
impl Prompt {
fn flush(&mut self) {
apply(self.app.take_effects());
}
}
impl ZellijPlugin for Prompt... |
rust_dataset_chunk_511001 | rust_dataset.txt | 511,001 | 512 | => Value::String(text.clone()),
Answer::Number(number) => json!(number),
Answer::Bool(on) => Value::Bool(*on),
Answer::Choice(choice) => Value::String(choice.clone()),
Answer::Choices(choices) => {
Value::Array(choices.iter().cloned().map(Value::String).c... |
rust_dataset_chunk_511002 | rust_dataset.txt | 511,002 | 512 | format!("'{}' is not a whole number", default))?,
),
Spec::Toggle { .. } => Answer::Bool(parse_bool(default)?),
Spec::Form { default, .. } => {
Answer::Form(default.clone().unwrap_or_default().into_iter().collect())
},
Spec::Notify { .. } | Spec::Info { .. } => retur... |
rust_dataset_chunk_511003 | rust_dataset.txt | 511,003 | 512 | fn request(name: &str, pairs: &[(&str, &str)]) -> Request {
let args: BTreeMap<String, String> = pairs
.iter()
.map(|(k, v)| (k.to_string(), v.to_string()))
.collect();
parse_request(name, &args, None).unwrap()
}
#[test]
fn plain_text_output_for_each_... |
rust_dataset_chunk_511004 | rust_dataset.txt | 511,004 | 512 | ,\"port\":8080,\"files\":[\"a\"]}\n"
);
assert_eq!(reply.exit_code, 0);
let reply = reply_for(&Outcome::Answered(Answer::Form(values)), true, false);
assert!(reply
.output
.starts_with("{\"result\":\"answered\",\"value\":{\"name\":\"demo\""));
}
#[test]
... |
rust_dataset_chunk_511005 | rust_dataset.txt | 511,005 | 512 | 1s")]);
let reply = reply_for(
&Outcome::TimedOut(default_answer(&without_default).unwrap()),
false,
false,
);
assert_eq!(reply.output, "");
assert_eq!(reply.exit_code, 124);
let confirm = request("confirm", &[("default", "no")]);
let r... |
rust_dataset_chunk_511006 | rust_dataset.txt | 511,006 | 512 | {
remember: Some(_), ..
} => BTreeMap::from([
(MENU_CHOICE_FIELD.to_owned(), FormFieldKind::Choose),
(MENU_REMEMBER_FIELD.to_owned(), FormFieldKind::Toggle),
]),
_ => BTreeMap::new(),
... |
rust_dataset_chunk_511007 | rust_dataset.txt | 511,007 | 512 | .. }) => {},
}
}
effects
}
pub fn prompt_result(
outcome: &Outcome,
field_kinds: &BTreeMap<String, FormFieldKind>,
) -> PromptResult {
match outcome {
Outcome::Answered(Answer::Confirmed(yes)) => PromptResult::Confirmed(*yes),
Outcome::Answered(answer) => PromptResult::Answ... |
rust_dataset_chunk_511008 | rust_dataset.txt | 511,008 | 512 | String(text) => text.clone(),
other => other.to_string(),
})
.collect(),
)),
Value::Object(_) => Some(PromptValue::Text(value.to_string())),
}
}
#[cfg(test)]
mod tests {
use super::*;
use serde_json::json;
#[test]
fn a_form_answer... |
rust_dataset_chunk_511009 | rust_dataset.txt | 511,009 | 512 | Value::Number(3)))
);
assert_eq!(
prompt_result(&Outcome::Error("x".to_owned()), &kinds),
PromptResult::Error("x".to_owned())
);
assert_eq!(
expand(vec![Intent::Reply(
Destination::plugin(4),
Outcome::Cancelled
... |
rust_dataset_chunk_511010 | rust_dataset.txt | 511,010 | 512 | : Option<i64>,
},
Toggle {
message: Option<StyledText>,
default: bool,
},
Select {
message: StyledText,
options: Vec<String>,
default: Option<usize>,
},
Menu {
items: Vec<ChoiceItem>,
remember: Option<String>,
padded: bool,
},
... |
rust_dataset_chunk_511011 | rust_dataset.txt | 511,011 | 512 | },
PromptSpec::Choose {
items,
multi,
selected,
} => Spec::Choose {
items,
multi,
labels,
null,
selected,
streaming,
},
PromptSpec::Input {
message,
... |
rust_dataset_chunk_511012 | rust_dataset.txt | 511,012 | 512 | _name,
} => Spec::Notify {
message,
pane_name: caller.pane_title,
tab_name: caller.tab_name,
show_pane_name,
show_tab_name,
caller_pane: caller.pane_id,
},
PromptSpec::Info { message } => Spec::Info { message },
};
O... |
rust_dataset_chunk_511013 | rust_dataset.txt | 511,013 | 512 | );
let without_names = parse_request(
"notify",
&args(&[
("message", "Saved"),
("no_pane_name", "true"),
("no_tab_name", "true"),
]),
None,
)
.unwrap();
assert_eq!(
without_names.... |
rust_dataset_chunk_511014 | rust_dataset.txt | 511,014 | 512 | );
assert_eq!(selected, vec!["b".to_owned()]);
assert!(null);
assert!(!streaming);
},
other => panic!("unexpected {:?}", other),
}
}
#[test]
fn a_payload_with_several_lines_becomes_several_items() {
asse... |
rust_dataset_chunk_511015 | rust_dataset.txt | 511,015 | 512 | Some(65535),
step: 1,
default: Some(8080),
}
);
}
#[test]
fn toggle_and_select_read_their_defaults() {
let toggle = parse_request("toggle", &args(&[("default", "on")]), None).unwrap();
assert_eq!(
toggle.spec,
Spec... |
rust_dataset_chunk_511016 | rust_dataset.txt | 511,016 | 512 | u32,
value_len: u32,
label_len: u32,
}
#[derive(Debug, Default)]
pub struct ItemStore {
chunks: Vec<String>,
spans: Vec<Span>,
text_bytes: usize,
}
impl ItemStore {
pub fn len(&self) -> usize {
self.spans.len()
}
pub fn is_empty(&self) -> bool {
self.spans.is_empty()
... |
rust_dataset_chunk_511017 | rust_dataset.txt | 511,017 | 512 | span.label_len == NO_LABEL {
return self.value(index);
}
let start = span.start as usize + span.value_len as usize;
&self.chunks[span.chunk as usize][start..start + span.label_len as usize]
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn values_and_labels_com... |
rust_dataset_chunk_511018 | rust_dataset.txt | 511,018 | 512 | _FIELD, MENU_REMEMBER_FIELD};
use crate::form::FormScreen;
use crate::outcome::{Answer, Outcome};
use crate::request::{Pattern, Request, Spec};
use crate::store::ItemStore;
pub type Hint = (&'static str, &'static str);
pub const MIN_WIDTH: usize = 36;
pub const MAX_WIDTH: usize = 100;
const CONFIRM_DEFAULT_WIDTH: us... |
rust_dataset_chunk_511019 | rust_dataset.txt | 511,019 | 512 | (s) + 2).unwrap_or(0);
let room = width.saturating_sub(status_width);
let mut line = String::new();
let mut key_ranges = vec![];
for (index, (key, action)) in hints.iter().enumerate() {
let separator = if index == 0 { "" } else { ", " };
let entry = format!("{}{} - {}", separator, key, a... |
rust_dataset_chunk_511020 | rust_dataset.txt | 511,020 | 512 | message,
yes,
no,
*default_yes,
)),
Spec::Choose {
items,
multi,
selected,
streaming,
..
} => Screen::Choose(ChooseScreen::new(
... |
rust_dataset_chunk_511021 | rust_dataset.txt | 511,021 | 512 | (_))
}
pub fn is_notice(&self) -> bool {
matches!(self, Screen::Notify(_))
}
pub fn watches_names(&self) -> bool {
match self {
Screen::Notify(s) => s.watches_names(),
_ => false,
}
}
pub fn update_panes(&mut self, pane_manifest: &PaneManifest) -> ... |
rust_dataset_chunk_511022 | rust_dataset.txt | 511,022 | 512 | Confirm(s) => s.render(x, y, width, height),
Screen::Choose(s) => s.render(x, y, width, height),
Screen::Input(s) => s.render(x, y, width, height),
Screen::Number(s) => s.render(x, y, width, height),
Screen::Toggle(s) => s.render(x, y, width, height),
Screen::... |
rust_dataset_chunk_511023 | rust_dataset.txt | 511,023 | 512 | cancel"),
],
Screen::Select(_) => &[
("<Space>", "open"),
("<←→>", "change"),
("<Enter>", "accept"),
("<Esc>", "cancel"),
],
Screen::Menu(s) if s.has_remember() => &[
("<↓↑>", "move"),
... |
rust_dataset_chunk_511024 | rust_dataset.txt | 511,024 | 512 | Screen {
dialog: dialog
.buttons(vec![yes.to_owned(), no.to_owned()])
.selected(selected)
.footer_rows(2)
.centered()
.opened(),
}
}
fn respond(&mut self, response: UiResponse) -> Step {
match response {
... |
rust_dataset_chunk_511025 | rust_dataset.txt | 511,025 | 512 | marked: vec![],
multi,
preselected,
search: TextInput::empty()
.search_mode()
.placeholder("Type to search")
.focused(),
list: MenuList::new(vec![]).focused(),
visible: vec![],
highlighted... |
rust_dataset_chunk_511026 | rust_dataset.txt | 511,026 | 512 | any(|value| value == self.items.value(*index))
})
}
fn highlighted_position(&self) -> Option<usize> {
let highlighted = self.highlighted?;
self.visible
.iter()
.position(|index| *index as usize == highlighted)
}
pub fn refresh(&mut self) {
if !self... |
rust_dataset_chunk_511027 | rust_dataset.txt | 511,027 | 512 | to_owned(),
))),
None => Step::Nothing,
}
}
pub fn handle_key(&mut self, key: &KeyWithModifier) -> Step {
self.refresh();
if is_key(key, BareKey::Enter) {
return self.submit();
}
if self.multi && (is_key(key, BareKey::Char(' ')) || is_k... |
rust_dataset_chunk_511028 | rust_dataset.txt | 511,028 | 512 | let query = self.search.get_text();
let searching = !query.trim().is_empty();
self.visible
.iter()
.skip(self.offset)
.take(rows)
.map(|index| {
let full_label = self.items.display(*index as usize);
let label = trunc... |
rust_dataset_chunk_511029 | rust_dataset.txt | 511,029 | 512 | .list.set_highlighted(
self.highlighted_position()
.and_then(|p| p.checked_sub(self.offset)),
);
let list_y = y + 1 + if needs_indicators { 1 } else { 0 };
if needs_indicators {
let above = self.offset;
let below = total.saturating_sub(self.off... |
rust_dataset_chunk_511030 | rust_dataset.txt | 511,030 | 512 | >,
tried: bool,
}
impl InputScreen {
pub fn new(
message: Option<StyledText>,
placeholder: Option<String>,
pattern: Option<Pattern>,
required: bool,
default: Option<String>,
) -> Self {
let mut input = TextInput::new(default.unwrap_or_default()).focused();
... |
rust_dataset_chunk_511031 | rust_dataset.txt | 511,031 | 512 | >,
max: Option<i64>,
stepper: NumberStepper,
error: Option<String>,
}
pub use zellij_utils::prompt::range_error;
impl NumberScreen {
pub fn new(
message: Option<StyledText>,
min: Option<i64>,
max: Option<i64>,
step: i64,
default: Option<i64>,
) -> Self {
... |
rust_dataset_chunk_511032 | rust_dataset.txt | 511,032 | 512 | KeyWithModifier::new(BareKey::Right)
} else if is_key(key, BareKey::Down) {
KeyWithModifier::new(BareKey::Left)
} else {
key.clone()
};
let handled = self.stepper.handle_key(&key).is_handled();
if self.error.is_some() {
self.error = self.typed... |
rust_dataset_chunk_511033 | rust_dataset.txt | 511,033 | 512 | Esc) {
return Step::Done(Outcome::Cancelled);
}
if is_key(key, BareKey::Left) {
self.toggle.set_on(false);
return Step::Redraw;
}
if is_key(key, BareKey::Right) {
self.toggle.set_on(true);
return Step::Redraw;
}
... |
rust_dataset_chunk_511034 | rust_dataset.txt | 511,034 | 512 | match self.selected_value() {
Some(value) => Step::Done(Outcome::Answered(Answer::Choice(value))),
None => Step::Nothing,
};
}
if is_key(key, BareKey::Esc) {
return Step::Done(Outcome::Cancelled);
}
... |
rust_dataset_chunk_511035 | rust_dataset.txt | 511,035 | 512 | _mark_column();
}
self.remember = label.map(|label| Toggle::new(label, false));
self
}
pub fn padded(mut self, padded: bool) -> Self {
self.padding = if padded { 1 } else { 0 };
self
}
pub fn has_remember(&self) -> bool {
self.remember.is_some()
}
... |
rust_dataset_chunk_511036 | rust_dataset.txt | 511,036 | 512 | 2
+ if self.remember.is_some() {
REMEMBER_GAP_ROWS + 1
} else {
0
};
let list_height = height.saturating_sub(reserved).min(self.list_height());
self.list
.render(x + padding, y + padding, inner_width, list_height);
i... |
rust_dataset_chunk_511037 | rust_dataset.txt | 511,037 | 512 | go_back_area: None,
}
}
fn text_width_wanted(&self) -> usize {
self.message
.text
.split('\n')
.map(text_width)
.max()
.unwrap_or(0)
.clamp(MIN_WIDTH, INFO_TEXT_WIDTH)
}
pub fn desired_size(&self) -> (usize, usize) ... |
rust_dataset_chunk_511038 | rust_dataset.txt | 511,038 | 512 | 3, ..INFO_KEY.len()),
x,
footer_y,
None,
None,
);
let action_x = x + key_width + separator.len();
let action = if self.go_back_hovered {
Text::from(INFO_ACTION).selected()
} else {
Text::from(INFO_ACTION)
};
... |
rust_dataset_chunk_511039 | rust_dataset.txt | 511,039 | 512 | _name = non_empty(tab_name);
let changed = self.tab_name != tab_name;
self.caller_in_other_tab |= tab_name.is_some() && self.caller_tab_position.is_none();
self.tab_name = tab_name;
changed && self.shows_tab_name()
}
fn shows_tab_name(&self) -> bool {
self.show_tab_name &... |
rust_dataset_chunk_511040 | rust_dataset.txt | 511,040 | 512 | let name_changed = match tabs.iter().find(|tab| tab.position == caller_tab_position) {
Some(tab) => self.set_tab_name(Some(tab.name.clone())),
None => false,
};
name_changed || placement_changed
}
fn name_lines(&self) -> Vec<String> {
let mut lines = vec![... |
rust_dataset_chunk_511041 | rust_dataset.txt | 511,041 | 512 | + 1;
if on_close_mark {
Step::Done(Outcome::Cancelled)
} else {
Step::NoticeClicked(self.caller_pane)
}
},
_ => Step::Nothing,
}
}
pub fn render(&mut self, x: usize, y: usize, cols: usize, ro... |
rust_dataset_chunk_511042 | rust_dataset.txt | 511,042 | 512 | 1, line_y, Some(1), None);
if row < message_rows {
if let Some(line) = lines.get(row) {
print_text_with_coordinates(
line.clone(),
x + 2,
line_y,
Some(text_width_available),
... |
rust_dataset_chunk_511043 | rust_dataset.txt | 511,043 | 512 | }
}
fn manifest(panes: Vec<(usize, Vec<PaneInfo>)>) -> PaneManifest {
PaneManifest {
panes: panes.into_iter().collect(),
}
}
fn notice(show_pane_name: bool, show_tab_name: bool) -> NotifyScreen {
let mut screen = NotifyScreen::new(None, "Done".into())
.... |
rust_dataset_chunk_511044 | rust_dataset.txt | 511,044 | 512 | }
#[test]
fn the_names_follow_pane_and_tab_renames() {
let mut screen = notice(true, true);
let panes = manifest(vec![
(0, vec![pane(1, "other")]),
(1, vec![pane(3, "cargo")]),
]);
assert!(screen.update_panes(&panes));
assert!(screen.update_ta... |
rust_dataset_chunk_511045 | rust_dataset.txt | 511,045 | 512 | ".to_owned())))
);
}
#[test]
fn choose_esc_clears_the_search_first_then_cancels() {
let mut screen = ChooseScreen::new(items(&["a", "b"]), false, vec![], false);
screen.handle_key(&key(BareKey::Char('b')));
assert_eq!(screen.handle_key(&key(BareKey::Esc)), Step::Redraw);
... |
rust_dataset_chunk_511046 | rust_dataset.txt | 511,046 | 512 | assert_eq!(
screen.handle_key(&key(BareKey::Enter)),
Step::Done(Outcome::Answered(Answer::Choice("b".to_owned())))
);
}
#[test]
fn choose_keeps_only_the_rows_on_screen_in_the_list_element() {
let many: Vec<ChoiceItem> = (0..5000)
.map(|i| ChoiceIt... |
rust_dataset_chunk_511047 | rust_dataset.txt | 511,047 | 512 | areKey::Enter)),
Step::Done(Outcome::Answered(Answer::Choice("item 3".to_owned())))
);
}
#[test]
fn input_refuses_text_that_fails_the_check() {
let pattern = Pattern(regex::Regex::new("^[a-z]+$").unwrap());
let mut screen = InputScreen::new(None, None, Some(pattern), tru... |
rust_dataset_chunk_511048 | rust_dataset.txt | 511,048 | 512 | areKey::Enter)),
Step::Done(Outcome::Answered(Answer::Choice("Apache-2.0".to_owned())))
);
assert_eq!(
select.handle_key(&key(BareKey::Esc)),
Step::Done(Outcome::Cancelled)
);
}
#[test]
fn number_refuses_a_typed_value_outside_the_range() {
... |
rust_dataset_chunk_511049 | rust_dataset.txt | 511,049 | 512 | }
#[test]
fn a_menu_starts_on_the_default_item() {
let mut menu = MenuScreen::new(vec![
ChoiceItem::plain("detach"),
ChoiceItem::plain("quit"),
ChoiceItem::plain("cancel"),
])
.starting_at(Some("quit"));
assert_eq!(
menu.handle_ke... |
rust_dataset_chunk_511050 | rust_dataset.txt | 511,050 | 512 | ())
.collect()
};
assert_eq!(
indices(&levels[3]),
vec![0, 1, 2, 3, 4, 5, 6, 18, 19, 20, 21, 22]
);
assert_eq!(indices(&levels[4]), (52..60).collect::<Vec<_>>());
}
#[test]
fn help_entries_that_do_not_fit_are_dropped_from_the_end() {
... |
rust_dataset_chunk_511051 | rust_dataset.txt | 511,051 | 512 | (',')
.filter(|i| !i.is_empty())
.map(|i| i.parse().unwrap())
.collect()
};
assert_eq!(indices(&levels[3]), vec![0, 1, 2, 14, 15, 16, 17, 18]);
assert_eq!(indices(&levels[4]), vec![36, 37, 38]);
}
#[test]
fn styled_questions_are_handed... |
rust_dataset_chunk_511052 | rust_dataset.txt | 511,052 | 512 | (Mouse::LeftClick(1, 0)),
Step::Nothing
));
assert!(matches!(
screen.handle_mouse(Mouse::Hover(go_back_line, 8)),
Step::Redraw
));
assert!(matches!(
screen.handle_mouse(Mouse::Hover(go_back_line, 9)),
Step::Nothing
));
... |
rust_dataset_chunk_511053 | rust_dataset.txt | 511,053 | 512 | SWITCHED.with(|switched| switched.set(true));
}
}
fn leave() {
zellij_tile::prelude::set_live_view(None);
let switched = SWITCHED.with(|switched| switched.replace(false));
if !switched {
zellij_tile::prelude::detach();
}
}
pub fn close_self() {
if is_enabled() {
leave();
}... |
rust_dataset_chunk_511054 | rust_dataset.txt | 511,054 | 512 | (3, ..),
close_button_column(cols),
0,
None,
None,
);
}
pub fn request_quit() {
note_switch();
zellij_tile::prelude::switch_session(Some(QUIT_REQUEST));
}
pub fn title(view: &str) -> String {
format!("Zellij · {}", view)
}
pub fn quit_lines(sessions: &[String]) -> Vec<... |
rust_dataset_chunk_511055 | rust_dataset.txt | 511,055 | 512 | (session, pane_id);
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn the_quit_question_names_every_session_and_sits_in_the_middle() {
let sessions = vec!["api".to_owned(), "docs".to_owned()];
let lines = quit_lines(&sessions);
assert_eq!(lines[0], "Quit Zellij and stop all sessi... |
rust_dataset_chunk_511056 | rust_dataset.txt | 511,056 | 512 | : RefCell<Vec<(AttentionStatus, [u8; 3])>> = RefCell::new(vec![]);
}
pub fn of(status: AttentionStatus) -> Option<[u8; 3]> {
COLORS.with(|colors| {
colors
.borrow()
.iter()
.find(|(s, _)| *s == status)
.map(|(_, rgb)| *rgb)
})
}
pub fn set(colors: &[(Att... |
rust_dataset_chunk_511057 | rust_dataset.txt | 511,057 | 512 | item = truncate_plain(&hint.text(), width);
let current = lines.last_mut().unwrap();
let mut candidate = current.clone();
candidate.push(item.clone());
if line_width(&candidate) <= width {
current.push(item);
} else if lines.len() < max_lines {
lines.push... |
rust_dataset_chunk_511058 | rust_dataset.txt | 511,058 | 512 | ()
.map(|text| BlockLine {
text,
secondary: true,
}),
);
lines
}
pub fn line_text(line: &BlockLine) -> Text {
let mut text = key_hint_ranges(Text::from(line.text.as_str()), &line.text);
if !line.secondary {
return text;
}
let mut l... |
rust_dataset_chunk_511059 | rust_dataset.txt | 511,059 | 512 | h.label),
width,
)
})
.collect()
}
pub const ALL_KEYS_TITLE: &str = "All keys";
pub const ALL_KEYS_CLOSE: &str = "Press any key to go back";
pub const ALL_KEYS_SCROLL: &str = "<↓↑> more any other key: back";
pub fn render_all_keys(title: &str, hints: &[Hint], rows: usize,... |
rust_dataset_chunk_511060 | rust_dataset.txt | 511,060 | 512 | index, column) in columns.iter().enumerate() {
let column_x = x + index * (column_width + 4);
for (row, line) in column.iter().enumerate() {
print_text_with_coordinates(
key_hint_text(line),
column_x,
y + 2 + row,
Some(column_wi... |
rust_dataset_chunk_511061 | rust_dataset.txt | 511,061 | 512 | -plugins/session-manager/src/inbox.rs ---
use std::collections::VecDeque;
use std::ops::Range;
use unicode_width::UnicodeWidthStr;
use zellij_tile::prelude::*;
use crate::app_panel::focus_session_pane;
use crate::panel::truncate_plain;
pub const JUST_NOW_SECONDS: u64 = 10;
pub const PREFERRED_TEXT_WIDTH: usize = 24;... |
rust_dataset_chunk_511062 | rust_dataset.txt | 511,062 | 512 | 100;
pub const WATCHING_EMPHASIS: usize = 3;
pub const SESSION_EMPHASIS: usize = 1;
pub fn spinner_frame(now: u64) -> &'static str {
SPINNER_FRAMES[((now / SPINNER_FRAME_MS) % SPINNER_FRAMES.len() as u64) as usize]
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
pub enum BrowserTab {
#[default]
I... |
rust_dataset_chunk_511063 | rust_dataset.txt | 511,063 | 512 | }
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct SessionsLiveTarget {
pub key: ItemKey,
pub tab: String,
pub pane: String,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct LiveLayout {
pub list_x: usize,
pub list_width: usize,
pub top: usize,
pub list_rows: usize,
pub... |
rust_dataset_chunk_511064 | rust_dataset.txt | 511,064 | 512 | : usize) -> Option<LiveLayout> {
let box_height = height.checked_sub(1)?;
if width < SESSIONS_VIEW_MIN_COLS + 2 || box_height < SESSIONS_VIEW_MIN_ROWS + 2 {
return None;
}
Some(LiveLayout {
list_x: x,
list_width: 0,
top: y,
list... |
rust_dataset_chunk_511065 | rust_dataset.txt | 511,065 | 512 | Status::NewOutput => "New Output",
AttentionStatus::Idle if attention.watched => "Watching",
AttentionStatus::Idle => "Idle",
}
}
pub fn status_and_text(item: &GlobalAttentionItem) -> (String, usize) {
let status = status_title(item);
let detail = row_text(item);
let redundant = detail.... |
rust_dataset_chunk_511066 | rust_dataset.txt | 511,066 | 512 | >,
pub history: Option<SessionHistoryInfo>,
pub tab: BrowserTab,
pub tab_chosen: bool,
pub only_here: bool,
pub show_quiet: bool,
pub group_by_session: bool,
pub selection: Option<ItemKey>,
pub clock_armed: bool,
pub spinner_armed: bool,
pub card_targets: Vec<(usize, Range<usize>... |
rust_dataset_chunk_511067 | rust_dataset.txt | 511,067 | 512 | (&self, item: &GlobalAttentionItem) -> bool {
item.item.attention.effective_status() == self.status
&& item.item.attention.since_ms <= self.since_ms
}
}
fn recalled(item: &GlobalAttentionItem) -> Option<GlobalAttentionItem> {
let attention = &item.item.attention;
if !attention.status.is... |
rust_dataset_chunk_511068 | rust_dataset.txt | 511,068 | 512 | {}", secs / 86400, ago)
}
}
pub fn age_label_changes_in_ms(since_ms: u64, now_ms: u64) -> u64 {
let age = now_ms.saturating_sub(since_ms);
let step = |unit: u64| unit - age % unit;
if age < JUST_NOW_SECONDS * 1000 {
JUST_NOW_SECONDS * 1000 - age
} else if age < 60_000 {
60_000 - age... |
rust_dataset_chunk_511069 | rust_dataset.txt | 511,069 | 512 | usize)>,
now: u64,
width: usize,
) -> Self {
let mut widths = ColumnWidths {
session: 0,
pane: 0,
age: 0,
compact_age: false,
};
let mut compact_age = 0;
for (item, indent) in items {
widths.session = widths... |
rust_dataset_chunk_511070 | rust_dataset.txt | 511,070 | 512 | , item: &GlobalAttentionItem) -> Text {
let text = Text::from(self.line.as_str());
if item.is_muted() {
return text.dim_all();
}
let session_start = self.symbol_len + 1;
let status = item.item.attention.effective_status();
let text = if status.is_idle() && ite... |
rust_dataset_chunk_511071 | rust_dataset.txt | 511,071 | 512 | , text_width);
let age = if widths.age == 0 {
String::new()
} else {
format!(
" {}",
pad_left_to(
&age_label(item.item.attention.since_ms, now, widths.compact_age),
widths.age,
)
)
};
let line = format!("{}{}{} ... |
rust_dataset_chunk_511072 | rust_dataset.txt | 511,072 | 512 | osen {
self.tab = if !self.has_rows() {
BrowserTab::Sessions
} else {
BrowserTab::Inbox
};
}
true
}
pub fn update_history(&mut self, history: SessionHistoryInfo) -> bool {
if self.history.as_ref() == Some(&history) {
... |
rust_dataset_chunk_511073 | rust_dataset.txt | 511,073 | 512 | .iter()
.find(|item| item.is_same_pane(&key.session, &key.pane_id))
}
fn session_runs(&self, session: &str) -> bool {
self.global
.as_ref()
.map(|global| global.has_session(session))
.unwrap_or(true)
}
fn refresh_listed(&mut self) {
let ... |
rust_dataset_chunk_511074 | rust_dataset.txt | 511,074 | 512 | .shown_items = items;
self.held = held;
}
fn is_dropped(&self, key: &ItemKey) -> bool {
self.dropped.iter().any(|dropped| dropped.key == *key)
}
fn drop_key(&mut self, key: &ItemKey) {
if self.is_dropped(key) {
return;
}
let known = self
... |
rust_dataset_chunk_511075 | rust_dataset.txt | 511,075 | 512 | order.get(position.min(order.len().saturating_sub(1))))
.map(|index| ItemKey::of(&self.items()[*index]));
}
pub fn forget_closed_panes_here(&mut self, open_panes: &[u32]) -> bool {
self.forget_listed_where(|known| {
known.is_current
&& matches!(known.item.pane_i... |
rust_dataset_chunk_511076 | rust_dataset.txt | 511,076 | 512 | = !self.show_quiet;
self.list_scroll = 0;
self.rebuild_items();
}
pub fn toggle_grouping(&mut self) {
self.group_by_session = !self.group_by_session;
self.list_scroll = 0;
}
pub fn sections(&self) -> Vec<(Group, Vec<usize>)> {
let mut sections: Vec<(Group, Vec<... |
rust_dataset_chunk_511077 | rust_dataset.txt | 511,077 | 512 | y.since_ms
.cmp(&x.since_ms)
.then(a.session.cmp(&b.session))
.then(a.item.pane_id.cmp(&b.item.pane_id))
};
by_section.then(within)
});
shown
}
pub fn quiet_count(&self) -> usize {
self.i... |
rust_dataset_chunk_511078 | rust_dataset.txt | 511,078 | 512 | let counted = || {
order
.iter()
.map(|index| &self.items()[*index])
.filter(|item| item.is_counted() && !self.is_held(&ItemKey::of(item)))
};
let newest = counted()
.find(|item| !item.item.attention.watched)
.or_else(|... |
rust_dataset_chunk_511079 | rust_dataset.txt | 511,079 | 512 | let (nothing, back_to) = if counted.is_empty() {
(
Some(format!(
"Nothing needs you · {} running",
self.running_count()
)),
self.previous_session(),
)
} else {
(None, None)
... |
rust_dataset_chunk_511080 | rust_dataset.txt | 511,080 | 512 | ::start(crate::timers::TimerOwner::Clock, seconds);
self.clock_armed = true;
}
}
pub fn go_to_selected(&self) -> bool {
match self.selected_target() {
Some(item) => {
focus_session_pane(&item.session, item.item.pane_id);
true
}... |
rust_dataset_chunk_511081 | rust_dataset.txt | 511,081 | 512 | cols: usize) {
let (inbox, sessions) = self.tab_titles(sessions);
let base = format!(" {} │ {}", inbox, sessions);
let tab_hint = [TAB_SWITCH_HINT, "<TAB>", ""]
.into_iter()
.find(|hint| base.width() + 2 + hint.width() < cols)
.unwrap_or("");
let line... |
rust_dataset_chunk_511082 | rust_dataset.txt | 511,082 | 512 | if self.views_own_session() {
return self.own_resize_allowed;
}
self.resize_allowed
.or_else(|| {
self.live
.as_ref()
.filter(|live| {
live.target
.as_ref()
... |
rust_dataset_chunk_511083 | rust_dataset.txt | 511,083 | 512 | self.capture_tab = None;
}
pub fn live_view_request(&self, layout: &LiveLayout) -> LiveView {
let (x, y, cols, rows) = layout.view_rect();
let target = match self.live_view_target() {
Some(key) => PaneAddress::local(key.session, key.pane_id),
None => PaneAddress::local(... |
rust_dataset_chunk_511084 | rust_dataset.txt | 511,084 | 512 | (SESSION_COLUMN_MAX)
}
fn row_head_width(session_width: usize) -> usize {
if session_width == 0 {
2
} else {
session_width + 4
}
}
fn natural_list_width(&self) -> usize {
let order = self.ordered();
let head = Self::row_head_width(self.se... |
rust_dataset_chunk_511085 | rust_dataset.txt | 511,085 | 512 | : sent.resize_allowed,
view_only: false,
};
if *sent == hidden {
return;
}
set_live_view(Some(hidden.clone()));
self.live_view_sent = Some(hidden);
}
pub fn clear_live_view(&mut self) {
if self.live_view_sent.take().is_some() {
... |
rust_dataset_chunk_511086 | rust_dataset.txt | 511,086 | 512 | {
let key = ItemKey {
session: target.session.clone(),
pane_id: target.pane_id,
};
self.drop_key(&key);
let session_ended =
status.state == MirrorState::Closed(MirrorClosedReason::SessionEnding);
changed ... |
rust_dataset_chunk_511087 | rust_dataset.txt | 511,087 | 512 | State::Connecting) => String::new(),
Some(MirrorState::NoTarget) => "no pane selected".to_owned(),
Some(MirrorState::Live) => String::new(),
Some(MirrorState::Closed(reason)) => {
format!("closed: {}", closed_reason_text(reason))
},
}
}
pu... |
rust_dataset_chunk_511088 | rust_dataset.txt | 511,088 | 512 | _ascii_case(status)
|| detail.eq_ignore_ascii_case(WATCHING_TEXT);
let line = if redundant {
status.to_owned()
} else {
format!("{} · {}", status, detail)
};
let title = self.cut_title(item).and_then(|title| {
let room = width.saturating_su... |
rust_dataset_chunk_511089 | rust_dataset.txt | 511,089 | 512 | &mut self,
x: usize,
y: usize,
cols: usize,
rows: usize,
simplified_ui: bool,
) {
self.browser_targets
.retain(|(_, _, t)| matches!(t, BrowserTarget::Tab(_)));
self.live_layout = None;
if let Some(layout) = self.plan_live_layout(x, ... |
rust_dataset_chunk_511090 | rust_dataset.txt | 511,090 | 512 | help_block(width, true)
.last()
.map(|line| line.text.width())
.unwrap_or(0);
detail_need > 0 && help_need + detail_need + details.width() + 4 > width
};
let tabs_row = self.tabs_row.take();
if crowded && !details.is_empty() {
... |
rust_dataset_chunk_511091 | rust_dataset.txt | 511,091 | 512 | fn render_list_browser(
&mut self,
x: usize,
y: usize,
cols: usize,
rows: usize,
simplified_ui: bool,
) {
let now = now_ms();
let body_y = y + 1;
let body_rows = rows.saturating_sub(1);
let available_width = cols.saturating_sub(4).m... |
rust_dataset_chunk_511092 | rust_dataset.txt | 511,092 | 512 | top,
None,
None,
);
}
if below > 0 {
print_text_with_coordinates(
Text::from(format!("↓ {} more", below).as_str()).dim_all(),
left,
item_top + item_rows,
None,
... |
rust_dataset_chunk_511093 | rust_dataset.txt | 511,093 | 512 | _default()
} else {
state_word
};
let state = if state_word.is_empty() {
String::new()
} else {
truncate_plain(&format!(" {} ", state_word), inner / 2)
};
let title_room = inner.saturating_sub(state.width());
let prefix = symbol... |
rust_dataset_chunk_511094 | rust_dataset.txt | 511,094 | 512 | pub fn render_live_view_box(&mut self, layout: &LiveLayout) {
let x = layout.box_x;
let y = layout.top;
let width = layout.box_width;
let height = layout.box_height;
for row in y..y + height {
self.browser_targets
.push((row, x..x + width, BrowserTarg... |
rust_dataset_chunk_511095 | rust_dataset.txt | 511,095 | 512 | , Some(detail_room), None);
}
if !hint.is_empty() {
let text = self.view_hint(&hint, capturing);
print_text_with_coordinates(text, hint_x, layout.status_y, Some(hint_width), None);
}
}
fn view_hint(&self, hint: &str, capturing: bool) -> Text {
if capturin... |
rust_dataset_chunk_511096 | rust_dataset.txt | 511,096 | 512 | self.item_ranges.iter().filter(|r| r.start < scroll).count();
let below = self
.item_ranges
.iter()
.filter(|r| r.start >= scroll && r.end > shown_end)
.count();
(above, below)
}
fn primary_hints(&self, live: bool) -> Vec<(crate::help::Hint, Item... |
rust_dataset_chunk_511097 | rust_dataset.txt | 511,097 | 512 | ", "all keys"),
width,
)
}
fn render_help_block(
&mut self,
help: &[crate::help::BlockLine],
x: usize,
y: usize,
width: usize,
live: bool,
) {
crate::help::render_block(help, x, y, width);
let actions = self.primary_hints(l... |
rust_dataset_chunk_511098 | rust_dataset.txt | 511,098 | 512 | ) == selected;
let start = if member == 0 {
header_start
} else {
lines.len()
};
let held = self.is_held(&ItemKey::of(&item));
let mut text = pane_row(
&item,
s... |
rust_dataset_chunk_511099 | rust_dataset.txt | 511,099 | 512 | simplified_ui: bool,
) {
let now = now_ms();
let content = self.card_content(now);
self.card_targets.clear();
let width = cols;
let inner = width.saturating_sub(2);
let content_x = 2;
let content_width = width.saturating_sub(4);
let title = match self... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.