1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-19 19:31:49 +03:00
Commit Graph

218 Commits

Author SHA1 Message Date
Wez Furlong
c8a58cac06 we now render useless blocks in the fg color via gl 2018-02-16 23:28:51 -08:00
Wez Furlong
20965e786f start hacking on OpenGL ES2 rendering 2018-02-16 21:44:56 -08:00
Wez Furlong
236960e1a8 squeeze one extra row in at the bottom of my screen 2018-02-11 18:54:18 -08:00
Wez Furlong
0ae6b3e753 use xdg-open to open links on click 2018-02-11 12:41:31 -08:00
Wez Furlong
21f0e3fd98 Recognize clicks on hyperlinks
There's plumbing for handling these events in the TerminalHost
trait, but we don't do anything beyond printing them at the moment.
2018-02-11 12:28:37 -08:00
Wez Furlong
b6aa2cffea make hyperlinks show underlined on hover
Adds some plumbing to track the current mouse position and
extract the hyperlink from the cell that is being hovered over.

We render those cells with underline, possibly in a different color.

We don't yet do anything on click.
2018-02-11 12:11:02 -08:00
Wez Furlong
7ad2468937 hide AnswerBack from the public interface
This felt a bit repeatey and it pre-dated the TerminalHost trait.
I'd like to remove it completely but there are some frustrating and
fiddly lifetime concerns with mutable TerminalHost reference so I'm
hiding it from the public interface and bridging it the answerback
stream into the host at the bottom of the advance_bytes method for
now.
2018-02-11 09:40:02 -08:00
Wez Furlong
52ba033ea7 Avoid flickery erase in render_line
This also improves perf.  The issue was that the erase of the whole
line of the background may be observed by the X server when SHM is
enabled because we don't wait for the exposure/copy to the window
pixmap before updating the same row fractionally later.

Avoiding the unconditional erase and just painting the full cell
contents over means that there's no opportunity for a visible flash.

In addition, since we render the cells background individually, that
erase was not needed.

This should save us some work and take some load off the cpu.
2018-02-11 08:59:56 -08:00
Wez Furlong
9feb3bd0e7 fixup width for background/underline/strike
This wasn't correctly handling double-width or ligatures.  In addition,
don't respect the x_advance outside of a ligature run, as it can result
in slightly offset columns for example when `ls -l` shows `--` and that
sequence has a slightly less wide ligatured rendition.

```
echo -e '\e[4mu--nder\e[0m  \e[21mdo--uble\e[0m  \e[9mst--rike\e[0m'
```
2018-02-11 08:47:53 -08:00
Wez Furlong
74cd62e743 extract render_glyph_slices 2018-02-11 08:25:22 -08:00
Wez Furlong
ee603e4cc8 clarify comments 2018-02-11 08:10:16 -08:00
Wez Furlong
1ba432378b extract cursor rendering 2018-02-11 08:05:58 -08:00
Wez Furlong
8ecaa7d6ab extract underline and strikethrough methods 2018-02-11 08:01:06 -08:00
Wez Furlong
0208a7837e start breakin up the paint method
This has grown pretty large.  Splitting out the guts means adopting
the use of RefCell to satisfy the borrow checker.
2018-02-11 07:46:40 -08:00
Wez Furlong
31b270910b make cell_height and cell_width integers
I've been meaning to do this for a while
2018-02-11 07:28:36 -08:00
Wez Furlong
4a0648fef5 Add strikethrough rendering 2018-02-10 21:42:55 -08:00
Wez Furlong
5a6ed045ad Render underline and double underline 2018-02-10 21:25:43 -08:00
Wez Furlong
ac1751f20c factor our line drawing from rect drawing 2018-02-10 20:42:01 -08:00
Wez Furlong
6af3b63d57 make scrollback size configurable 2018-02-10 09:43:54 -08:00
Wez Furlong
beeaacfabc fixup some bad math for under-width ligatures
We were panicking when rendering the || ligature, which is narrower
than we were expecting.  There was also a weird looking assert
that was triggering if we got path the math overflow.
2018-02-10 09:27:59 -08:00
Wez Furlong
6b182ffe52 implement an equivalent to xterm*boldColor
I love my tomato bold!
2018-02-10 08:36:34 -08:00
Wez Furlong
3075e47c89 Allow configuring colors 2018-02-10 08:16:20 -08:00
Wez Furlong
4ce67c7f9a Use the palette crate for blending
I wasn't pleased with how text was rendering on a colored background,
and after some research I discovered that I was neglecting to convert
from sRGB to a linear RGB colorspace, and that this was causing the
blending to have inaccurate results.

