aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'alacritty/src/main.rs')
-rw-r--r--alacritty/src/main.rs74
1 files changed, 37 insertions, 37 deletions
diff --git a/alacritty/src/main.rs b/alacritty/src/main.rs
index 6bb9041c..fa501013 100644
--- a/alacritty/src/main.rs
+++ b/alacritty/src/main.rs
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
-//! Alacritty - The GPU Enhanced Terminal
+//! Alacritty - The GPU Enhanced Terminal.
#![deny(clippy::all, clippy::if_not_else, clippy::enum_glob_use, clippy::wrong_pub_self_convention)]
#![cfg_attr(feature = "nightly", feature(core_intrinsics))]
#![cfg_attr(all(test, feature = "bench"), feature(test))]
@@ -83,41 +83,41 @@ fn main() {
AttachConsole(ATTACH_PARENT_PROCESS);
}
- // Load command line options
+ // Load command line options.
let options = Options::new();
- // Setup glutin event loop
+ // Setup glutin event loop.
let window_event_loop = GlutinEventLoop::<Event>::with_user_event();
- // Initialize the logger as soon as possible as to capture output from other subsystems
+ // Initialize the logger as soon as possible as to capture output from other subsystems.
let log_file = logging::initialize(&options, window_event_loop.create_proxy())
.expect("Unable to initialize logger");
- // Load configuration file
+ // Load configuration file.
let config_path = options.config_path().or_else(config::installed_config);
let config = config_path.map(config::load_from).unwrap_or_else(Config::default);
let config = options.into_config(config);
- // Update the log level from config
+ // Update the log level from config.
log::set_max_level(config.debug.log_level);
- // Switch to home directory
+ // Switch to home directory.
#[cfg(target_os = "macos")]
env::set_current_dir(dirs::home_dir().unwrap()).unwrap();
- // Set locale
+ // Set locale.
#[cfg(target_os = "macos")]
locale::set_locale_environment();
- // Store if log file should be deleted before moving config
+ // Store if log file should be deleted before moving config.
let persistent_logging = config.persistent_logging();
- // Run alacritty
+ // Run Alacritty.
if let Err(err) = run(window_event_loop, config) {
error!("Alacritty encountered an unrecoverable error:\n\n\t{}\n", err);
std::process::exit(1);
}
- // Clean up logfile
+ // Clean up logfile.
if let Some(log_file) = log_file {
if !persistent_logging && fs::remove_file(&log_file).is_ok() {
let _ = writeln!(io::stdout(), "Deleted log file at \"{}\"", log_file.display());
@@ -125,9 +125,9 @@ fn main() {
}
}
-/// Run Alacritty
+/// Run Alacritty.
///
-/// Creates a window, the terminal state, pty, I/O event loop, input processor,
+/// Creates a window, the terminal state, PTY, I/O event loop, input processor,
/// config change monitor, and runs the main display loop.
fn run(window_event_loop: GlutinEventLoop<Event>, config: Config) -> Result<(), Box<dyn Error>> {
info!("Welcome to Alacritty");
@@ -137,25 +137,25 @@ fn run(window_event_loop: GlutinEventLoop<Event>, config: Config) -> Result<(),
None => info!("No configuration file found"),
}
- // Set environment variables
+ // Set environment variables.
tty::setup_env(&config);
let event_proxy = EventProxy::new(window_event_loop.create_proxy());
- // Create a display
+ // Create a display.
//
// The display manages a window and can draw the terminal.
let display = Display::new(&config, &window_event_loop)?;
- info!("PTY Dimensions: {:?} x {:?}", display.size_info.lines(), display.size_info.cols());
+ info!("PTY dimensions: {:?} x {:?}", display.size_info.lines(), display.size_info.cols());
- // Create new native clipboard
+ // Create new native clipboard.
#[cfg(not(any(target_os = "macos", windows)))]
let clipboard = Clipboard::new(display.window.wayland_display());
#[cfg(any(target_os = "macos", windows))]
let clipboard = Clipboard::new();
- // Create the terminal
+ // Create the terminal.
//
// This object contains all of the state about what's being displayed. It's
// wrapped in a clonable mutex since both the I/O loop and display need to
@@ -163,9 +163,9 @@ fn run(window_event_loop: GlutinEventLoop<Event>, config: Config) -> Result<(),
let terminal = Term::new(&config, &display.size_info, clipboard, event_proxy.clone());
let terminal = Arc::new(FairMutex::new(terminal));
- // Create the pty
+ // Create the PTY.
//
- // The pty forks a process to run the shell on the slave side of the
+ // The PTY forks a process to run the shell on the slave side of the
// pseudoterminal. A file descriptor for the master side is retained for
// reading/writing to the shell.
#[cfg(not(any(target_os = "macos", windows)))]
@@ -173,9 +173,9 @@ fn run(window_event_loop: GlutinEventLoop<Event>, config: Config) -> Result<(),
#[cfg(any(target_os = "macos", windows))]
let pty = tty::new(&config, &display.size_info, None);
- // Create the pseudoterminal I/O loop
+ // Create the pseudoterminal I/O loop.
//
- // pty I/O is ran on another thread as to not occupy cycles used by the
+ // PTY I/O is ran on another thread as to not occupy cycles used by the
// renderer and input processing. Note that access to the terminal state is
// synchronized since the I/O loop updates the state, and the display
// consumes it periodically.
@@ -185,7 +185,7 @@ fn run(window_event_loop: GlutinEventLoop<Event>, config: Config) -> Result<(),
// to be sent to the pty loop and ultimately written to the pty.
let loop_tx = event_loop.channel();
- // Create a config monitor when config was loaded from path
+ // Create a config monitor when config was loaded from path.
//
// The monitor watches the config file for changes and reloads it. Pending
// config changes are processed in the main loop.
@@ -193,42 +193,42 @@ fn run(window_event_loop: GlutinEventLoop<Event>, config: Config) -> Result<(),
config.config_path.as_ref().map(|path| Monitor::new(path, event_proxy.clone()));
}
- // Setup storage for message UI
+ // Setup storage for message UI.
let message_buffer = MessageBuffer::new();
- // Event processor
+ // Event processor.
let mut processor =
Processor::new(event_loop::Notifier(loop_tx.clone()), message_buffer, config, display);
- // Kick off the I/O thread
+ // Kick off the I/O thread.
let io_thread = event_loop.spawn();
info!("Initialisation complete");
- // Start event loop and block until shutdown
+ // Start event loop and block until shutdown.
processor.run(terminal, window_event_loop);
// This explicit drop is needed for Windows, ConPTY backend. Otherwise a deadlock can occur.
// The cause:
- // - Drop for Conpty will deadlock if the conout pipe has already been dropped.
- // - The conout pipe is dropped when the io_thread is joined below (io_thread owns pty).
- // - Conpty is dropped when the last of processor and io_thread are dropped, because both of
- // them own an Arc<Conpty>.
+ // - Drop for ConPTY will deadlock if the conout pipe has already been dropped.
+ // - The conout pipe is dropped when the io_thread is joined below (io_thread owns PTY).
+ // - ConPTY is dropped when the last of processor and io_thread are dropped, because both of
+ // them own an Arc<ConPTY>.
//
- // The fix is to ensure that processor is dropped first. That way, when io_thread (i.e. pty)
- // is dropped, it can ensure Conpty is dropped before the conout pipe in the pty drop order.
+ // The fix is to ensure that processor is dropped first. That way, when io_thread (i.e. PTY)
+ // is dropped, it can ensure ConPTY is dropped before the conout pipe in the PTY drop order.
//
// FIXME: Change PTY API to enforce the correct drop order with the typesystem.
drop(processor);
- // Shutdown PTY parser event loop
- loop_tx.send(Msg::Shutdown).expect("Error sending shutdown to pty event loop");
+ // Shutdown PTY parser event loop.
+ loop_tx.send(Msg::Shutdown).expect("Error sending shutdown to PTY event loop");
io_thread.join().expect("join io thread");
- // FIXME patch notify library to have a shutdown method
+ // FIXME patch notify library to have a shutdown method.
// config_reloader.join().ok();
- // Without explicitly detaching the console cmd won't redraw it's prompt
+ // Without explicitly detaching the console cmd won't redraw it's prompt.
#[cfg(windows)]
unsafe {
FreeConsole();