Misc formatting fixes
This commit is contained in:
parent
781572096e
commit
bde4dacc79
|
@ -1,6 +1,7 @@
|
||||||
//! Clipboard access on macOS
|
//! Clipboard access on macOS
|
||||||
//!
|
//!
|
||||||
//! Implemented according to https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/PasteboardGuide106/Articles/pbReading.html#//apple_ref/doc/uid/TP40008123-SW1
|
//! Implemented according to
|
||||||
|
//! https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/PasteboardGuide106/Articles/pbReading.html#//apple_ref/doc/uid/TP40008123-SW1
|
||||||
|
|
||||||
mod ns {
|
mod ns {
|
||||||
extern crate objc_id;
|
extern crate objc_id;
|
||||||
|
@ -62,22 +63,25 @@ mod ns {
|
||||||
};
|
};
|
||||||
|
|
||||||
let classes: Id<NSArray<NSObject, Owned>> = unsafe {
|
let classes: Id<NSArray<NSObject, Owned>> = unsafe {
|
||||||
// I think this transmute is valid. It's going from an Id<Object> to an
|
// I think this transmute is valid. It's going from an
|
||||||
// Id<NSObject>. From transmute's perspective, the only thing that matters is that
|
// Id<Object> to an Id<NSObject>. From transmute's perspective,
|
||||||
// they both have the same size (they do for now since the generic is phantom data).
|
// the only thing that matters is that they both have the same
|
||||||
// In both cases, the underlying pointer is an id (from `[NSString class]`), so
|
// size (they do for now since the generic is phantom data). In
|
||||||
// again, this should be valid. There's just nothing implemented in objc_id or
|
// both cases, the underlying pointer is an id (from `[NSString
|
||||||
// objc_foundation to do this "safely". By the way, the only reason this is
|
// class]`), so again, this should be valid. There's just
|
||||||
// necessary is because INSObject isn't implemented for Id<Object>.
|
// nothing implemented in objc_id or objc_foundation to do this
|
||||||
|
// "safely". By the way, the only reason this is necessary is
|
||||||
|
// because INSObject isn't implemented for Id<Object>.
|
||||||
//
|
//
|
||||||
// And if that argument isn't convincing, my final reasoning is that "it seems to
|
// And if that argument isn't convincing, my final reasoning is
|
||||||
// work".
|
// that "it seems to work".
|
||||||
NSArray::from_vec(vec![mem::transmute(ns_string)])
|
NSArray::from_vec(vec![mem::transmute(ns_string)])
|
||||||
};
|
};
|
||||||
|
|
||||||
// No options
|
// No options
|
||||||
//
|
//
|
||||||
// Apparently this doesn't compile without a type hint, so it maps objects to objects!
|
// Apparently this doesn't compile without a type hint, so it maps
|
||||||
|
// objects to objects!
|
||||||
let options: Id<NSDictionary<NSObject, NSObject>> = NSDictionary::new();
|
let options: Id<NSDictionary<NSObject, NSObject>> = NSDictionary::new();
|
||||||
|
|
||||||
// call [pasteboard readObjectsForClasses:options:]
|
// call [pasteboard readObjectsForClasses:options:]
|
||||||
|
@ -95,8 +99,10 @@ mod ns {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Ok, this is great. We have an NSArray<NSString>, and these have decent bindings. Use
|
// Ok, this is great. We have an NSArray<NSString>, and these have
|
||||||
// the first item returned (if an item was returned) or just return an empty string
|
// decent bindings. Use the first item returned (if an item was
|
||||||
|
// returned) or just return an empty string
|
||||||
|
//
|
||||||
// XXX Should this return an error if no items were returned?
|
// XXX Should this return an error if no items were returned?
|
||||||
let contents = copied_items
|
let contents = copied_items
|
||||||
.first_object()
|
.first_object()
|
||||||
|
|
|
@ -226,9 +226,15 @@ impl Descriptor {
|
||||||
|
|
||||||
impl Font {
|
impl Font {
|
||||||
/// The the bounding rect of a glyph
|
/// The the bounding rect of a glyph
|
||||||
pub fn bounding_rect_for_glyph(&self, orientation: FontOrientation, index: u32) -> Rect<f64> {
|
pub fn bounding_rect_for_glyph(
|
||||||
let cg_rect = self.ct_font.get_bounding_rects_for_glyphs(orientation as CTFontOrientation,
|
&self,
|
||||||
&[index as CGGlyph]);
|
orientation: FontOrientation,
|
||||||
|
index: u32
|
||||||
|
) -> Rect<f64> {
|
||||||
|
let cg_rect = self.ct_font.get_bounding_rects_for_glyphs(
|
||||||
|
orientation as CTFontOrientation,
|
||||||
|
&[index as CGGlyph]
|
||||||
|
);
|
||||||
|
|
||||||
Rect::new(
|
Rect::new(
|
||||||
Point2D::new(cg_rect.origin.x, cg_rect.origin.y),
|
Point2D::new(cg_rect.origin.x, cg_rect.origin.y),
|
||||||
|
@ -255,10 +261,12 @@ impl Font {
|
||||||
|
|
||||||
let indices = [index as CGGlyph];
|
let indices = [index as CGGlyph];
|
||||||
|
|
||||||
self.ct_font.get_advances_for_glyphs(FontOrientation::Default as _,
|
self.ct_font.get_advances_for_glyphs(
|
||||||
&indices[0],
|
FontOrientation::Default as _,
|
||||||
ptr::null_mut(),
|
&indices[0],
|
||||||
1)
|
ptr::null_mut(),
|
||||||
|
1
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_glyph(&self, character: char, _size: f64) -> RasterizedGlyph {
|
pub fn get_glyph(&self, character: char, _size: f64) -> RasterizedGlyph {
|
||||||
|
@ -297,19 +305,25 @@ impl Font {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut cg_context = CGContext::create_bitmap_context(rasterized_width as usize,
|
let mut cg_context = CGContext::create_bitmap_context(
|
||||||
rasterized_height as usize,
|
rasterized_width as usize,
|
||||||
8, // bits per component
|
rasterized_height as usize,
|
||||||
rasterized_width as usize * 4,
|
8, // bits per component
|
||||||
&CGColorSpace::create_device_rgb(),
|
rasterized_width as usize * 4,
|
||||||
kCGImageAlphaPremultipliedFirst |
|
&CGColorSpace::create_device_rgb(),
|
||||||
kCGBitmapByteOrder32Host);
|
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host
|
||||||
|
);
|
||||||
|
|
||||||
// Give the context an opaque, black background
|
// Give the context an opaque, black background
|
||||||
cg_context.set_rgb_fill_color(0.0, 0.0, 0.0, 1.0);
|
cg_context.set_rgb_fill_color(0.0, 0.0, 0.0, 1.0);
|
||||||
let context_rect = CGRect::new(&CGPoint::new(0.0, 0.0),
|
let context_rect = CGRect::new(
|
||||||
&CGSize::new(rasterized_width as f64,
|
&CGPoint::new(0.0, 0.0),
|
||||||
rasterized_height as f64));
|
&CGSize::new(
|
||||||
|
rasterized_width as f64,
|
||||||
|
rasterized_height as f64
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
cg_context.fill_rect(context_rect);
|
cg_context.fill_rect(context_rect);
|
||||||
|
|
||||||
// Uses thin strokes
|
// Uses thin strokes
|
||||||
|
@ -354,7 +368,11 @@ impl Font {
|
||||||
let chars = [character as UniChar];
|
let chars = [character as UniChar];
|
||||||
let mut glyphs = [0 as CGGlyph];
|
let mut glyphs = [0 as CGGlyph];
|
||||||
|
|
||||||
let res = self.ct_font.get_glyphs_for_characters(&chars[0], &mut glyphs[0], 1 as CFIndex);
|
let res = self.ct_font.get_glyphs_for_characters(
|
||||||
|
&chars[0],
|
||||||
|
&mut glyphs[0],
|
||||||
|
1 as CFIndex
|
||||||
|
);
|
||||||
|
|
||||||
if res {
|
if res {
|
||||||
Some(glyphs[0] as u32)
|
Some(glyphs[0] as u32)
|
||||||
|
|
|
@ -65,7 +65,11 @@ fn list_families() -> Vec<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut id = 0;
|
let mut id = 0;
|
||||||
while FcPatternGetString(*font, b"family\0".as_ptr() as *mut c_char, id, &mut family) == FcResultMatch {
|
while FcPatternGetString(
|
||||||
|
*font,
|
||||||
|
b"family\0".as_ptr() as *mut c_char,
|
||||||
|
id, &mut family
|
||||||
|
) == FcResultMatch {
|
||||||
let safe_family = fc_char8_to_string(family);
|
let safe_family = fc_char8_to_string(family);
|
||||||
id += 1;
|
id += 1;
|
||||||
families.push(safe_family);
|
families.push(safe_family);
|
||||||
|
@ -139,7 +143,11 @@ pub fn get_family_info(family: String) -> Family {
|
||||||
let family_name = family_name.as_ptr();
|
let family_name = family_name.as_ptr();
|
||||||
|
|
||||||
// Add family name to pattern. Use this for searching.
|
// Add family name to pattern. Use this for searching.
|
||||||
FcPatternAddString(pattern, FAMILY.as_ptr() as *mut c_char, family_name as *mut FcChar8);
|
FcPatternAddString(
|
||||||
|
pattern,
|
||||||
|
FAMILY.as_ptr() as *mut c_char,
|
||||||
|
family_name as *mut FcChar8
|
||||||
|
);
|
||||||
|
|
||||||
// Request filename, style, and index for each variant in family
|
// Request filename, style, and index for each variant in family
|
||||||
let object_set = FcObjectSetCreate(); // *mut FcObjectSet
|
let object_set = FcObjectSetCreate(); // *mut FcObjectSet
|
||||||
|
@ -147,7 +155,13 @@ pub fn get_family_info(family: String) -> Family {
|
||||||
FcObjectSetAdd(object_set, INDEX.as_ptr() as *mut c_char);
|
FcObjectSetAdd(object_set, INDEX.as_ptr() as *mut c_char);
|
||||||
FcObjectSetAdd(object_set, STYLE.as_ptr() as *mut c_char);
|
FcObjectSetAdd(object_set, STYLE.as_ptr() as *mut c_char);
|
||||||
|
|
||||||
let variants = FcFontSetList(config, &mut font_set, 1 /* nsets */, pattern, object_set);
|
let variants = FcFontSetList(
|
||||||
|
config,
|
||||||
|
&mut font_set,
|
||||||
|
1 /* nsets */,
|
||||||
|
pattern, object_set
|
||||||
|
);
|
||||||
|
|
||||||
let num_variant = (*variants).nfont as isize;
|
let num_variant = (*variants).nfont as isize;
|
||||||
|
|
||||||
for i in 0..num_variant {
|
for i in 0..num_variant {
|
||||||
|
|
|
@ -117,7 +117,10 @@ impl Rasterizer {
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let ft_lib = self.library.raw();
|
let ft_lib = self.library.raw();
|
||||||
freetype::ffi::FT_Library_SetLcdFilter(ft_lib, freetype::ffi::FT_LCD_FILTER_DEFAULT);
|
freetype::ffi::FT_Library_SetLcdFilter(
|
||||||
|
ft_lib,
|
||||||
|
freetype::ffi::FT_LCD_FILTER_DEFAULT
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let bitmap = glyph.bitmap();
|
let bitmap = glyph.bitmap();
|
||||||
|
|
|
@ -14,11 +14,9 @@
|
||||||
//
|
//
|
||||||
//! Compatibility layer for different font engines
|
//! Compatibility layer for different font engines
|
||||||
//!
|
//!
|
||||||
//! This module is developed as part of Alacritty; Alacritty does not include Windows support
|
|
||||||
//! as a goal at this time, and neither does this module.
|
|
||||||
//!
|
|
||||||
//! CoreText is used on Mac OS.
|
//! CoreText is used on Mac OS.
|
||||||
//! FreeType is used on everything that's not Mac OS.
|
//! FreeType is used on everything that's not Mac OS.
|
||||||
|
//! Eventually, ClearType support will be available for windows
|
||||||
#![feature(integer_atomics)]
|
#![feature(integer_atomics)]
|
||||||
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
|
49
src/ansi.rs
49
src/ansi.rs
|
@ -176,13 +176,14 @@ pub trait Handler {
|
||||||
|
|
||||||
/// Erase `count` chars in current line following cursor
|
/// Erase `count` chars in current line following cursor
|
||||||
///
|
///
|
||||||
/// Erase means resetting to the default state (default colors, no content, no mode flags)
|
/// Erase means resetting to the default state (default colors, no content,
|
||||||
|
/// no mode flags)
|
||||||
fn erase_chars(&mut self, Column) {}
|
fn erase_chars(&mut self, Column) {}
|
||||||
|
|
||||||
/// Delete `count` chars
|
/// Delete `count` chars
|
||||||
///
|
///
|
||||||
/// Deleting a character is like the delete key on the keyboard - everything to the right of the
|
/// Deleting a character is like the delete key on the keyboard - everything
|
||||||
/// deleted things is shifted left.
|
/// to the right of the deleted things is shifted left.
|
||||||
fn delete_chars(&mut self, Column) {}
|
fn delete_chars(&mut self, Column) {}
|
||||||
|
|
||||||
/// Move backward `count` tabs
|
/// Move backward `count` tabs
|
||||||
|
@ -211,8 +212,9 @@ pub trait Handler {
|
||||||
|
|
||||||
/// Reverse Index
|
/// Reverse Index
|
||||||
///
|
///
|
||||||
/// Move the active position to the same horizontal position on the preceding line. If the
|
/// Move the active position to the same horizontal position on the
|
||||||
/// active position is at the top margin, a scroll down is performed
|
/// preceding line. If the active position is at the top margin, a scroll
|
||||||
|
/// down is performed
|
||||||
fn reverse_index(&mut self) {}
|
fn reverse_index(&mut self) {}
|
||||||
|
|
||||||
/// set a terminal attribute
|
/// set a terminal attribute
|
||||||
|
@ -690,7 +692,13 @@ impl<'a, H, W> vte::Perform for Performer<'a, H, W>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn esc_dispatch(&mut self, params: &[i64], intermediates: &[u8], _ignore: bool, byte: u8) {
|
fn esc_dispatch(
|
||||||
|
&mut self,
|
||||||
|
params: &[i64],
|
||||||
|
intermediates: &[u8],
|
||||||
|
_ignore: bool,
|
||||||
|
byte: u8
|
||||||
|
) {
|
||||||
match byte {
|
match byte {
|
||||||
b'D' => self.handler.linefeed(),
|
b'D' => self.handler.linefeed(),
|
||||||
b'E' => self.handler.newline(),
|
b'E' => self.handler.newline(),
|
||||||
|
@ -998,19 +1006,22 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_zsh_startup() {
|
fn parse_zsh_startup() {
|
||||||
static BYTES: &'static [u8] = &[
|
static BYTES: &'static [u8] = &[
|
||||||
0x1b, 0x5b, 0x31, 0x6d, 0x1b, 0x5b, 0x37, 0x6d, 0x25, 0x1b, 0x5b, 0x32, 0x37, 0x6d,
|
0x1b, 0x5b, 0x31, 0x6d, 0x1b, 0x5b, 0x37, 0x6d, 0x25, 0x1b, 0x5b,
|
||||||
0x1b, 0x5b, 0x31, 0x6d, 0x1b, 0x5b, 0x30, 0x6d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
0x32, 0x37, 0x6d, 0x1b, 0x5b, 0x31, 0x6d, 0x1b, 0x5b, 0x30, 0x6d,
|
||||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||||
0x20, 0x20, 0x20, 0x0d, 0x20, 0x0d, 0x0d, 0x1b, 0x5b, 0x30, 0x6d, 0x1b, 0x5b, 0x32,
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||||
0x37, 0x6d, 0x1b, 0x5b, 0x32, 0x34, 0x6d, 0x1b, 0x5b, 0x4a, 0x6a, 0x77, 0x69, 0x6c,
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||||
0x6d, 0x40, 0x6a, 0x77, 0x69, 0x6c, 0x6d, 0x2d, 0x64, 0x65, 0x73, 0x6b, 0x20, 0x1b,
|
0x20, 0x20, 0x0d, 0x20, 0x0d, 0x0d, 0x1b, 0x5b, 0x30, 0x6d, 0x1b,
|
||||||
0x5b, 0x30, 0x31, 0x3b, 0x33, 0x32, 0x6d, 0xe2, 0x9e, 0x9c, 0x20, 0x1b, 0x5b, 0x30,
|
0x5b, 0x32, 0x37, 0x6d, 0x1b, 0x5b, 0x32, 0x34, 0x6d, 0x1b, 0x5b,
|
||||||
0x31, 0x3b, 0x33, 0x32, 0x6d, 0x20, 0x1b, 0x5b, 0x33, 0x36, 0x6d, 0x7e, 0x2f, 0x63,
|
0x4a, 0x6a, 0x77, 0x69, 0x6c, 0x6d, 0x40, 0x6a, 0x77, 0x69, 0x6c,
|
||||||
0x6f, 0x64, 0x65
|
0x6d, 0x2d, 0x64, 0x65, 0x73, 0x6b, 0x20, 0x1b, 0x5b, 0x30, 0x31,
|
||||||
|
0x3b, 0x33, 0x32, 0x6d, 0xe2, 0x9e, 0x9c, 0x20, 0x1b, 0x5b, 0x30,
|
||||||
|
0x31, 0x3b, 0x33, 0x32, 0x6d, 0x20, 0x1b, 0x5b, 0x33, 0x36, 0x6d,
|
||||||
|
0x7e, 0x2f, 0x63, 0x6f, 0x64, 0x65
|
||||||
];
|
];
|
||||||
|
|
||||||
let mut handler = AttrHandler::default();
|
let mut handler = AttrHandler::default();
|
||||||
|
|
|
@ -459,7 +459,10 @@ impl de::Deserialize for RawBinding {
|
||||||
impl Visitor for RawBindingVisitor {
|
impl Visitor for RawBindingVisitor {
|
||||||
type Value = RawBinding;
|
type Value = RawBinding;
|
||||||
|
|
||||||
fn visit_map<V>(&mut self, mut visitor: V) -> ::std::result::Result<RawBinding, V::Error>
|
fn visit_map<V>(
|
||||||
|
&mut self,
|
||||||
|
mut visitor: V
|
||||||
|
) -> ::std::result::Result<RawBinding, V::Error>
|
||||||
where V: MapVisitor,
|
where V: MapVisitor,
|
||||||
{
|
{
|
||||||
let mut mods: Option<::glutin::Mods> = None;
|
let mut mods: Option<::glutin::Mods> = None;
|
||||||
|
@ -1129,7 +1132,8 @@ impl Monitor {
|
||||||
if op.contains(op::IGNORED) {
|
if op.contains(op::IGNORED) {
|
||||||
if let Some(path) = path.as_ref() {
|
if let Some(path) = path.as_ref() {
|
||||||
if let Err(err) = watcher.watch(&path) {
|
if let Err(err) = watcher.watch(&path) {
|
||||||
err_println!("failed to establish watch on {:?}: {:?}", path, err);
|
err_println!("failed to establish watch on {:?}: {:?}",
|
||||||
|
path, err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,7 +176,11 @@ impl Display {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Process pending resize events
|
/// Process pending resize events
|
||||||
pub fn handle_resize(&mut self, terminal: &mut MutexGuard<Term>, items: &mut [&mut OnResize]) {
|
pub fn handle_resize(
|
||||||
|
&mut self,
|
||||||
|
terminal: &mut MutexGuard<Term>,
|
||||||
|
items: &mut [&mut OnResize]
|
||||||
|
) {
|
||||||
// Resize events new_size and are handled outside the poll_events
|
// Resize events new_size and are handled outside the poll_events
|
||||||
// iterator. This has the effect of coalescing multiple resize
|
// iterator. This has the effect of coalescing multiple resize
|
||||||
// events into one.
|
// events into one.
|
||||||
|
|
|
@ -174,7 +174,14 @@ impl<Io> EventLoop<Io>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn pty_read<W: Write>(&mut self, state: &mut State, buf: &mut [u8], mut writer: Option<&mut W>) {
|
fn pty_read<W>(
|
||||||
|
&mut self,
|
||||||
|
state: &mut State,
|
||||||
|
buf: &mut [u8],
|
||||||
|
mut writer: Option<&mut W>
|
||||||
|
)
|
||||||
|
where W: Write
|
||||||
|
{
|
||||||
loop {
|
loop {
|
||||||
match self.pty.read(&mut buf[..]) {
|
match self.pty.read(&mut buf[..]) {
|
||||||
Ok(0) => break,
|
Ok(0) => break,
|
||||||
|
@ -234,7 +241,10 @@ impl<Io> EventLoop<Io>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn spawn(mut self, state: Option<State>) -> thread::JoinHandle<(EventLoop<Io>, State)> {
|
pub fn spawn(
|
||||||
|
mut self,
|
||||||
|
state: Option<State>
|
||||||
|
) -> thread::JoinHandle<(EventLoop<Io>, State)> {
|
||||||
thread::spawn_named("pty reader", move || {
|
thread::spawn_named("pty reader", move || {
|
||||||
let mut state = state.unwrap_or_else(Default::default);
|
let mut state = state.unwrap_or_else(Default::default);
|
||||||
let mut buf = [0u8; 4096];
|
let mut buf = [0u8; 4096];
|
||||||
|
|
|
@ -331,9 +331,9 @@ row_index_range!(RangeTo<usize>);
|
||||||
row_index_range!(RangeFrom<usize>);
|
row_index_range!(RangeFrom<usize>);
|
||||||
row_index_range!(RangeFull);
|
row_index_range!(RangeFull);
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Row ranges for Grid
|
// Row ranges for Grid
|
||||||
// -------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
impl<T> Index<Range<index::Line>> for Grid<T> {
|
impl<T> Index<Range<index::Line>> for Grid<T> {
|
||||||
type Output = [Row<T>];
|
type Output = [Row<T>];
|
||||||
|
@ -383,9 +383,9 @@ impl<T> IndexMut<RangeFrom<index::Line>> for Grid<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Column ranges for Row
|
// Column ranges for Row
|
||||||
// -------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
impl<T> Index<Range<index::Column>> for Row<T> {
|
impl<T> Index<Range<index::Column>> for Row<T> {
|
||||||
type Output = [T];
|
type Output = [T];
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
//! let _sampler = meter.sampler();
|
//! let _sampler = meter.sampler();
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! // Get the moving average. The meter tracks a fixed number of samles, and the average won't mean
|
//! // Get the moving average. The meter tracks a fixed number of samles, and
|
||||||
//! // much until it's filled up at least once.
|
//! // the average won't mean much until it's filled up at least once.
|
||||||
//! println!("Average time: {}", meter.average());
|
//! println!("Average time: {}", meter.average());
|
||||||
|
|
||||||
use std::time::{Instant, Duration};
|
use std::time::{Instant, Duration};
|
||||||
|
|
|
@ -127,7 +127,9 @@ impl GlyphCache {
|
||||||
|
|
||||||
// Load regular font
|
// Load regular font
|
||||||
let regular_desc = FontDesc::new(font.family(), font.style());
|
let regular_desc = FontDesc::new(font.family(), font.style());
|
||||||
let regular = rasterizer.load_font(®ular_desc, size).expect("regular font load ok");
|
let regular = rasterizer
|
||||||
|
.load_font(®ular_desc, size)
|
||||||
|
.expect("regular font load ok");
|
||||||
|
|
||||||
// Load bold font
|
// Load bold font
|
||||||
let bold_style = font.bold_style().unwrap_or("Bold");
|
let bold_style = font.bold_style().unwrap_or("Bold");
|
||||||
|
@ -1192,8 +1194,9 @@ impl Atlas {
|
||||||
|
|
||||||
/// Insert the glyph without checking for room
|
/// Insert the glyph without checking for room
|
||||||
///
|
///
|
||||||
/// Internal function for use once atlas has been checked for space. GL errors could still occur
|
/// Internal function for use once atlas has been checked for space. GL
|
||||||
/// at this point if we were checking for them; hence, the Result.
|
/// errors could still occur at this point if we were checking for them;
|
||||||
|
/// hence, the Result.
|
||||||
fn insert_inner(&mut self,
|
fn insert_inner(&mut self,
|
||||||
glyph: &RasterizedGlyph,
|
glyph: &RasterizedGlyph,
|
||||||
active_tex: &mut u32)
|
active_tex: &mut u32)
|
||||||
|
|
|
@ -343,8 +343,8 @@ impl Term {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scroll up to keep cursor and as much context as possible in grid. This only runs when the
|
// Scroll up to keep cursor and as much context as possible in grid.
|
||||||
// lines decreases.
|
// This only runs when the lines decreases.
|
||||||
self.scroll_region = Line(0)..self.grid.num_lines();
|
self.scroll_region = Line(0)..self.grid.num_lines();
|
||||||
|
|
||||||
// Scroll up to keep cursor in terminal
|
// Scroll up to keep cursor in terminal
|
||||||
|
@ -366,8 +366,9 @@ impl Term {
|
||||||
self.cursor.col = limit(self.cursor.col, Column(0), num_cols);
|
self.cursor.col = limit(self.cursor.col, Column(0), num_cols);
|
||||||
|
|
||||||
// Recreate tabs list
|
// Recreate tabs list
|
||||||
self.tabs = (Column(0)..self.grid.num_cols()).map(|i| (*i as usize) % TAB_SPACES == 0)
|
self.tabs = (Column(0)..self.grid.num_cols())
|
||||||
.collect::<Vec<bool>>();
|
.map(|i| (*i as usize) % TAB_SPACES == 0)
|
||||||
|
.collect::<Vec<bool>>();
|
||||||
|
|
||||||
self.tabs[0] = false;
|
self.tabs[0] = false;
|
||||||
|
|
||||||
|
@ -707,7 +708,8 @@ impl ansi::Handler for Term {
|
||||||
ptr::copy(src, dst, n);
|
ptr::copy(src, dst, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear last `count` cells in line. If deleting 1 char, need to delete 1 cell.
|
// Clear last `count` cells in line. If deleting 1 char, need to delete
|
||||||
|
// 1 cell.
|
||||||
let template = self.empty_cell.clone();
|
let template = self.empty_cell.clone();
|
||||||
let end = self.size_info.cols() - count;
|
let end = self.size_info.cols() - count;
|
||||||
for c in &mut line[end..] {
|
for c in &mut line[end..] {
|
||||||
|
@ -946,13 +948,13 @@ mod bench {
|
||||||
|
|
||||||
/// Benchmark for the renderable cells iterator
|
/// Benchmark for the renderable cells iterator
|
||||||
///
|
///
|
||||||
/// The renderable cells iterator yields cells that require work to be displayed (that is, not a
|
/// The renderable cells iterator yields cells that require work to be
|
||||||
/// an empty background cell). This benchmark measures how long it takes to process the whole
|
/// displayed (that is, not a an empty background cell). This benchmark
|
||||||
/// iterator.
|
/// measures how long it takes to process the whole iterator.
|
||||||
///
|
///
|
||||||
/// When this benchmark was first added, it averaged ~78usec on my macbook pro. The total
|
/// When this benchmark was first added, it averaged ~78usec on my macbook
|
||||||
/// render time for this grid is anywhere between ~1500 and ~2000usec (measured imprecisely with
|
/// pro. The total render time for this grid is anywhere between ~1500 and
|
||||||
/// the visual meter).
|
/// ~2000usec (measured imprecisely with the visual meter).
|
||||||
#[bench]
|
#[bench]
|
||||||
fn render_iter(b: &mut test::Bencher) {
|
fn render_iter(b: &mut test::Bencher) {
|
||||||
// Need some realistic grid state; using one of the ref files.
|
// Need some realistic grid state; using one of the ref files.
|
||||||
|
|
|
@ -21,7 +21,10 @@ pub mod thread {
|
||||||
T: Send + 'static,
|
T: Send + 'static,
|
||||||
S: Into<String>
|
S: Into<String>
|
||||||
{
|
{
|
||||||
::std::thread::Builder::new().name(name.into()).spawn(f).expect("thread spawn works")
|
::std::thread::Builder::new()
|
||||||
|
.name(name.into())
|
||||||
|
.spawn(f)
|
||||||
|
.expect("thread spawn works")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub use ::std::thread::*;
|
pub use ::std::thread::*;
|
||||||
|
|
Loading…
Reference in New Issue