This diff pulls in the palette crate to handle the heavy lifting.
It doesn't appear to have any especially fast optimizations for this
though, which is a shame because the blending code I was using
previously was largely integer math with few branches.  The colorspace
conversion has several floating point operations and branches that
are unavoidable :-/

We run a bit hotter on the CPU but the results are much more pleasing
to the eye.
2018-02-09 23:32:35 -08:00
Wez Furlong
6c75ff4146 Use brighter version of ANSI color when bold enabled
This is one of the main reasons that I started to build my
own terminal emulator :-p
2018-02-09 20:54:17 -08:00
Wez Furlong
1619f786a9 Add somewhat primitive text selection for copy/paste 2018-02-08 21:35:26 -08:00
Wez Furlong
4338eecc3f Allow not specifying font_rules in the config file 2018-02-07 15:42:12 -08:00
Wez Furlong
6dd0312980 Don't clip off the last couple of glyph pixels
This is most noticable with a cursive italic font.  When we
were dividing the glyph into cell slices, we could leave off
a 2 pixel wide strip from the last of the sequence and this
looked nasty.

This diff also adjusts come calculations to use the width and
height from the current TextStyle.  Whether this is more or
less correct remains to be seen :-p
2018-02-07 15:31:37 -08:00
Wez Furlong
edd5911535 Add a small font styling engine
This enables selecting an italic font when the cell is italic,
but has more power beyond just that simple property.

This runs a little hot on the CPU so there's probably some caching and
tweaking that can be done to make the evaluation a bit cheaper.
2018-02-07 09:23:24 -08:00
Wez Furlong
7ade4434fe Add basic config file parsing
So that we no longer assume Operator Mono SSm.
We now default to `monospace`.  I just tried this and the font metrics
appear to be wonky, so there's some tweaking to do.
2018-02-07 07:51:04 -08:00
Wez Furlong
401530a899 lookup the $SHELL for the user rather than assume zsh 2018-02-06 22:48:28 -08:00
Wez Furlong
532cf28782 add support for setting the primary selection 2018-02-06 20:40:46 -08:00
Wez Furlong
7657a91188 refactor to make it easier to use and extend TerminalHost 2018-02-05 08:52:35 -08:00
Wez Furlong
a4c7de7b9b We now support shift+insert to paste the selection 2018-02-05 08:22:08 -08:00
Wez Furlong
b24ac14c05 Add TerminalHost trait
This will make it easier to add copy/paste handling in a follow up.
2018-02-04 22:35:33 -08:00
Wez Furlong
5261f9f3d8 Enable mouse reporting
There's a bit of restructuring of XCB event handling going on to enable
this, and we only support SGR reporting at the moment.
2018-02-04 20:53:03 -08:00
Wez Furlong
f89d37401b Enable viewing the scrollback
Both mouse wheel and shift+{PageUp,PageDown} can be used to adjust
the scroll viewport.
2018-02-04 14:19:12 -08:00
Wez Furlong
0bec822f75 create the palette when we create the window
Rather than every time we paint and resize
2018-02-04 09:19:25 -08:00
Wez Furlong
09c70930b9 improve resize handling
Both in terms of resizing the window and running the `resize` utility.
2018-02-04 09:17:05 -08:00
Wez Furlong
4c8e3ffd75 improve clustering and cursor rendering
We weren't quite right with handling the cursor around double-width
characters.  We're now a bit more robust at this because we're
clustering and taking pains to consider the printable width of the
cell as well as the width of the shaped (eg: with contextual ligatures)
glyph.

There may still be issues with contextual ligatures of length 3,
but I haven't managed to nail down exactly the issue yet.
2018-02-04 08:28:32 -08:00
Wez Furlong
904f8fc059 better typing for rows and cursor position 2018-02-02 08:16:07 -08:00
Wez Furlong
5cdb5149c3 suppress keypress debug prints 2018-02-01 00:26:01 -08:00
Wez Furlong
e7e0aeebc2 Add support for cursor keys 2018-01-31 20:31:06 -08:00
Wez Furlong
659ce4fc2d Make answerback more generic, enable title changing 2018-01-31 15:15:23 -08:00
Wez Furlong
11e6d538fc move term to its own crate
This makes it harder to accidentally violate separation of concerns.
2018-01-31 10:50:21 -08:00
Wez Furlong
4dcab21a97 placeholder for alt graphics mode
These are emitted by `top`
2018-01-31 10:15:39 -08:00
Wez Furlong
45793bd594 Add some more tests and bounds checks/limits 2018-01-31 10:07:50 -08:00
Wez Furlong
a55395d7c9 start building out unit tests 2018-01-30 22:44:14 -08:00
Wez Furlong
0eb4dd44b3 add IL and DL sequences
These probably aren't quite right
2018-01-30 07:31:31 -08:00
Wez Furlong
cb9a2129be handle reverse index escape sequence
This unlocks pressing `b` in `less` and `more` to scroll backwards.
To facilitate this I had to do a better job at scrolling up and down,
so beef up the code to enable that.  Scroll regions still need some
work; test case for that is running vim and then opening help.

Also: fixup the y position when rending rows; it was off by one row.
2018-01-29 23:29:56 -08:00
Wez Furlong
0ebf84ee1c adopt dirtying mechanism for more efficient screen updates
We now keep track of the dirty status on a per-line basis
and use that status to realize when we need to repaint a portion
of the screen.  This reduces the compute cost of redrawing
quite significantly; we're no longer on `top` when we're running
`top`!
2018-01-29 20:38:48 -08:00
Wez Furlong
740c3339a5 Add glyph caching 2018-01-29 09:38:06 -08:00
Wez Furlong
5b1ccc59b6 make CSIParser a bit more compact
The simpler escape sequences were getting a bit boiler-platey and long,
so hoist them up and perform matching at the main level.  This has the
side effect of discarding params after a match; that's fine for these
as it only seems to be important for the SGR sequences.
2018-01-29 08:00:30 -08:00
Wez Furlong
be30b1cb54 there's already a wterm, rename to wezterm 2018-01-28 23:52:21 -08:00
Wez Furlong
544dd70ac1 Add CUU, CUD, CUB handling 2018-01-28 23:50:53 -08:00
Wez Furlong
67f07b4fcc add primitive auto wrapping support 2018-01-28 23:44:38 -08:00
Wez Furlong
5dbf90412f bounds check should be on the actual number of cols
Don't trust that a given Line has exactly phys_cols columns.
2018-01-28 23:33:31 -08:00
Wez Furlong
4a4d8c7186 add CUF cursor move support 2018-01-28 22:25:53 -08:00
Wez Furlong
2e73b937bb Add some state to track vertical scroll regions
However, it doesn't really do very much that is useful yet
2018-01-28 21:16:59 -08:00
Wez Furlong
6ed0e81f02 fix SetCursorPosXY; had rows/cols flipped 2018-01-28 21:13:11 -08:00
Wez Furlong
13a856bbb2 add device attributes answerback 2018-01-28 20:46:34 -08:00
Wez Furlong
1059620233 add stub for setting the scroll region 2018-01-28 20:33:21 -08:00
Wez Furlong
2011eec9f2 clamp cursor y position when moving the cursor 2018-01-28 19:30:07 -08:00
Wez Furlong
001eda902b tidy up basic scroll handling
Previously, we would not allocate a new line and would end up
panicking when we went off the end of the default screen height.
2018-01-28 18:05:22 -08:00
Wez Furlong
8d9cd83e6d add some more comments on CSIParser 2018-01-28 17:11:05 -08:00
Wez Furlong
0057b42c4f Pull intermediates check up higher in CSIParser
This should reduce the chance of ambiguous matches for sequences
that have the same 'byte' field but different intermediates.
2018-01-28 17:01:15 -08:00
Wez Furlong
78c3aee697 Add support for responding to escape sequences 2018-01-28 16:43:10 -08:00
Wez Furlong
d28494ac20 recognize device status report codes 2018-01-28 15:11:07 -08:00
Wez Furlong
b696aae51f vim truecolor mode uses kde style rgb sgr 2018-01-28 14:55:28 -08:00
Wez Furlong
a0cc6822ef add support for recognizing some decset modes
We don't do anything about those modes yet.
2018-01-28 14:51:00 -08:00
Wez Furlong
5816928a25 Add support for Erase In Display 2018-01-28 14:12:56 -08:00
Wez Furlong
39a5b5ef0d add some comments about CSIParser 2018-01-28 14:03:57 -08:00
Wez Furlong
d48bc62a18 move all the current CSI parsing into the CSIParser 2018-01-28 13:53:18 -08:00
Wez Furlong
12a839c4ac Adopt slice patterns for parsing CSI 2018-01-28 13:36:17 -08:00
Wez Furlong
2eefee4412 move csi parsing to its own file 2018-01-28 11:35:36 -08:00
Wez Furlong
cedc62e91a fix cursor positioning when ligatures are used 2018-01-28 09:55:28 -08:00
Wez Furlong
dbeda14566 Add ShmImage, a shared memory Pixmap
Using the SHM extension of the X server saves us from sending ~1MB of
bitmap data to the server on many screen update operations for a
modestly sized terminal window.

