aboutsummaryrefslogtreecommitdiff
path: root/src/panic.rs
diff options
context:
space:
mode:
authorTheodore Dubois <tblodt@icloud.com>2019-04-28 06:24:58 -0700
committerChristian Duerr <chrisduerr@users.noreply.github.com>2019-04-28 13:24:58 +0000
commitdbd8538762ef8968a493e1bf996e8693479ca783 (patch)
tree32ac2a6a5e01238a272d4ba534551d2e42903c7a /src/panic.rs
parent9c6d12ea2c863ba76015bdedc00db13b7307725a (diff)
downloadr-alacritty-dbd8538762ef8968a493e1bf996e8693479ca783.tar.gz
r-alacritty-dbd8538762ef8968a493e1bf996e8693479ca783.tar.bz2
r-alacritty-dbd8538762ef8968a493e1bf996e8693479ca783.zip
Split alacritty into a separate crates
The crate containing the entry point is called alacritty, and the crate containing everything else is called alacritty_terminal.
Diffstat (limited to 'src/panic.rs')
-rw-r--r--src/panic.rs53
1 files changed, 0 insertions, 53 deletions
diff --git a/src/panic.rs b/src/panic.rs
deleted file mode 100644
index 4d3524ed..00000000
--- a/src/panic.rs
+++ /dev/null
@@ -1,53 +0,0 @@
-// 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.
-//
-//! ANSI Terminal Stream Parsing
-
-// Use the default behavior of the other platforms.
-#[cfg(not(windows))]
-pub fn attach_handler() {}
-
-// Install a panic handler that renders the panic in a classical Windows error
-// dialog box as well as writes the panic to STDERR.
-#[cfg(windows)]
-pub fn attach_handler() {
- use std::{io, io::Write, panic, ptr};
- use winapi::um::winuser;
-
- panic::set_hook(Box::new(|panic_info| {
- let _ = writeln!(io::stderr(), "{}", panic_info);
- let msg = format!("{}\n\nPress Ctrl-C to Copy", panic_info);
- unsafe {
- winuser::MessageBoxW(
- ptr::null_mut(),
- win32_string(&msg).as_ptr(),
- win32_string("Alacritty: Runtime Error").as_ptr(),
- winuser::MB_ICONERROR
- | winuser::MB_OK
- | winuser::MB_SETFOREGROUND
- | winuser::MB_TASKMODAL,
- );
- }
- }));
-}
-
-// Converts the string slice into a Windows-standard representation for "W"-
-// suffixed function variants, which accept UTF-16 encoded string values.
-#[cfg(windows)]
-fn win32_string(value: &str) -> Vec<u16> {
- use std::ffi::OsStr;
- use std::iter::once;
- use std::os::windows::ffi::OsStrExt;
- OsStr::new(value).encode_wide().chain(once(0)).collect()
-}