1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-25 14:05:41 -05:00

Fix all trivial compiler warnings

Of note are the `ansi` and `grid` modules becoming public. There are
several bits of unused code in each of these. In the case of `grid`, the
unused parts are generally useful, like some indexing implementations.
In ansi, there are pieces that will be used once the parser is more
complete. In any case, these modules are fairly generic and mostly
usable outside of Alacritty.

Unused cargo packages were also removed.
This commit is contained in:
Joe Wilm 2016-06-09 08:30:55 -07:00
parent a60dbd564b
commit 8566e17860
No known key found for this signature in database
GPG key ID: 39B57C6972F518DA
8 changed files with 76 additions and 197 deletions

44
Cargo.lock generated
View file

@ -2,10 +2,8 @@
name = "alacritty"
version = "0.1.0"
dependencies = [
"arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cgmath 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
"freetype-rs 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gl_generator 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"glutin 0.4.9 (git+https://github.com/jwilm/glutin?rev=c95e6973ace3cbf321123a64588b27f032675be9)",
@ -19,15 +17,6 @@ name = "android_glue"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "arrayvec"
version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"nodrop 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"odds 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "bitflags"
version = "0.3.3"
@ -88,7 +77,7 @@ version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"objc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -112,12 +101,12 @@ dependencies = [
[[package]]
name = "core-graphics"
version = "0.3.1"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"core-foundation 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -150,16 +139,6 @@ dependencies = [
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "euclid"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "expat-sys"
version = "2.1.2"
@ -275,7 +254,7 @@ dependencies = [
"cgl 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"cocoa 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"dwmapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gdi32-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gl_generator 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -429,14 +408,6 @@ dependencies = [
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "nodrop"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"odds 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "notify"
version = "2.5.5"
@ -531,11 +502,6 @@ dependencies = [
"malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "odds"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "osmesa-sys"
version = "0.0.5"
@ -578,7 +544,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "serde"
version = "0.7.7"
version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]

View file

@ -11,9 +11,7 @@ servo-fontconfig = { git = "https://github.com/jwilm/rust-fontconfig" }
freetype-rs = "0.9.0"
libc = "*"
cgmath = "0.7"
euclid = "0.6"
notify = { git = "https://github.com/jwilm/rsnotify", branch = "add-ignore-op" }
arrayvec = "0.3"
bitflags = "*"
[build-dependencies]

View file

@ -17,7 +17,7 @@
//! should be, feel free to add it. Please try not to become overzealous and adding support for
//! sequences only used by folks trapped in 1988.
use std::io::{Cursor, Read, Write, Chars};
use std::io::Write;
use ::Rgb;
/// A CSI Escape sequence
@ -32,38 +32,6 @@ pub trait TermInfo {
fn cols(&self) -> usize;
}
/// Control requiring action
#[derive(Debug, Eq, PartialEq)]
pub enum Control {
PutTab(u8),
Backspace(u8),
CarriageReturn,
Newline,
Bell,
SwitchG0,
SwitchG1,
Substitute,
LineFeed,
SetHorizontalTabStop,
ReverseIndex,
IdentifyTerminal,
ResetState,
}
/// Something parsed from the pty stream
#[derive(Debug, Eq, PartialEq)]
pub enum Item {
/// CSI escape
Escape(Escape),
/// Control character,
Control(Control),
/// Plain character
Char(char),
}
pub const CSI_ATTR_MAX: usize = 16;
pub struct Parser {
@ -244,46 +212,46 @@ pub enum Attr {
/// writing specific handler impls for tests far easier.
pub trait Handler {
/// A character to be displayed
fn input(&mut self, c: char) {}
fn input(&mut self, _c: char) {}
/// Set cursor to position
fn goto(&mut self, x: i64, y: i64) {}
fn goto(&mut self, _x: i64, _y: i64) {}
/// Set cursor to specific row
fn goto_row(&mut self, y: i64) {}
fn goto_row(&mut self, _y: i64) {}
/// Set cursor to specific column
fn goto_col(&mut self, x: i64) {}
fn goto_col(&mut self, _x: i64) {}
/// Insert blank characters
fn insert_blank(&mut self, num: i64) {}
fn insert_blank(&mut self, _num: i64) {}
/// Move cursor up `rows`
fn move_up(&mut self, rows: i64) {}
fn move_up(&mut self, _rows: i64) {}
/// Move cursor down `rows`
fn move_down(&mut self, rows: i64) {}
fn move_down(&mut self, _rows: i64) {}
/// Identify the terminal (should write back to the pty stream)
fn identify_terminal(&mut self) {}
/// Move cursor forward `cols`
fn move_forward(&mut self, cols: i64) {}
fn move_forward(&mut self, _cols: i64) {}
/// Move cursor backward `cols`
fn move_backward(&mut self, cols: i64) {}
fn move_backward(&mut self, _cols: i64) {}
/// Move cursor down `rows` and set to column 1
fn move_down_and_cr(&mut self, rows: i64) {}
fn move_down_and_cr(&mut self, _rows: i64) {}
/// Move cursor up `rows` and set to column 1
fn move_up_and_cr(&mut self, rows: i64) {}
fn move_up_and_cr(&mut self, _rows: i64) {}
/// Put `count` tabs
fn put_tab(&mut self, count: i64) {}
fn put_tab(&mut self, _count: i64) {}
/// Backspace `count` characters
fn backspace(&mut self, count: i64) {}
fn backspace(&mut self, _count: i64) {}
/// Carriage return
fn carriage_return(&mut self) {}
@ -306,32 +274,32 @@ pub trait Handler {
fn set_horizontal_tabstop(&mut self) {}
/// Scroll up `rows` rows
fn scroll_up(&mut self, rows: i64) {}
fn scroll_up(&mut self, _rows: i64) {}
/// Scroll down `rows` rows
fn scroll_down(&mut self, rows: i64) {}
fn scroll_down(&mut self, _rows: i64) {}
/// Insert `count` blank lines
fn insert_blank_lines(&mut self, count: i64) {}
fn insert_blank_lines(&mut self, _count: i64) {}
/// Delete `count` lines
fn delete_lines(&mut self, count: i64) {}
fn delete_lines(&mut self, _count: i64) {}
/// Erase `count` chars
///
/// TODO figure out AND comment what it means to "erase" chars
fn erase_chars(&mut self, count: i64) {}
fn erase_chars(&mut self, _count: i64) {}
/// Delete `count` chars
///
/// TODO figure out AND comment what it means to "delete" chars
fn delete_chars(&mut self, count: i64) {}
fn delete_chars(&mut self, _count: i64) {}
/// Move backward `count` tabs
fn move_backward_tabs(&mut self, count: i64) {}
fn move_backward_tabs(&mut self, _count: i64) {}
/// Move forward `count` tabs
fn move_forward_tabs(&mut self, count: i64) {}
fn move_forward_tabs(&mut self, _count: i64) {}
/// Save current cursor position
fn save_cursor_position(&mut self) {}
@ -340,13 +308,13 @@ pub trait Handler {
fn restore_cursor_position(&mut self) {}
/// Clear current line
fn clear_line(&mut self, mode: LineClearMode) {}
fn clear_line(&mut self, _mode: LineClearMode) {}
/// Clear screen
fn clear_screen(&mut self, mode: ClearMode) {}
fn clear_screen(&mut self, _mode: ClearMode) {}
/// Clear tab stops
fn clear_tabs(&mut self, mode: TabulationClearMode) {}
fn clear_tabs(&mut self, _mode: TabulationClearMode) {}
/// Reset terminal state
fn reset_state(&mut self) {}
@ -358,16 +326,16 @@ pub trait Handler {
fn reverse_index(&mut self) {}
/// set a terminal attribute
fn terminal_attribute(&mut self, attr: Attr) {}
fn terminal_attribute(&mut self, _attr: Attr) {}
/// Set mode
fn set_mode(&mut self, Mode) {}
fn set_mode(&mut self, _mode: Mode) {}
/// Unset mode
fn unset_mode(&mut self, Mode) {}
/// DECSTBM - Set the terminal scrolling region
fn set_scrolling_region(&mut self, top: i64, bot: i64) {}
fn set_scrolling_region(&mut self, _top: i64, _bot: i64) {}
}
/// An implementation of handler that just prints everything it gets
@ -471,7 +439,7 @@ impl Parser {
handler.input(c);
}
fn other<H>(&mut self, handler: &mut H, c: char)
fn other<H>(&mut self, _handler: &mut H, c: char)
where H: Handler + TermInfo
{
if c == 0x07 as char || c == 0x18 as char || c == 0x1a as char ||
@ -537,7 +505,6 @@ impl Parser {
fn csi_parse<H>(&mut self, handler: &mut H)
where H: Handler + TermInfo
{
let mut idx = 0;
let mut args = [0i64; CSI_ATTR_MAX];
let mut args_idx = 0;
@ -951,8 +918,8 @@ fn is_control_c1(c: char) -> bool {
}
/// C0 set of 7-bit control characters (from ANSI X3.4-1977).
#[allow(dead_code)]
mod C0 {
#[allow(non_snake_case)]
pub mod C0 {
/// Null filler, terminal should ignore this character
pub const NUL: char = 0x00 as char;
/// Start of Header
@ -1027,8 +994,8 @@ mod C0 {
/// 0x80 (@), 0x81 (A), 0x82 (B), 0x83 (C) are reserved
/// 0x98 (X), 0x99 (Y) are reserved
/// 0x9a (Z) is resezved, but causes DEC terminals to respond with DA codes
#[allow(dead_code)]
mod C1 {
#[allow(non_snake_case)]
pub mod C1 {
/// Reserved
pub const PAD: char = 0x80 as char;
/// Reserved

View file

@ -10,9 +10,7 @@ extern crate freetype;
extern crate libc;
extern crate glutin;
extern crate cgmath;
extern crate euclid;
extern crate notify;
extern crate arrayvec;
#[macro_use]
extern crate bitflags;
@ -23,24 +21,20 @@ mod macros;
mod list_fonts;
mod text;
mod renderer;
mod grid;
pub mod grid;
mod meter;
mod tty;
mod ansi;
pub mod ansi;
mod term;
mod util;
use std::collections::HashMap;
use std::fs::File;
use std::io::{BufReader, Read, BufRead, Write, BufWriter};
use std::io::{Read, Write, BufWriter};
use std::sync::Arc;
use std::sync::mpsc;
use std::os::unix::io::{FromRawFd, AsRawFd};
use grid::Grid;
use meter::Meter;
use renderer::{QuadRenderer, GlyphCache, LoadGlyph};
use renderer::{QuadRenderer, GlyphCache};
use term::Term;
use text::FontDesc;
use tty::process_should_exit;
@ -116,7 +110,7 @@ mod gl {
}
#[derive(Debug)]
struct TermProps {
pub struct TermProps {
width: f32,
height: f32,
cell_width: f32,
@ -159,12 +153,12 @@ fn main() {
let tty = tty::new(num_rows as u8, num_cols as u8);
tty.resize(num_rows as usize, num_cols as usize, width as usize, height as usize);
let mut reader = tty.reader();
let mut writer = tty.writer();
let reader = tty.reader();
let writer = tty.writer();
println!("num_cols, num_rows = {}, {}", num_cols, num_rows);
let mut grid = Grid::new(num_rows as usize, num_cols as usize);
let grid = Grid::new(num_rows as usize, num_cols as usize);
let props = TermProps {
cell_width: cell_width as f32,
@ -206,41 +200,44 @@ fn main() {
let window_ref = window.clone();
let input_thread = thread::spawn_named("Input Thread", move || {
for event in window_ref.wait_events() {
tx.send(Event::Glutin(event));
tx.send(Event::Glutin(event)).unwrap();
if process_should_exit() {
break;
}
}
});
'main_loop: loop {
// Block waiting for next event
match rx.recv() {
Ok(e) => {
let res = handle_event(e, &mut writer, &mut terminal, &mut pty_parser);
if res == ShouldExit::Yes {
break;
}
},
Err(mpsc::RecvError) => break,
}
{
let mut writer = BufWriter::new(&writer);
// Handle Any events that have been queued
loop {
match rx.try_recv() {
// Block waiting for next event
match rx.recv() {
Ok(e) => {
let res = handle_event(e, &mut writer, &mut terminal, &mut pty_parser);
if res == ShouldExit::Yes {
break;
}
},
Err(mpsc::TryRecvError::Disconnected) => break 'main_loop,
Err(mpsc::TryRecvError::Empty) => break,
Err(mpsc::RecvError) => break,
}
// TODO make sure this doesn't block renders
// Handle Any events that have been queued
loop {
match rx.try_recv() {
Ok(e) => {
let res = handle_event(e, &mut writer, &mut terminal, &mut pty_parser);
if res == ShouldExit::Yes {
break;
}
},
Err(mpsc::TryRecvError::Disconnected) => break 'main_loop,
Err(mpsc::TryRecvError::Empty) => break,
}
// TODO make sure this doesn't block renders
}
}
unsafe {

View file

@ -3,13 +3,12 @@ use std::ffi::CString;
use std::fs::File;
use std::io::{self, Read};
use std::mem::size_of;
use std::path::{PathBuf, Path};
use std::path::{PathBuf};
use std::ptr;
use std::sync::Arc;
use std::sync::atomic::{Ordering, AtomicBool};
use cgmath::{self, Matrix};
use euclid::{Rect, Size2D, Point2D};
use cgmath;
use gl::types::*;
use gl;
use notify::{Watcher as WatcherApi, RecommendedWatcher as Watcher, op};
@ -184,12 +183,6 @@ pub struct PackedVertex {
y: f32,
}
#[derive(Debug)]
struct ElementIndex {
col: u32, // x
row: u32, // y
}
#[derive(Debug)]
pub struct Batch {
tex: GLuint,
@ -616,13 +609,6 @@ impl<'a> Drop for RenderApi<'a> {
}
}
fn get_rect(glyph: &Glyph, x: f32, y: f32) -> Rect<f32> {
Rect::new(
Point2D::new(x + glyph.left as f32, y - (glyph.height - glyph.top) as f32),
Size2D::new(glyph.width as f32, glyph.height as f32)
)
}
impl ShaderProgram {
pub fn activate(&self) {
unsafe {

View file

@ -1,8 +1,7 @@
/// Exports the `Term` type which is a high-level API for the Grid
use std::sync::Arc;
use std::ops::Range;
use ansi::{self, Attr, DebugHandler};
use ansi::{self, Attr};
use grid::{self, Grid, CellFlags};
use tty;
use ::Rgb;
@ -70,10 +69,6 @@ impl Cursor {
}
}
struct Mover<'a> {
cursor: &'a mut Cursor,
}
pub struct Term {
/// The grid
grid: Grid,
@ -85,7 +80,7 @@ pub struct Term {
alt: bool,
/// Reference to the underlying tty
tty: tty::Tty,
_tty: tty::Tty,
/// The cursor
cursor: Cursor,
@ -130,7 +125,7 @@ impl Term {
alt_cursor: Cursor::default(),
fg: DEFAULT_FG,
bg: DEFAULT_BG,
tty: tty,
_tty: tty,
tabs: tabs,
attr: CellFlags::empty(),
mode: TermMode::empty(),
@ -157,10 +152,6 @@ impl Term {
}
}
pub fn resize(&mut self) {
unimplemented!();
}
#[inline]
pub fn cursor_x(&self) -> u16 {
self.cursor.x
@ -195,13 +186,6 @@ impl Term {
cell.flags = self.attr;
}
/// Advance to next line
fn newline_c(&mut self, count: u16) {
// TODO handle scroll
self.cursor.x = 0;
self.cursor.y += 1;
}
/// Convenience function for scrolling
fn scroll(&mut self, count: isize) {
println!("[TERM] scrolling {} lines", count);
@ -299,6 +283,7 @@ impl ansi::Handler for Term {
#[inline]
fn backspace(&mut self, count: i64) {
println!("backspace");
// TODO this is incorrect; count unused
self.cursor.x -= 1;
self.set_char(' ');
}
@ -357,7 +342,6 @@ impl ansi::Handler for Term {
println!("clear_line: {:?}", mode);
match mode {
ansi::LineClearMode::Right => {
let cols = self.grid.num_cols();
let row = &mut self.grid[self.cursor.y as usize];
let start = self.cursor.x as usize;
for cell in row[start..].iter_mut() {

View file

@ -7,7 +7,7 @@ use std::mem;
use std::os::unix::io::FromRawFd;
use std::ptr;
use libc::{self, winsize, c_int, c_char, pid_t, WNOHANG, WIFEXITED, WEXITSTATUS, SIGCHLD};
use libc::{self, winsize, c_int, pid_t, WNOHANG, WIFEXITED, WEXITSTATUS, SIGCHLD};
/// Process ID of child process
///
@ -21,7 +21,7 @@ static mut PID: pid_t = 0;
/// cheked via `process_should_exit`.
static mut SHOULD_EXIT: bool = false;
extern "C" fn sigchld(a: c_int) {
extern "C" fn sigchld(_a: c_int) {
let mut status: c_int = 0;
unsafe {
let p = libc::waitpid(PID, &mut status, WNOHANG);
@ -45,23 +45,6 @@ pub fn process_should_exit() -> bool {
unsafe { SHOULD_EXIT }
}
pub enum Error {
/// TODO
Unknown,
}
impl Error {
/// Build an Error from the current value of errno.
fn from_errno() -> Error {
let err = errno();
match err {
_ => Error::Unknown
}
}
}
pub type Result<T> = ::std::result::Result<T, Error>;
/// Get the current value of errno
fn errno() -> c_int {
unsafe {

View file

@ -1,5 +1,3 @@
use std::iter::Iterator;
/// Threading utilities
pub mod thread {
/// Like `thread::spawn`, but with a `name` argument