summaryrefslogtreecommitdiffstats
path: root/src/renderer/mod.rs
AgeCommit message (Collapse)Author
2018-11-12Fix incorrect padding calculationsChristian Duerr
The extra window padding was calculated in the renderer which lead to problems with the paddings calculated in the `src/display.rs` and `src/term/mod.rs`. As a solution, every instance of `config.padding().x/y` has been removed from the renderer (`src/renderer/mod.rs`), instead the padding is always passed through from the `src/display.rs`. The initial calculations during display creation and after resize then are scaled appropriately and then the extra padding is calculated. As a result every other location can just make use of the correctly calculated `size_info.padding_x` and `size_info.padding_y`. The documentation has been changed to clearly state that the padding is scaled by DPI now. This fixes #1773.
2018-11-11Center the grid inside the windowChristian Duerr
Currently alacritty always puts the grid at the top-left position of the window. The only distance to the top-left window border is set by the padding in the config. However the grid always has a fixed size, and if a cell doesn't completely fit the screen anymore, the padding at the bottom right window corner can be significantly bigger than the padding at the top left. To fix this whenever there is more space left and there would usually be a bigger padding at the bottom right, the space is now split up and added to the padding. This should always center the grid inside the window and make sure all borders have the same padding from the text area. This screenshot shows how it has been until now: ![Before](https://u.teknik.io/kRJwg.png) Here is how it looks now: ![After](https://u.teknik.io/m4puV.png) This fixes #1065.
2018-11-10Remove re-export of glutin size typesChristian Duerr
2018-11-10Upgrade Glutin to v0.19.0Matt Keeler
Some changes include: • Use the with_hardware_acceleration function on the ContextBuilder to not require the discrete GPU • Remove the LMenu and RMenu virtual key codes (winit 0.16.0 removed these because Windows now generates LAlt and RAlt instead • Replace set_cursor_state with hide_cursor (winit 0.16.0 removed the set_cursor_state function) • Replace GlWindow::hidpi_factor with GlWindow::get_hidpi_factor and change to expecting an f64 • Use the glutin/winit dpi size and position types where possible Glutin's dpi change event has been implemented. All size events now return logical sizes. As a result of that, the logical sizes are translated in the `display::handle_rezize` method so DPI scaling works correctly. When the DPI is changed, the glyph cache is updated to make use of the correct font size again. Moving a window to a different screen which is a different DPI caused a racing condition where the logical size of the event was sent to the `handle_resize` method in `src/display.rs`, however if there was a DPI change event before `handle_resize` is able to process this message, it would incorrectly use the new DPI to scale the resize event. To solve this issue instead of sending the logical size to the `handle_resize` method and then converting it to a physical size in there, the `LogicalSize` of the resize event is transformed into a `PhysicalSize` as soon as it's received. This fixes potential racing conditions since all events are processed in order. The padding has been changed so it's also scaled by DPR. The `scale_with_dpi` config option has been removed. If it's not present a warning will be emitted. The `winit` dependency on Windows has been removed. All interactions with winit in Alacritty are handled through glutin.
2018-10-16Add support for Windows (#1374)Zac Pullar-Strecker
Initial support for Windows is implemented using the winpty translation layer. Clipboard support for Windows is provided through the `clipboard` crate, and font rasterization is provided by RustType. The tty.rs file has been split into OS-specific files to separate standard pty handling from the winpty implementation. Several binary components are fetched via build script on windows including libclang and winpty. These could be integrated more directly in the future either by building those dependencies as part of the Alacritty build process or by leveraging git lfs to store the artifacts. Fixes #28.
2018-09-30Drop terminal lock before renderingtrimental
The terminal lock is now dropped before rendering by storing all grid cells before clearing the screen. This frees the terminal to do other things since the lock is now free, which lead to a performance benefit with high throughput applications.
2018-09-19Add hidden escape sequenceChristian Duerr
This adds support for the `hidden` escape sequence `\e[8m`, which will render the text as invisible. This has also raised a few questions about the rendering of foreground and background colors and their interaction with the different escape sequences. Previously, Alacritty has oriented itself after URxvt, which has some strange and unexpected behavior. The new implementation of color inversion is modeled after XTerm, which has a consistent pattern of always inverting the foreground and background colors. This should hopefully lead to less confusion for the user and a more consistent behavior. A full matrix showcasing the new way Alacritty inverses text can be found here: https://i.imgur.com/d1XavG7.png This fixes #1454 and fixes #1455.
2018-09-17Bump version number to 0.2.0 (#1492)Christian Duerr
* Change deb installation from crates.io to git There have been a number of issues an PRs opened since the cargo-deb installation does not work with the latest version from crates.io. To help out users until the crates.io version is updated, the installation instructions have been temporarily changed to install `cargo-deb` through github. * Revert cargo-deb install back to use crates.io Since `cargo-deb` has been updated on crates.io it is now possible to just install it from crates.io and build Alacritty's deb without having to rely on github. * Update dependencies This fixes an `illegal hardware instruction (core dumped)` error when building in release mode. * Remove redundant copy when selecting font_key * Bump version number to 0.2.0 Since the Scrollback branch introduces some major changes, this bumps the version number from 0.1.0 to 0.2.0. The versions of Alacritty have not been updated regularly to this point, so the scrollback branch is a good point in time to start updating Alacritty's version on a regular basis. Further changes to the readme, like dropping the 'alpha' status and updating it to 'beta' could also be introduced with this branch. This way there will be a clean cut which updates everything as soon as scrollback is merged. Building versions is another thing which would be a good thing to start reasonably quickly. However starting this on the main branch after scrollback has been merged seems like a more reliable way to move forward. This fixes #1240. * Add a CHANGELOG file A CHANGELOG file has been added to offer a bit more transparency over which features have been changed, added and potentially removed in Alacritty. There are various formats available for the CHANGELOG file but the most common and sensible one seems to be the one defined by https://keepachangelog.com/en/1.0.0. Following the template proposed by this it should be possible to create a clear CHANGELOG which makes it simple for new contributors to figure out exactly which formatting should be used for it. Since there have been quite a few changes to Alacritty already, not all changes have been added to the changelog. However a few entries have been ported just to give a bit of an example what the format should look like. This also helps with the 0.2.0 version since it will not be completely empty in the changelog. This fixes #1534. * Update CHANGELOG This updates the CHANGELOG to include the changes introduced by 43882ade33d4c14ee7248e489a2d33395faaa0b1.
2018-07-21Scrollback cleanupChristian Duerr
There were some unneeded codeblocks and TODO/XXX comments in the code that have been removed. All issues marked with TODO/XXX have either been already resolved or tracking issues exist.
2018-06-02Cleanup styleJoe Wilm
2018-05-11Fix clippy lintsChristian Duerr
2018-03-12Prevent negative cell dimensions (#1181)Christian Duerr
Prevent the cell dimensions from going below 1, this bug resulted in allocation of large amounts of memory in the scrollback PR but is also present on master. Currently the approach is to just `panic!`, however an `eprintln!` and `exit` could be an alternative too. I don't think it's realistic to check this at startup and it should have no performance impact since the failing method is only called once at startup. To make it a bit more clear what kind of values are accepted, the datatypes of offsets and paddings have also been changed so that these don't accept floats anymore and padding can never be negative. This should allow us to be a bit more strict with the config to make sure that errors are printed when invalid values are specified (like negative padding). This fixes #1167.
2018-03-04Remove all instances of unwrap() from configChristian Duerr
Unwrapping inside the config file parsing can lead to some issues that prevent us from falling back to a default configuration file. One instance of that issue was mentioned in #1135. Now all instances of `unwrap()` have been removed and replaced with proper error handling. This will make the config more robust and prevents live reload from silently breaking while alacritty is running. This also fixes a few currently existing clippy issues. Clippy added an additonal lint which complains about `MyStruct { field: field }`. These issues have been fixed, except for some false-positives and issues in external macros which will probably be fixed with future updates (rust-lang-nursery/bitflags#149)
2018-01-26Update dependenciesgolem131
Updated the version of some dependencies. This also changes to a new clippy version so clippy can work with the latest nightly compiler again. Some issues created by new lints have been fixed.
2018-01-06Add clippy check to travisChristian Duerr
This commit adds clippy as a required step of the build process. To make this possible, all existing clippy issues have been resolved.
2018-01-05Prevent font_size_modifier from sinking too low (#994)Christian Duerr
This replaces the `font_size_modifier` stored on the `Term` struct with a `font_size` field. With this change it is not necessary anymore to calculate the new font size from a delta but the current font size is always stored directly on the `Term` struct. As a result of this it is now possible to increase the font size by more than 127 steps at runtime. It also limits the minimum font size to 1, so issues with the `font_size_modifier` dropping far below font size 1 are resolved with this change. This fixes #955.
2017-12-24Fix stack overflow with too large glyphsJoe Wilm
This resolves the remaining issue of #842.
2017-12-23Update bitflags to v1Chet Gurevitch
2017-12-22Share LoadGlyph implementationsJoe Wilm
Previously there were two separate but intended-to-be-identical implementations. Now the two implementations simply delegate to a single, shared method. This should help correctness issues in the future.
2017-12-22Change LoadGlyph in LoaderApi to match RenderApiChristian Duerr
2017-12-22Fix stack-overflow when creating a new atlasChristian Duerr
When an atlas is full and the `insert` call fails, a new atlas should be created. This is the current strategy, however the atlas is put at the end of the vector, but the `current_atlas` index is set to 0, instead of the last element. This leads to a recursion where it keeps trying to insert into the full atlas at position 0 instead of the new at `atlas.len() - 1`. With this simple fix a stack-overflow is prevented because the new atlas is inserted as the first element, which then will be used correctly for loading new glyphs. This fixes jwilm/alacritty/issues/842 and might also solve jwilm/alacritty/issues/914 (I wasn't able to reproduce this with the latest master).
2017-12-03clippy: do and don't pass some things by reference as suggested ↵Matthias Krüger
(needless_pass_by_value, needless_borrow).
2017-12-03clippy: fix if_not_else warning 'breaking' the build. Swap blocks and change ↵Matthias Krüger
to "==".
2017-10-26Fix stack overflowJoe Wilm
Resolves #872
2017-10-21Fix solid background color opacity (#847)Joe Wilm
Since landing the patch adding transparency support to Alacritty, there's been an issue where othewise solid background cells were also being rendered partially transparent. Now, all filled background cells are rendered fully opaque. Some logic was added to support discarding filled backgrounds which had the same color as the default background. This means that, if the default background is #000 and a cell has that background, it will never be rendered opaque. This may not be correct. Note that many truecolor vim color schemes print spaces for default colored background cells. Performance can be dramatically improved by using ctermbg=NONE guibg=NONE to skip rendering those cells.
2017-10-14Fix memory leak from font resizingJoe Wilm
The source of the leak was loading up multiple copies of the FT_face even when not necessary. Fonts are now appropriately cached for FreeType when going through the `Rasterize::load_font` API. Additionally, textures in the glyph cache are now reused. The result of this is that resizing to already loaded fonts is free from a memory consumption perspective.
2017-10-14Implement user actions for font resize (#625)Dan Aloni
Adds support for font resizing at run-time. Three new actions are introduced: * IncreaseFontSize - Increases current font size by 1.0 * DecreaseFontSize - Decreases current font size by 1.0 * ResetFontSize - Resets font size to that specified in the configuration. The stock config files have example configuration for each which should match gnome-terminal. For convenience, the config entries are: - { key: Key0, mods: Control, action: ResetFontSize } - { key: Equals, mods: Control, action: IncreaseFontSize } - { key: Subtract, mods: Control, action: DecreaseFontSize }
2017-09-27Use clippy = "*", update, and fix some warnings (#796)Aaron Hill
Because there are so many clippy warnings in the current codebase, this commit removes '#![cfg_attr(feature = "clippy", deny(clippy))]', to make it easier to fix warnings incrementally.
2017-09-05Comment about duration arg to file watcherJoe Wilm
2017-09-05Reduce file watcher debounce periodJoe Wilm
500ms introduced a visual lag between file save and display update.
2017-09-05Update notifyJonathan Schleußer
2017-08-20Add background_opacity option to set terminal transparency (#331)Gabriel Martinez
The option is an Alpha struct that ensures that the contained float is between 0.0 and 1.0. Background colors are multiplied by the opacity to properly alpha blend them.
2017-07-28Support background and foreground color escape codes (#662)Tuomas Siipola
2017-07-03Revert "Reduce InstanceData footprint"Joe Wilm
This reverts commit 3cdba291242cc1c1684bff7f8242262b1cdeb582. On some systems, the target commit actually caused a massive performance issue rather than fixing one.
2017-07-01Reduce InstanceData footprintJoe Wilm
The InstanceData type in the rendering subsystem was previously 16 floats which occupied a total of 64 bytes per instance. This meant that for every character or background cell drawn, 64 bytes were sent to the GPU. In the case of a 400x100 cell grid, a total of 2.5MB would be sent. This patch reduces InstanceData's size to 26 bytes, a 60% improvement! Using the above example for comparison, a worst case of 1MB would be transferred. The motivation for this patch comes from macOS. Once the terminal grid would reach a certain size, performance experienced a sharp and dramatic drop (render times would go from ~3ms to ~16ms). I don't want to speculate too much on the underlying issue, but suffice it to say that this patch alleviates the problem in my testing.
2017-06-01avoid named field shorthandMartin Algesten
2017-05-31somewhat DRYer code for font loadingMartin Algesten
2017-05-06Work around ICEJoe Wilm
2017-05-06Add window padding optionTuomas Siipola
Padding can be configured by using the `padding` field in the config file, like so: padding: x: 2 y: 2 which would result in a 2px padding within each side of the window.
2017-05-06Fix glyph offsets in cellJoe Wilm
We previously had a hard-coded value for aligning glyphs within cells. The font descent is now used, and the offset should be correct by default.
2017-05-01Combine FontOffset and GlyphOffset structs into Delta structAaron Williamson
The two structs are very similar, so there is no reason for them to be separate. Instead combine them into a single Delta struct, which can be used to shift a point in a two dimensional plane.
2017-05-01Add glyph offset option to user configurationAaron Williamson
Add the ability to move glyphs within their cells on a global basis via an option in the configuration file.
2017-05-01Remove unnecessary size argument to metrics functionAaron Williamson
The changes to metric consumption rendered the size argument unnecessary, remove it.
2017-02-11Move color list to Term structJoe Wilm
The color list needs to be updated by the parser, and this isn't possible if it's on the config. This change makes sense semantically as well since it's really part of the terminal state. This is in preparation for OSC color parsing.
2017-02-07Add visual bell supportMark Andrus Roberts
This commit adds support for a visual bell. Although the Handler in src/ansi.rs warns "Hopefully this is never implemented", I wanted to give it a try. A new config option is added, `visual_bell`, which sets the `duration` and `animation` function of the visual bell. The default `duration` is 150 ms, and the default `animation` is `EaseOutExpo`. To disable the visual bell, set its duration to 0. The visual bell is modeled by VisualBell in src/term/mod.rs. It has a method to ring the bell, `ring`, and another method, `intensity`. Both return the "intensity" of the bell, which ramps down from 1.0 to 0.0 at a rate set by `duration` and `animation`. Whether or not the Processor waits for events is now configurable in order to allow for smooth drawing of the visual bell.
2017-01-26Optimize glyph cache accessJoe Wilm
Loading a glyph from the cache is a very hot operation in the renderer. The original implementation would first check if a glyph was loaded and then call `get()` which would have to search a second time. This showed up as a very slow point in profiles. This patch addresses glyph cache access in two ways: by using a faster hasher optimized for small keys (fnv), and by using the entry API for fetching a cached glyph. The `fnv` hasher is faster than the default and is very efficient for small keys. Using the entry API on the HashMap means only 1 lookup instead of two. The entry API has a downside where the key needs to get cloned on fetches. Reducing the GlyphKey width to 64-bits helps in both areas. Copying an 8-byte wide type is very cheap and thus limits downside of the entry API. The small width also helps with the hasher performance. Over all, this patch reduced typical render times by several hundred microseconds on a 2013 MacBook Pro with a full screen terminal full of text.
2017-01-23Use the log-crate instead of printing to stdoutLukas Lueg
2017-01-06Remove need for inclusive rangesManish Goregaokar
2017-01-05Fix ARMTaylor Trump
2017-01-02Rework font loadingJoe Wilm
This work started because we wanted to be able to simply say "monospace" on Linux and have it give us some sort of font. The config format for fonts changed to accomodate this new paradigm. As a result, italic and bold can have different families from the normal (roman) face. The fontconfig based font resolution probably works a lot better than the CoreText version at this point. With CoreText, we simply iterate over fonts and check it they match the requested properties. What's worse is that the CoreText version requires a valid family. With fontconfig, it will just provide the closest matching thing and use it (unless a specific style is requested).