@@ -18,6 +18,8 @@ export interface GhosttyCellRange {
1818}
1919
2020const DEFAULT_SELECTION_BACKGROUND = "rgba(72, 122, 191, 0.35)" ;
21+ const POWERLINE_SOLID_RIGHT = "\ue0b0" ;
22+ const POWERLINE_SOLID_LEFT = "\ue0b2" ;
2123
2224function cssColor ( color : GhosttyColor ) : string {
2325 return `rgb(${ color . r } , ${ color . g } , ${ color . b } )` ;
@@ -35,6 +37,30 @@ function sameTextStyle(left: GhosttyCell, right: GhosttyCell): boolean {
3537 ) ;
3638}
3739
40+ function isSolidPowerlineSeparator ( text : string ) : boolean {
41+ return text === POWERLINE_SOLID_RIGHT || text === POWERLINE_SOLID_LEFT ;
42+ }
43+
44+ // Fallback fonts inset or scale these private-use glyphs, leaving a gap where
45+ // the separator should meet the next cell. Fill the triangle from the cell's
46+ // own edges instead, as native terminals do.
47+ function fillSolidPowerlineSeparator (
48+ context : CanvasRenderingContext2D ,
49+ text : string ,
50+ left : number ,
51+ top : number ,
52+ metrics : GhosttyCellMetrics ,
53+ ) : void {
54+ const right = left + metrics . width ;
55+ const [ base , point ] = text === POWERLINE_SOLID_RIGHT ? [ left , right ] : [ right , left ] ;
56+ context . beginPath ( ) ;
57+ context . moveTo ( base , top ) ;
58+ context . lineTo ( point , top + metrics . height / 2 ) ;
59+ context . lineTo ( base , top + metrics . height ) ;
60+ context . closePath ( ) ;
61+ context . fill ( ) ;
62+ }
63+
3864export function ghosttyTextRunEnd (
3965 cells : readonly GhosttyCell [ ] ,
4066 start : number ,
@@ -48,7 +74,7 @@ export function ghosttyTextRunEnd(
4874 end += 1 ;
4975 continue ;
5076 }
51- if ( next . text . length === 0 || ! sameStyle ( next ) ) break ;
77+ if ( next . text . length === 0 || isSolidPowerlineSeparator ( next . text ) || ! sameStyle ( next ) ) break ;
5278 end += 1 ;
5379 }
5480 return end ;
@@ -192,6 +218,20 @@ export function renderGhosttySnapshot(options: {
192218 runStart += 1 ;
193219 continue ;
194220 }
221+ if ( isSolidPowerlineSeparator ( first . text ) ) {
222+ if ( ! first . invisible ) {
223+ context . fillStyle = cssColor ( first . foreground ) ;
224+ fillSolidPowerlineSeparator (
225+ context ,
226+ first . text ,
227+ padding + runStart * metrics . width ,
228+ top ,
229+ metrics ,
230+ ) ;
231+ }
232+ runStart += 1 ;
233+ continue ;
234+ }
195235 const runEnd = ghosttyTextRunEnd ( row . cells , runStart , ( cell ) => sameTextStyle ( cell , first ) ) ;
196236 const text = row . cells
197237 . slice ( runStart , runEnd )
@@ -261,9 +301,13 @@ export function renderGhosttySnapshot(options: {
261301 context . fillRect ( left , top , metrics . width , metrics . height ) ;
262302 const cell = snapshot . rowData [ snapshot . cursorY ] ?. cells [ snapshot . cursorX ] ;
263303 if ( cell ?. text ) {
264- context . font = fontForCell ( cell , fontSize , fontFamily ) ;
265304 context . fillStyle = cssColor ( snapshot . background ) ;
266- context . fillText ( cell . text , left , top + metrics . baseline , metrics . width ) ;
305+ if ( isSolidPowerlineSeparator ( cell . text ) ) {
306+ fillSolidPowerlineSeparator ( context , cell . text , left , top , metrics ) ;
307+ } else {
308+ context . font = fontForCell ( cell , fontSize , fontFamily ) ;
309+ context . fillText ( cell . text , left , top + metrics . baseline , metrics . width ) ;
310+ }
267311 }
268312 }
269313 }
0 commit comments