mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-25 14:05:41 -05:00
Use the log-crate instead of printing to stdout
This commit is contained in:
parent
b23ed6ed4c
commit
64b42cd2f3
17 changed files with 187 additions and 93 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -12,6 +12,7 @@ dependencies = [
|
|||
"glutin 0.6.1 (git+https://github.com/jwilm/glutin?rev=af7fe340bd4a2af53ea521defcb4f377cdc588cf)",
|
||||
"lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mio 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"notify 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -257,6 +258,7 @@ dependencies = [
|
|||
"ffi-util 0.1.0",
|
||||
"freetype-rs 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"servo-fontconfig 0.2.0 (git+https://github.com/jwilm/rust-fontconfig)",
|
||||
]
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ mio = "0.6"
|
|||
serde_json = "*"
|
||||
copypasta = { path = "./copypasta" }
|
||||
xdg = "2.0.0"
|
||||
log = "0.3"
|
||||
|
||||
clippy = { version = "0.0.104", optional = true }
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ license = "Apache-2.0"
|
|||
euclid = "0.6.8"
|
||||
libc = "0.2.11"
|
||||
ffi-util = { path = "../ffi-util" }
|
||||
log = "0.3"
|
||||
|
||||
[target.'cfg(not(target_os = "macos"))'.dependencies]
|
||||
servo-fontconfig = { git = "https://github.com/jwilm/rust-fontconfig" }
|
||||
|
|
|
@ -125,7 +125,7 @@ impl ::Rasterize for Rasterizer {
|
|||
type Err = Error;
|
||||
|
||||
fn new(_dpi_x: f32, _dpi_y: f32, device_pixel_ratio: f32, use_thin_strokes: bool) -> Result<Rasterizer, Error> {
|
||||
println!("device_pixel_ratio: {}", device_pixel_ratio);
|
||||
info!("device_pixel_ratio: {}", device_pixel_ratio);
|
||||
Ok(Rasterizer {
|
||||
fonts: HashMap::new(),
|
||||
keys: HashMap::new(),
|
||||
|
@ -588,7 +588,7 @@ mod tests {
|
|||
fn get_descriptors_and_build_font() {
|
||||
let list = super::descriptors_for_family("Menlo");
|
||||
assert!(!list.is_empty());
|
||||
println!("{:?}", list);
|
||||
info!("{:?}", list);
|
||||
|
||||
// Check to_font
|
||||
let fonts = list.iter()
|
||||
|
|
|
@ -390,7 +390,7 @@ pub mod fc {
|
|||
(*self.as_ptr()).nfont as isize
|
||||
};
|
||||
|
||||
println!("num fonts = {}", num_fonts);
|
||||
info!("num fonts = {}", num_fonts);
|
||||
|
||||
FontSetIter {
|
||||
font_set: self.deref(),
|
||||
|
@ -408,7 +408,7 @@ pub mod fc {
|
|||
(*self.as_ptr()).nfont as isize
|
||||
};
|
||||
|
||||
println!("num fonts = {}", num_fonts);
|
||||
info!("num fonts = {}", num_fonts);
|
||||
|
||||
FontSetIter {
|
||||
font_set: self,
|
||||
|
@ -498,7 +498,7 @@ mod tests {
|
|||
break;
|
||||
}
|
||||
}
|
||||
println!("");
|
||||
info!("");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -520,7 +520,7 @@ mod tests {
|
|||
break;
|
||||
}
|
||||
}
|
||||
println!("");
|
||||
info!("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,9 @@ extern crate libc;
|
|||
#[macro_use]
|
||||
extern crate ffi_util;
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
use std::fmt;
|
||||
use std::sync::atomic::{AtomicU32, ATOMIC_U32_INIT, Ordering};
|
||||
|
||||
|
|
36
src/ansi.rs
36
src/ansi.rs
|
@ -488,39 +488,39 @@ impl<'a, H, W> vte::Perform for Performer<'a, H, W>
|
|||
C1::NEL => self.handler.newline(),
|
||||
C1::HTS => self.handler.set_horizontal_tabstop(),
|
||||
C1::DECID => self.handler.identify_terminal(self.writer),
|
||||
_ => err_println!("[unhandled] execute byte={:02x}", byte)
|
||||
_ => debug!("[unhandled] execute byte={:02x}", byte)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn hook(&mut self, params: &[i64], intermediates: &[u8], ignore: bool) {
|
||||
err_println!("[unhandled hook] params={:?}, ints: {:?}, ignore: {:?}",
|
||||
debug!("[unhandled hook] params={:?}, ints: {:?}, ignore: {:?}",
|
||||
params, intermediates, ignore);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn put(&mut self, byte: u8) {
|
||||
err_println!("[unhandled put] byte={:?}", byte);
|
||||
debug!("[unhandled put] byte={:?}", byte);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn unhook(&mut self) {
|
||||
err_println!("[unhandled unhook]");
|
||||
debug!("[unhandled unhook]");
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn osc_dispatch(&mut self, params: &[&[u8]]) {
|
||||
macro_rules! unhandled {
|
||||
() => {{
|
||||
err_print!("[unhandled osc_dispatch]: [");
|
||||
for param in params {
|
||||
err_print!("[");
|
||||
for byte in *param {
|
||||
err_print!("{:?}, ", *byte as char);
|
||||
let mut buf = String::new();
|
||||
for items in params {
|
||||
buf.push_str("[");
|
||||
for item in *items {
|
||||
buf.push_str(&format!("{:?},", *item as char));
|
||||
}
|
||||
err_print!("],");
|
||||
buf.push_str("],");
|
||||
}
|
||||
err_println!("]");
|
||||
warn!("[unhandled osc_dispatch]: [{}]", &buf);
|
||||
}}
|
||||
}
|
||||
|
||||
|
@ -564,7 +564,7 @@ impl<'a, H, W> vte::Perform for Performer<'a, H, W>
|
|||
|
||||
macro_rules! unhandled {
|
||||
() => {{
|
||||
err_println!("[Unhandled CSI] action={:?}, args={:?}, intermediates={:?}",
|
||||
warn!("[Unhandled CSI] action={:?}, args={:?}, intermediates={:?}",
|
||||
action, args, intermediates);
|
||||
return;
|
||||
}}
|
||||
|
@ -775,7 +775,7 @@ impl<'a, H, W> vte::Perform for Performer<'a, H, W>
|
|||
) {
|
||||
macro_rules! unhandled {
|
||||
() => {{
|
||||
err_println!("[unhandled] esc_dispatch params={:?}, ints={:?}, byte={:?} ({:02x})",
|
||||
warn!("[unhandled] esc_dispatch params={:?}, ints={:?}, byte={:?} ({:02x})",
|
||||
params, intermediates, byte as char, byte);
|
||||
return;
|
||||
}}
|
||||
|
@ -823,7 +823,7 @@ fn parse_color(attrs: &[i64], i: &mut usize) -> Option<Color> {
|
|||
2 => {
|
||||
// RGB color spec
|
||||
if attrs.len() < 5 {
|
||||
err_println!("Expected RGB color spec; got {:?}", attrs);
|
||||
warn!("Expected RGB color spec; got {:?}", attrs);
|
||||
return None;
|
||||
}
|
||||
|
||||
|
@ -835,7 +835,7 @@ fn parse_color(attrs: &[i64], i: &mut usize) -> Option<Color> {
|
|||
|
||||
let range = 0..256;
|
||||
if !range.contains_(r) || !range.contains_(g) || !range.contains_(b) {
|
||||
err_println!("Invalid RGB color spec: ({}, {}, {})", r, g, b);
|
||||
warn!("Invalid RGB color spec: ({}, {}, {})", r, g, b);
|
||||
return None;
|
||||
}
|
||||
|
||||
|
@ -847,7 +847,7 @@ fn parse_color(attrs: &[i64], i: &mut usize) -> Option<Color> {
|
|||
},
|
||||
5 => {
|
||||
if attrs.len() < 3 {
|
||||
err_println!("Expected color index; got {:?}", attrs);
|
||||
warn!("Expected color index; got {:?}", attrs);
|
||||
None
|
||||
} else {
|
||||
*i += 2;
|
||||
|
@ -857,14 +857,14 @@ fn parse_color(attrs: &[i64], i: &mut usize) -> Option<Color> {
|
|||
Some(Color::Indexed(idx as u8))
|
||||
},
|
||||
_ => {
|
||||
err_println!("Invalid color index: {}", idx);
|
||||
warn!("Invalid color index: {}", idx);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
err_println!("Unexpected color attr: {}", attrs[*i+1]);
|
||||
warn!("Unexpected color attr: {}", attrs[*i+1]);
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
13
src/cli.rs
13
src/cli.rs
|
@ -11,16 +11,19 @@
|
|||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
extern crate log;
|
||||
use std::env;
|
||||
use index::{Line, Column};
|
||||
|
||||
|
||||
/// Options specified on the command line
|
||||
pub struct Options {
|
||||
pub print_events: bool,
|
||||
pub ref_test: bool,
|
||||
pub columns: Column,
|
||||
pub lines: Line,
|
||||
pub title: String
|
||||
pub title: String,
|
||||
pub log_level: log::LogLevelFilter
|
||||
}
|
||||
|
||||
impl Default for Options {
|
||||
|
@ -30,7 +33,8 @@ impl Default for Options {
|
|||
ref_test: false,
|
||||
columns: Column(80),
|
||||
lines: Line(24),
|
||||
title: "Alacritty".to_owned()
|
||||
title: "Alacritty".to_owned(),
|
||||
log_level: log::LogLevelFilter::Warn,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +60,11 @@ impl Options {
|
|||
"-t" | "--title" => {
|
||||
args_iter.next().map(|t| options.title = t);
|
||||
},
|
||||
"-q" => options.log_level = log::LogLevelFilter::Error,
|
||||
"-qq" => options.log_level = log::LogLevelFilter::Off,
|
||||
"-v" => options.log_level = log::LogLevelFilter::Info,
|
||||
"-vv" => options.log_level = log::LogLevelFilter::Debug,
|
||||
"-vvv" => options.log_level = log::LogLevelFilter::Trace,
|
||||
// ignore unexpected
|
||||
_ => (),
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ impl Display {
|
|||
.expect("glutin returns window size");
|
||||
let dpr = window.hidpi_factor();
|
||||
|
||||
println!("device_pixel_ratio: {}", dpr);
|
||||
info!("device_pixel_ratio: {}", dpr);
|
||||
|
||||
let rasterizer = font::Rasterizer::new(dpi.x(), dpi.y(), dpr, config.use_thin_strokes())?;
|
||||
|
||||
|
@ -155,7 +155,7 @@ impl Display {
|
|||
|
||||
// Initialize glyph cache
|
||||
let glyph_cache = {
|
||||
println!("Initializing glyph cache");
|
||||
info!("Initializing glyph cache");
|
||||
let init_start = ::std::time::Instant::now();
|
||||
|
||||
let cache = renderer.with_loader(|mut api| {
|
||||
|
@ -164,7 +164,7 @@ impl Display {
|
|||
|
||||
let stop = init_start.elapsed();
|
||||
let stop_f = stop.as_secs() as f64 + stop.subsec_nanos() as f64 / 1_000_000_000f64;
|
||||
println!("Finished initializing glyph cache in {}", stop_f);
|
||||
info!("Finished initializing glyph cache in {}", stop_f);
|
||||
|
||||
cache
|
||||
};
|
||||
|
@ -180,11 +180,11 @@ impl Display {
|
|||
let width = cell_width * options.columns_u32() + 4;
|
||||
let height = cell_height * options.lines_u32() + 4;
|
||||
let size = Size { width: Pixels(width), height: Pixels(height) };
|
||||
println!("set_inner_size: {}", size);
|
||||
info!("set_inner_size: {}", size);
|
||||
|
||||
window.set_inner_size(size);
|
||||
renderer.resize(*size.width as _, *size.height as _);
|
||||
println!("Cell Size: ({} x {})", cell_width, cell_height);
|
||||
info!("Cell Size: ({} x {})", cell_width, cell_height);
|
||||
|
||||
let size_info = SizeInfo {
|
||||
width: *size.width as f32,
|
||||
|
|
|
@ -189,7 +189,7 @@ impl<N: Notify> Processor<N> {
|
|||
macro_rules! process {
|
||||
($event:expr) => {
|
||||
if self.print_events {
|
||||
err_println!("glutin event: {:?}", $event);
|
||||
println!("glutin event: {:?}", $event);
|
||||
}
|
||||
Processor::handle_event(
|
||||
&mut processor,
|
||||
|
|
18
src/grid.rs
18
src/grid.rs
|
@ -469,7 +469,7 @@ mod tests {
|
|||
#[test]
|
||||
fn grid_swap_lines_ok() {
|
||||
let mut grid = Grid::new(Line(10), Column(1), &0);
|
||||
println!("");
|
||||
info!("");
|
||||
|
||||
// swap test ends
|
||||
grid[Line(0)][Column(0)] = 1;
|
||||
|
@ -487,14 +487,14 @@ mod tests {
|
|||
grid[Line(4)][Column(0)] = 1;
|
||||
grid[Line(5)][Column(0)] = 2;
|
||||
|
||||
println!("grid: {:?}", grid);
|
||||
info!("grid: {:?}", grid);
|
||||
|
||||
assert_eq!(grid[Line(4)][Column(0)], 1);
|
||||
assert_eq!(grid[Line(5)][Column(0)], 2);
|
||||
|
||||
grid.swap_lines(Line(4), Line(5));
|
||||
|
||||
println!("grid: {:?}", grid);
|
||||
info!("grid: {:?}", grid);
|
||||
|
||||
assert_eq!(grid[Line(4)][Column(0)], 2);
|
||||
assert_eq!(grid[Line(5)][Column(0)], 1);
|
||||
|
@ -524,18 +524,18 @@ mod tests {
|
|||
// Scroll up moves lines upwards
|
||||
#[test]
|
||||
fn scroll_up() {
|
||||
println!("");
|
||||
info!("");
|
||||
|
||||
let mut grid = Grid::new(Line(10), Column(1), &0);
|
||||
for i in 0..10 {
|
||||
grid[Line(i)][Column(0)] = i;
|
||||
}
|
||||
|
||||
println!("grid: {:?}", grid);
|
||||
info!("grid: {:?}", grid);
|
||||
|
||||
grid.scroll_up(Line(0)..Line(8), Line(2));
|
||||
|
||||
println!("grid: {:?}", grid);
|
||||
info!("grid: {:?}", grid);
|
||||
|
||||
let mut other = Grid::new(Line(10), Column(1), &9);
|
||||
|
||||
|
@ -558,18 +558,18 @@ mod tests {
|
|||
// Scroll down moves lines downwards
|
||||
#[test]
|
||||
fn scroll_down() {
|
||||
println!("");
|
||||
info!("");
|
||||
|
||||
let mut grid = Grid::new(Line(10), Column(1), &0);
|
||||
for i in 0..10 {
|
||||
grid[Line(i)][Column(0)] = i;
|
||||
}
|
||||
|
||||
println!("grid: {:?}", grid);
|
||||
info!("grid: {:?}", grid);
|
||||
|
||||
grid.scroll_down(Line(2)..Line(10), Line(2));
|
||||
|
||||
println!("grid: {:?}", grid);
|
||||
info!("grid: {:?}", grid);
|
||||
|
||||
let mut other = Grid::new(Line(10), Column(1), &9);
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ impl Action {
|
|||
Clipboard::new()
|
||||
.and_then(|mut clipboard| clipboard.store_primary(buf))
|
||||
.unwrap_or_else(|err| {
|
||||
err_println!("Error storing selection to clipboard. {}", Red(err));
|
||||
warn!("Error storing selection to clipboard. {}", Red(err));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ impl Action {
|
|||
}
|
||||
})
|
||||
.unwrap_or_else(|err| {
|
||||
err_println!("Error loading data from clipboard. {}", Red(err));
|
||||
warn!("Error loading data from clipboard. {}", Red(err));
|
||||
});
|
||||
},
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ impl<'a, N: Notify + 'a> Processor<'a, N> {
|
|||
Clipboard::new()
|
||||
.and_then(|mut clipboard| clipboard.store_selection(buf))
|
||||
.unwrap_or_else(|err| {
|
||||
err_println!("Error storing selection to clipboard. {}", Red(err));
|
||||
warn!("Error storing selection to clipboard. {}", Red(err));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,9 @@ extern crate xdg;
|
|||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
#[macro_use]
|
||||
pub mod macros;
|
||||
|
||||
|
@ -56,6 +59,7 @@ pub mod event_loop;
|
|||
pub mod grid;
|
||||
pub mod index;
|
||||
pub mod input;
|
||||
pub mod logging;
|
||||
pub mod meter;
|
||||
pub mod renderer;
|
||||
pub mod selection;
|
||||
|
|
64
src/logging.rs
Normal file
64
src/logging.rs
Normal file
|
@ -0,0 +1,64 @@
|
|||
// Copyright 2016 Joe Wilm, The Alacritty Project Contributors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//! Logging for alacritty.
|
||||
//!
|
||||
//! The main executable is supposed to call `initialize()` exactly once during
|
||||
//! startup. All logging messages are written to stdout, given that their
|
||||
//! log-level is sufficient for the level configured in `cli::Options`.
|
||||
use log;
|
||||
use std::sync;
|
||||
use std::io;
|
||||
use cli;
|
||||
|
||||
pub struct Logger<T:Send+io::Write> {
|
||||
level: log::LogLevelFilter,
|
||||
output: sync::Mutex<T>
|
||||
}
|
||||
|
||||
impl<T> Logger<T> where T:Send+io::Write {
|
||||
pub fn new(output: T, level: log::LogLevelFilter) -> Logger<io::LineWriter<T>> {
|
||||
Logger { level: level,
|
||||
output: sync::Mutex::new(io::LineWriter::new(output)) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl<T> log::Log for Logger<T> where T:Send+io::Write {
|
||||
fn enabled(&self, metadata: &log::LogMetadata) -> bool {
|
||||
metadata.level() <= self.level
|
||||
}
|
||||
|
||||
fn log(&self, record: &log::LogRecord) {
|
||||
if !self.enabled(record.metadata()) {
|
||||
return
|
||||
}
|
||||
let writer = &mut self.output.lock().unwrap();
|
||||
if self.level < log::LogLevelFilter::Debug {
|
||||
writer.write(format!("{}\n", record.args()).as_ref()).unwrap();
|
||||
} else {
|
||||
writer.write(format!("{}: {}\n",
|
||||
record.target(),
|
||||
record.args())
|
||||
.as_ref()).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn initialize(options: &cli::Options) {
|
||||
log::set_logger(|max_log_level| {
|
||||
max_log_level.set(options.log_level);
|
||||
Box::new(Logger::new(io::stdout(), options.log_level))
|
||||
}).unwrap_or_else(|e| die!("{}", e));
|
||||
}
|
14
src/main.rs
14
src/main.rs
|
@ -19,6 +19,9 @@
|
|||
#[macro_use]
|
||||
extern crate alacritty;
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
use std::error::Error;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
@ -27,12 +30,14 @@ use alacritty::config::{self, Config};
|
|||
use alacritty::display::Display;
|
||||
use alacritty::event;
|
||||
use alacritty::event_loop::{self, EventLoop};
|
||||
use alacritty::logging;
|
||||
use alacritty::sync::FairMutex;
|
||||
use alacritty::term::{Term};
|
||||
use alacritty::tty::{self, process_should_exit};
|
||||
use alacritty::util::fmt::Red;
|
||||
|
||||
fn main() {
|
||||
|
||||
// Load configuration
|
||||
let config = Config::load().unwrap_or_else(|err| {
|
||||
match err {
|
||||
|
@ -55,12 +60,15 @@ fn main() {
|
|||
// Load command line options
|
||||
let options = cli::Options::load();
|
||||
|
||||
// Initialize the logger before entering alacritty main loop
|
||||
logging::initialize(&options);
|
||||
|
||||
// Run alacritty
|
||||
if let Err(err) = run(config, options) {
|
||||
die!("Alacritty encountered an unrecoverable error:\n\n\t{}\n", Red(err));
|
||||
}
|
||||
|
||||
println!("Goodbye");
|
||||
info!("Goodbye.");
|
||||
}
|
||||
|
||||
|
||||
|
@ -69,12 +77,14 @@ fn main() {
|
|||
/// Creates a window, the terminal state, pty, I/O event loop, input processor,
|
||||
/// config change monitor, and runs the main display loop.
|
||||
fn run(mut config: Config, options: cli::Options) -> Result<(), Box<Error>> {
|
||||
info!("Welcome to Alacritty.");
|
||||
|
||||
// Create a display.
|
||||
//
|
||||
// The display manages a window and can draw the terminal
|
||||
let mut display = Display::new(&config, &options)?;
|
||||
|
||||
println!(
|
||||
info!(
|
||||
"PTY Dimensions: {:?} x {:?}",
|
||||
display.size().lines(),
|
||||
display.size().cols()
|
||||
|
|
|
@ -578,7 +578,7 @@ impl QuadRenderer {
|
|||
if op.contains(op::IGNORED) {
|
||||
if let Some(path) = path.as_ref() {
|
||||
if let Err(err) = watcher.watch(path) {
|
||||
err_println!("failed to establish watch on {:?}: {:?}", path, err);
|
||||
warn!("failed to establish watch on {:?}: {:?}", path, err);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -680,10 +680,10 @@ impl QuadRenderer {
|
|||
Err(err) => {
|
||||
match err {
|
||||
ShaderCreationError::Io(err) => {
|
||||
err_println!("Error reading shader file: {}", err);
|
||||
error!("Error reading shader file: {}", err);
|
||||
},
|
||||
ShaderCreationError::Compile(path, log) => {
|
||||
err_println!("Error compiling shader at {:?}", path);
|
||||
error!("Error compiling shader at {:?}", path);
|
||||
let _ = io::copy(&mut log.as_bytes(), &mut io::stdout());
|
||||
}
|
||||
}
|
||||
|
@ -975,7 +975,7 @@ impl ShaderProgram {
|
|||
let ortho = cgmath::ortho(0., width, 0., height, -1., 1.);
|
||||
let projection: [[f32; 4]; 4] = ortho.into();
|
||||
|
||||
println!("width: {}, height: {}", width, height);
|
||||
info!("width: {}, height: {}", width, height);
|
||||
|
||||
unsafe {
|
||||
gl::UniformMatrix4fv(self.u_projection,
|
||||
|
@ -1014,7 +1014,7 @@ impl ShaderProgram {
|
|||
gl::GetProgramiv(program, gl::LINK_STATUS, &mut success);
|
||||
|
||||
if success != (gl::TRUE as GLint) {
|
||||
err_println!("{}", get_program_info_log(program));
|
||||
error!("{}", get_program_info_log(program));
|
||||
panic!("failed to link shader program");
|
||||
}
|
||||
program
|
||||
|
|
|
@ -664,7 +664,7 @@ impl Term {
|
|||
/// Expects origin to be in scroll range.
|
||||
#[inline]
|
||||
fn scroll_down_relative(&mut self, origin: Line, lines: Line) {
|
||||
debug_println!("scroll_down: {}", lines);
|
||||
trace!("scroll_down: {}", lines);
|
||||
|
||||
// Copy of cell template; can't have it borrowed when calling clear/scroll
|
||||
let template = self.empty_cell;
|
||||
|
@ -697,7 +697,7 @@ impl Term {
|
|||
/// Expects origin to be in scroll range.
|
||||
#[inline]
|
||||
fn scroll_up_relative(&mut self, origin: Line, lines: Line) {
|
||||
debug_println!("scroll_up: {}", lines);
|
||||
trace!("scroll_up: {}", lines);
|
||||
|
||||
// Copy of cell template; can't have it borrowed when calling clear/scroll
|
||||
let template = self.empty_cell;
|
||||
|
@ -752,7 +752,7 @@ impl ansi::Handler for Term {
|
|||
return;
|
||||
}
|
||||
|
||||
debug_println!("wrapping");
|
||||
trace!("wrapping");
|
||||
|
||||
{
|
||||
let location = Point {
|
||||
|
@ -790,7 +790,7 @@ impl ansi::Handler for Term {
|
|||
|
||||
#[inline]
|
||||
fn goto(&mut self, line: Line, col: Column) {
|
||||
debug_println!("goto: line={}, col={}", line, col);
|
||||
trace!("goto: line={}, col={}", line, col);
|
||||
self.cursor.line = min(line, self.grid.num_lines() - 1);
|
||||
self.cursor.col = min(col, self.grid.num_cols() - 1);
|
||||
self.input_needs_wrap = false;
|
||||
|
@ -798,14 +798,14 @@ impl ansi::Handler for Term {
|
|||
|
||||
#[inline]
|
||||
fn goto_line(&mut self, line: Line) {
|
||||
debug_println!("goto_line: {}", line);
|
||||
trace!("goto_line: {}", line);
|
||||
self.cursor.line = min(line, self.grid.num_lines() - 1);
|
||||
self.input_needs_wrap = false;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn goto_col(&mut self, col: Column) {
|
||||
debug_println!("goto_col: {}", col);
|
||||
trace!("goto_col: {}", col);
|
||||
self.cursor.col = min(col, self.grid.num_cols() - 1);
|
||||
self.input_needs_wrap = false;
|
||||
}
|
||||
|
@ -840,27 +840,27 @@ impl ansi::Handler for Term {
|
|||
|
||||
#[inline]
|
||||
fn move_up(&mut self, lines: Line) {
|
||||
debug_println!("move_up: {}", lines);
|
||||
trace!("move_up: {}", lines);
|
||||
let lines = min(self.cursor.line, lines);
|
||||
self.cursor.line = min(self.cursor.line - lines, self.grid.num_lines() -1);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn move_down(&mut self, lines: Line) {
|
||||
debug_println!("move_down: {}", lines);
|
||||
trace!("move_down: {}", lines);
|
||||
self.cursor.line = min(self.cursor.line + lines, self.grid.num_lines() - 1);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn move_forward(&mut self, cols: Column) {
|
||||
debug_println!("move_forward: {}", cols);
|
||||
trace!("move_forward: {}", cols);
|
||||
self.cursor.col = min(self.cursor.col + cols, self.grid.num_cols() - 1);
|
||||
self.input_needs_wrap = false;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn move_backward(&mut self, cols: Column) {
|
||||
debug_println!("move_backward: {}", cols);
|
||||
trace!("move_backward: {}", cols);
|
||||
self.cursor.col -= min(self.cursor.col, cols);
|
||||
self.input_needs_wrap = false;
|
||||
}
|
||||
|
@ -872,17 +872,17 @@ impl ansi::Handler for Term {
|
|||
|
||||
#[inline]
|
||||
fn move_down_and_cr(&mut self, lines: Line) {
|
||||
err_println!("[unimplemented] move_down_and_cr: {}", lines);
|
||||
trace!("[unimplemented] move_down_and_cr: {}", lines);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn move_up_and_cr(&mut self, lines: Line) {
|
||||
err_println!("[unimplemented] move_up_and_cr: {}", lines);
|
||||
trace!("[unimplemented] move_up_and_cr: {}", lines);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn put_tab(&mut self, mut count: i64) {
|
||||
debug_println!("put_tab: {}", count);
|
||||
trace!("put_tab: {}", count);
|
||||
|
||||
let mut col = self.cursor.col;
|
||||
while col < self.grid.num_cols() && count != 0 {
|
||||
|
@ -902,7 +902,7 @@ impl ansi::Handler for Term {
|
|||
/// Backspace `count` characters
|
||||
#[inline]
|
||||
fn backspace(&mut self) {
|
||||
debug_println!("backspace");
|
||||
trace!("backspace");
|
||||
if self.cursor.col > Column(0) {
|
||||
self.cursor.col -= 1;
|
||||
self.input_needs_wrap = false;
|
||||
|
@ -912,7 +912,7 @@ impl ansi::Handler for Term {
|
|||
/// Carriage return
|
||||
#[inline]
|
||||
fn carriage_return(&mut self) {
|
||||
debug_println!("carriage_return");
|
||||
trace!("carriage_return");
|
||||
self.cursor.col = Column(0);
|
||||
self.input_needs_wrap = false;
|
||||
}
|
||||
|
@ -920,7 +920,7 @@ impl ansi::Handler for Term {
|
|||
/// Linefeed
|
||||
#[inline]
|
||||
fn linefeed(&mut self) {
|
||||
debug_println!("linefeed");
|
||||
trace!("linefeed");
|
||||
if (self.cursor.line + 1) >= self.scroll_region.end {
|
||||
self.scroll_up(Line(1));
|
||||
} else {
|
||||
|
@ -931,22 +931,22 @@ impl ansi::Handler for Term {
|
|||
/// Set current position as a tabstop
|
||||
#[inline]
|
||||
fn bell(&mut self) {
|
||||
debug_println!("bell");
|
||||
trace!("bell");
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn substitute(&mut self) {
|
||||
err_println!("[unimplemented] substitute");
|
||||
trace!("[unimplemented] substitute");
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn newline(&mut self) {
|
||||
err_println!("[unimplemented] newline");
|
||||
trace!("[unimplemented] newline");
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn set_horizontal_tabstop(&mut self) {
|
||||
err_println!("[unimplemented] set_horizontal_tabstop");
|
||||
trace!("[unimplemented] set_horizontal_tabstop");
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -963,7 +963,7 @@ impl ansi::Handler for Term {
|
|||
|
||||
#[inline]
|
||||
fn insert_blank_lines(&mut self, lines: Line) {
|
||||
debug_println!("insert_blank_lines: {}", lines);
|
||||
trace!("insert_blank_lines: {}", lines);
|
||||
if self.scroll_region.contains_(self.cursor.line) {
|
||||
let origin = self.cursor.line;
|
||||
self.scroll_down_relative(origin, lines);
|
||||
|
@ -972,7 +972,7 @@ impl ansi::Handler for Term {
|
|||
|
||||
#[inline]
|
||||
fn delete_lines(&mut self, lines: Line) {
|
||||
debug_println!("delete_lines: {}", lines);
|
||||
trace!("delete_lines: {}", lines);
|
||||
if self.scroll_region.contains_(self.cursor.line) {
|
||||
let origin = self.cursor.line;
|
||||
self.scroll_up_relative(origin, lines);
|
||||
|
@ -981,7 +981,7 @@ impl ansi::Handler for Term {
|
|||
|
||||
#[inline]
|
||||
fn erase_chars(&mut self, count: Column) {
|
||||
debug_println!("erase_chars: {}, {}", count, self.cursor.col);
|
||||
trace!("erase_chars: {}, {}", count, self.cursor.col);
|
||||
let start = self.cursor.col;
|
||||
let end = min(start + count, self.grid.num_cols() - 1);
|
||||
|
||||
|
@ -1022,27 +1022,27 @@ impl ansi::Handler for Term {
|
|||
|
||||
#[inline]
|
||||
fn move_backward_tabs(&mut self, count: i64) {
|
||||
err_println!("[unimplemented] move_backward_tabs: {}", count);
|
||||
trace!("[unimplemented] move_backward_tabs: {}", count);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn move_forward_tabs(&mut self, count: i64) {
|
||||
err_println!("[unimplemented] move_forward_tabs: {}", count);
|
||||
trace!("[unimplemented] move_forward_tabs: {}", count);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn save_cursor_position(&mut self) {
|
||||
err_println!("[unimplemented] save_cursor_position");
|
||||
trace!("[unimplemented] save_cursor_position");
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn restore_cursor_position(&mut self) {
|
||||
err_println!("[unimplemented] restore_cursor_position");
|
||||
trace!("[unimplemented] restore_cursor_position");
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn clear_line(&mut self, mode: ansi::LineClearMode) {
|
||||
debug_println!("clear_line: {:?}", mode);
|
||||
trace!("clear_line: {:?}", mode);
|
||||
let template = self.empty_cell;
|
||||
let col = self.cursor.col;
|
||||
|
||||
|
@ -1070,7 +1070,7 @@ impl ansi::Handler for Term {
|
|||
|
||||
#[inline]
|
||||
fn clear_screen(&mut self, mode: ansi::ClearMode) {
|
||||
debug_println!("clear_screen: {:?}", mode);
|
||||
trace!("clear_screen: {:?}", mode);
|
||||
let template = self.empty_cell;
|
||||
match mode {
|
||||
ansi::ClearMode::Below => {
|
||||
|
@ -1084,24 +1084,24 @@ impl ansi::Handler for Term {
|
|||
self.grid.clear(|c| c.reset(&template));
|
||||
},
|
||||
_ => {
|
||||
err_println!("ansi::ClearMode::Above not implemented");
|
||||
trace!("ansi::ClearMode::Above not implemented");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn clear_tabs(&mut self, mode: ansi::TabulationClearMode) {
|
||||
err_println!("[unimplemented] clear_tabs: {:?}", mode);
|
||||
trace!("[unimplemented] clear_tabs: {:?}", mode);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn reset_state(&mut self) {
|
||||
err_println!("[unimplemented] reset_state");
|
||||
trace!("[unimplemented] reset_state");
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn reverse_index(&mut self) {
|
||||
debug_println!("reverse_index");
|
||||
trace!("reverse_index");
|
||||
// if cursor is at the top
|
||||
if self.cursor.line == self.scroll_region.start {
|
||||
self.scroll_down(Line(1));
|
||||
|
@ -1113,7 +1113,7 @@ impl ansi::Handler for Term {
|
|||
/// set a terminal attribute
|
||||
#[inline]
|
||||
fn terminal_attribute(&mut self, attr: Attr) {
|
||||
debug_println!("Set Attribute: {:?}", attr);
|
||||
trace!("Set Attribute: {:?}", attr);
|
||||
match attr {
|
||||
Attr::Foreground(color) => self.template_cell.fg = color,
|
||||
Attr::Background(color) => self.template_cell.bg = color,
|
||||
|
@ -1131,14 +1131,14 @@ impl ansi::Handler for Term {
|
|||
Attr::Underscore => self.template_cell.flags.insert(cell::UNDERLINE),
|
||||
Attr::CancelUnderline => self.template_cell.flags.remove(cell::UNDERLINE),
|
||||
_ => {
|
||||
debug_println!("Term got unhandled attr: {:?}", attr);
|
||||
debug!("Term got unhandled attr: {:?}", attr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn set_mode(&mut self, mode: ansi::Mode) {
|
||||
debug_println!("set_mode: {:?}", mode);
|
||||
trace!("set_mode: {:?}", mode);
|
||||
match mode {
|
||||
ansi::Mode::SwapScreenAndSetRestoreCursor => self.swap_alt(),
|
||||
ansi::Mode::ShowCursor => self.mode.insert(mode::SHOW_CURSOR),
|
||||
|
@ -1149,14 +1149,14 @@ impl ansi::Handler for Term {
|
|||
ansi::Mode::SgrMouse => self.mode.insert(mode::SGR_MOUSE),
|
||||
ansi::Mode::LineWrap => self.mode.insert(mode::LINE_WRAP),
|
||||
_ => {
|
||||
debug_println!(".. ignoring set_mode");
|
||||
debug!(".. ignoring set_mode");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn unset_mode(&mut self,mode: ansi::Mode) {
|
||||
debug_println!("unset_mode: {:?}", mode);
|
||||
trace!("unset_mode: {:?}", mode);
|
||||
match mode {
|
||||
ansi::Mode::SwapScreenAndSetRestoreCursor => self.swap_alt(),
|
||||
ansi::Mode::ShowCursor => self.mode.remove(mode::SHOW_CURSOR),
|
||||
|
@ -1167,14 +1167,14 @@ impl ansi::Handler for Term {
|
|||
ansi::Mode::SgrMouse => self.mode.remove(mode::SGR_MOUSE),
|
||||
ansi::Mode::LineWrap => self.mode.remove(mode::LINE_WRAP),
|
||||
_ => {
|
||||
debug_println!(".. ignoring unset_mode");
|
||||
debug!(".. ignoring unset_mode");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn set_scrolling_region(&mut self, region: Range<Line>) {
|
||||
debug_println!("set scroll region: {:?}", region);
|
||||
trace!("set scroll region: {:?}", region);
|
||||
self.scroll_region.start = min(region.start, self.grid.num_lines());
|
||||
self.scroll_region.end = min(region.end, self.grid.num_lines());
|
||||
self.goto(Line(0), Column(0));
|
||||
|
@ -1182,13 +1182,13 @@ impl ansi::Handler for Term {
|
|||
|
||||
#[inline]
|
||||
fn set_keypad_application_mode(&mut self) {
|
||||
debug_println!("set mode::APP_KEYPAD");
|
||||
trace!("set mode::APP_KEYPAD");
|
||||
self.mode.insert(mode::APP_KEYPAD);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn unset_keypad_application_mode(&mut self) {
|
||||
debug_println!("unset mode::APP_KEYPAD");
|
||||
trace!("unset mode::APP_KEYPAD");
|
||||
self.mode.remove(mode::APP_KEYPAD);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue