@@ -177,35 +177,13 @@ class TerminalPainter extends CustomPainter {
177177 color = color.withOpacity (0.5 );
178178 }
179179
180- final styleToUse = (style.textStyleProvider != null )
181- ? style.textStyleProvider !(
182- color: color,
183- fontSize: style.fontSize,
184- fontWeight: flags.hasFlag (CellFlags .bold)
185- ? FontWeight .bold
186- : FontWeight .normal,
187- fontStyle: flags.hasFlag (CellFlags .italic)
188- ? FontStyle .italic
189- : FontStyle .normal,
190- decoration: flags.hasFlag (CellFlags .underline)
191- ? TextDecoration .underline
192- : TextDecoration .none,
193- )
194- : TextStyle (
195- color: color,
196- fontSize: style.fontSize,
197- fontWeight: flags.hasFlag (CellFlags .bold)
198- ? FontWeight .bold
199- : FontWeight .normal,
200- fontStyle: flags.hasFlag (CellFlags .italic)
201- ? FontStyle .italic
202- : FontStyle .normal,
203- decoration: flags.hasFlag (CellFlags .underline)
204- ? TextDecoration .underline
205- : TextDecoration .none,
206- fontFamily: 'monospace' ,
207- fontFamilyFallback: style.fontFamily,
208- );
180+ final styleToUse = PaintHelper .getStyleToUse (
181+ style,
182+ color,
183+ bold: flags.hasFlag (CellFlags .bold),
184+ italic: flags.hasFlag (CellFlags .italic),
185+ underline: flags.hasFlag (CellFlags .underline),
186+ );
209187
210188 character = textLayoutCache.performAndCacheLayout (
211189 String .fromCharCode (codePoint), styleToUse, cellHash);
@@ -226,18 +204,27 @@ class CursorPainter extends CustomPainter {
226204 final bool focused;
227205 final bool blinkVisible;
228206 final int cursorColor;
207+ final int textColor;
208+ final String composingString;
209+ final TextLayoutCache textLayoutCache;
210+ final TerminalStyle style;
229211
230212 CursorPainter ({
231213 required this .visible,
232214 required this .charSize,
233215 required this .focused,
234216 required this .blinkVisible,
235217 required this .cursorColor,
218+ required this .textColor,
219+ required this .composingString,
220+ required this .textLayoutCache,
221+ required this .style,
236222 });
237223
238224 @override
239225 void paint (Canvas canvas, Size size) {
240- if (blinkVisible && visible) {
226+ bool isVisible = visible && (blinkVisible || composingString != '' );
227+ if (isVisible) {
241228 _paintCursor (canvas);
242229 }
243230 }
@@ -249,7 +236,8 @@ class CursorPainter extends CustomPainter {
249236 focused != oldDelegate.focused ||
250237 visible != oldDelegate.visible ||
251238 charSize.cellWidth != oldDelegate.charSize.cellWidth ||
252- charSize.cellHeight != oldDelegate.charSize.cellHeight;
239+ charSize.cellHeight != oldDelegate.charSize.cellHeight ||
240+ composingString != oldDelegate.composingString;
253241 }
254242 return true ;
255243 }
@@ -262,5 +250,42 @@ class CursorPainter extends CustomPainter {
262250
263251 canvas.drawRect (
264252 Rect .fromLTWH (0 , 0 , charSize.cellWidth, charSize.cellHeight), paint);
253+
254+ if (composingString != '' ) {
255+ final styleToUse = PaintHelper .getStyleToUse (style, Color (textColor));
256+ final character = textLayoutCache.performAndCacheLayout (
257+ composingString, styleToUse, null );
258+ canvas.drawParagraph (character, Offset (0 , 0 ));
259+ }
260+ }
261+ }
262+
263+ class PaintHelper {
264+ static TextStyle getStyleToUse (
265+ TerminalStyle style,
266+ Color color, {
267+ bool bold = false ,
268+ bool italic = false ,
269+ bool underline = false ,
270+ }) {
271+ return (style.textStyleProvider != null )
272+ ? style.textStyleProvider !(
273+ color: color,
274+ fontSize: style.fontSize,
275+ fontWeight: bold ? FontWeight .bold : FontWeight .normal,
276+ fontStyle: italic ? FontStyle .italic : FontStyle .normal,
277+ decoration:
278+ underline ? TextDecoration .underline : TextDecoration .none,
279+ )
280+ : TextStyle (
281+ color: color,
282+ fontSize: style.fontSize,
283+ fontWeight: bold ? FontWeight .bold : FontWeight .normal,
284+ fontStyle: italic ? FontStyle .italic : FontStyle .normal,
285+ decoration:
286+ underline ? TextDecoration .underline : TextDecoration .none,
287+ fontFamily: 'monospace' ,
288+ fontFamilyFallback: style.fontFamily,
289+ );
265290 }
266291}
0 commit comments