SHM may not be available in some situations so we need to keep a
fallback that basically works.  This is done via a helper enum
in xwin.rs.

I've removed the unused Pixmap class; the pixmap concept makes the
most sense for us only when SHM is available.
2018-01-28 09:43:36 -08:00
Wez Furlong
91424e427f factor out BitmapImage from Image 2018-01-27 22:58:40 -08:00
Wez Furlong
bf854d0eb0 remove some unused code 2018-01-27 22:24:44 -08:00
Wez Furlong
0ab8cf1eec Render the cursor position, fixup colors
I thought it would be nice to use the default xterm palette, but
I really hate the contrast of its default blue on black, so switch
to the palette from my xterm config.
2018-01-27 22:17:31 -08:00
Wez Furlong
1d4fc17187 apply Deref to simplify Terminal/TerminalState 2018-01-27 21:56:29 -08:00
Wez Furlong
1ae85b2349 send keyboard input to the pty 2018-01-27 21:54:57 -08:00
Wez Furlong
f879447d59 add xgfx::Connection, store atoms inside it 2018-01-27 14:49:15 -08:00
Wez Furlong
ec3c8f04ba move TerminalWindow into its own file 2018-01-27 14:29:07 -08:00
Wez Furlong
5d6d9747c7 expand columns as needed for set_cell 2018-01-27 13:56:35 -08:00
Wez Furlong
2d739eb667 Ensure that the pty is the controlling terminal for the child 2018-01-27 13:51:10 -08:00
Wez Furlong
8080718c71 Listen for sigchld 2018-01-27 13:41:45 -08:00
Wez Furlong
a11a34b031 We're now able to run and render top 2018-01-27 13:38:26 -08:00
Wez Furlong
e63f003ad0 move the pty into the TerminalWindow 2018-01-27 08:43:08 -08:00
Wez Furlong
eef4487d27 plumb XCB events into the mio loop 2018-01-27 08:18:55 -08:00
Wez Furlong
ab74b4c731 proof of concept with having mio drive the pty reads 2018-01-26 09:00:40 -08:00
Wez Furlong
0ecda48f01 Add some code for working with ptys 2018-01-26 08:23:32 -08:00
Wez Furlong
3484b94435 Allow setting full RGB foreground/background color 2018-01-25 21:37:16 -08:00
Wez Furlong
b56209a181 tighten up SGR parsing
Track all the rendition bits described in the SGR section here:
https://invisible-island.net/xterm/ctlseqs/ctlseqs.html

Still need to hook up color matching against the color palette
as described for the 256 color mode flavor.
2018-01-25 10:05:57 -08:00
Wez Furlong
3ec0b3f795 connect model to display, hook up print + some basic SGR 2018-01-24 22:28:03 -08:00
Wez Furlong
342efa810b cell attributes to bitfield, add screen container 2018-01-24 09:13:03 -08:00
Wez Furlong
7e41bb27d4 Add basic attribute setting and rendering 2018-01-23 23:12:30 -08:00
Wez Furlong
641e85650d add terminal cell and colors 2018-01-23 08:57:59 -08:00
Wez Furlong
36a884b872 Add compositing to colorize text
Defines a couple of compositing operators so that we can support having
both colored background and colored text.
2018-01-22 22:32:48 -08:00
Wez Furlong
fb53f2c16b remove cairo dependency
It's a PITA to make it work with pixels without scaling and blurring
2018-01-22 18:54:18 -08:00
Wez Furlong
aef4e340e8 add xcb_util, set window name 2018-01-22 09:02:28 -08:00
Wez Furlong
3ea7bbc501 compute descender, render cell box, fixup GRAY handling 2018-01-22 08:13:00 -08:00
Wez Furlong
31f35554a4 Add text color, improve resize render performance 2018-01-21 17:14:56 -08:00
Wez Furlong
306414baa9 Add double buffering to eliminate flicker
Actually, the flicker was caused by the back pixel setting on the
window; I spent a long time running this down and finally got the
clue from this crusade against flicker:
http://www.ruska.it/michal/flicker.html
2018-01-21 10:25:40 -08:00
Wez Furlong
aa18b273f9 remove sdl. use cairo + xcb
The spacing between glyphs seems too wide.  Need to figure this out.
A bunch of the integer vs float changes in this diff were a result
of trying to run this down, but success has been limited, and in fact
the spacing has increased as a result of making this more correct(!)
2018-01-21 01:32:59 -08:00
Wez Furlong
67c04e7a2a start playing around with xcb+cairo 2018-01-20 14:54:11 -08:00
Wez Furlong
efb566e4bf move this pixelformat thing to be a constant 2018-01-18 07:31:24 -08:00
Wez Furlong
144d8cc3eb start pulling in cairo 2018-01-18 07:20:29 -08:00
Wez Furlong
df64bce18a add some docs, make slightly more efficient when computing cluster size vec 2018-01-17 00:17:22 -08:00
Wez Furlong
93c10590ca println -> debug build only logging 2018-01-17 00:07:31 -08:00
Wez Furlong
06b47bfc58 move FontHolder -> Font
Also change the constructor to pass in a fontconfig pattern
2018-01-17 00:01:34 -08:00
Wez Furlong
79bf022f68 move font code into main source
Initially I wanted to make the font code separate from
the main wterm executable in the hope that it would be
reusable.  However, we do need to be able to reach in
to both the font implementation and the SDL texture
implementation in order to capture the glyph data
into textures, so let's just embrace it all being
in the same crate.
2018-01-16 23:32:23 -08:00
Wez Furlong
739d25c21b cargo fmt with larger column allowance 2018-01-16 23:03:16 -08:00
Wez Furlong
471f3d0800 populate GlyphInfo.text only in debug builds 2018-01-16 23:01:55 -08:00
Wez Furlong
611e4b3505 fixup bearing_x handling and unicode width
Trigger x-scaling based on the x_advance rather than the bitmap width.
Also account for the unicode width of the fragment when scaling.

The use of bearing_x was incorrect; we were subtracting it rather
than adding it and making the glyphs look terrible at smaller sizes.
2018-01-16 22:50:47 -08:00
Wez Furlong
a5535d4c5b scale emoji bitmaps to match size of preferred font 2018-01-16 00:24:49 -08:00
Wez Furlong
2d5c54a642 implement fallback and rendering for color emoji 2018-01-15 22:45:25 -08:00
Wez Furlong
02bab4fcc7 Add fontconfig support to locate fonts
Also restructure things a little bit to facilitate more robust
fallback implementation.
2018-01-15 17:32:31 -08:00
Wez Furlong
d82860ef5a Render text on sdl using harfbuzz and freetype 2018-01-14 23:34:59 -08:00