@@ -29,6 +29,7 @@ class TerminalView extends StatefulWidget {
2929 this .autofocus = false ,
3030 ScrollController ? scrollController,
3131 InputBehavior ? inputBehavior,
32+ this .padding = 0.0 ,
3233 }) : focusNode = focusNode ?? FocusNode (),
3334 scrollController = scrollController ?? ScrollController (),
3435 inputBehavior = inputBehavior ?? InputBehaviors .platform,
@@ -42,6 +43,8 @@ class TerminalView extends StatefulWidget {
4243 final TerminalStyle style;
4344 final double opacity;
4445
46+ final double padding;
47+
4548 final InputBehavior inputBehavior;
4649
4750 // get the dimensions of a rendered character
@@ -165,7 +168,9 @@ class _TerminalViewState extends State<TerminalView> {
165168 child: MouseRegion (
166169 cursor: SystemMouseCursors .text,
167170 child: LayoutBuilder (builder: (context, constraints) {
168- onWidgetSize (constraints.maxWidth, constraints.maxHeight);
171+ onWidgetSize (constraints.maxWidth - widget.padding * 2 ,
172+ constraints.maxHeight - widget.padding * 2 );
173+
169174 // use flutter's Scrollable to manage scrolling to better integrate
170175 // with widgets such as Scrollbar.
171176 return NotificationListener <ScrollNotification >(
@@ -186,16 +191,20 @@ class _TerminalViewState extends State<TerminalView> {
186191 );
187192 }
188193
194+ final viewPortHeight =
195+ constraints.maxHeight - widget.padding * 2 ;
196+
189197 // set viewport height.
190- offset.applyViewportDimension (constraints.maxHeight );
198+ offset.applyViewportDimension (viewPortHeight );
191199
192200 if (widget.terminal.isReady) {
193201 final minScrollExtent = 0.0 ;
194202
195203 final maxScrollExtent = math.max (
196204 0.0 ,
197- _cellSize.cellHeight * widget.terminal.bufferHeight -
198- constraints.maxHeight);
205+ _cellSize.cellHeight *
206+ (widget.terminal.bufferHeight -
207+ widget.terminal.terminalHeight));
199208
200209 // set how much the terminal can scroll
201210 offset.applyContentDimensions (
@@ -260,29 +269,32 @@ class _TerminalViewState extends State<TerminalView> {
260269 },
261270 child: Container (
262271 constraints: BoxConstraints .expand (),
263- child: Stack (
264- children: < Widget > [
265- CustomPaint (
266- painter: TerminalPainter (
267- terminal: widget.terminal,
268- style: widget.style,
269- charSize: _cellSize,
270- textLayoutCache: textLayoutCache,
272+ child: Padding (
273+ padding: EdgeInsets .all (widget.padding),
274+ child: Stack (
275+ children: < Widget > [
276+ CustomPaint (
277+ painter: TerminalPainter (
278+ terminal: widget.terminal,
279+ style: widget.style,
280+ charSize: _cellSize,
281+ textLayoutCache: textLayoutCache,
282+ ),
271283 ),
272- ),
273- Positioned (
274- child: CursorView (
275- terminal: widget.terminal,
276- cellSize: _cellSize,
277- focusNode: widget.focusNode,
278- blinkOscillator: blinkOscillator,
284+ Positioned (
285+ child: CursorView (
286+ terminal: widget.terminal,
287+ cellSize: _cellSize,
288+ focusNode: widget.focusNode,
289+ blinkOscillator: blinkOscillator,
290+ ),
291+ width: _cellSize.cellWidth,
292+ height: _cellSize.cellHeight,
293+ left: _getCursorOffset ().dx,
294+ top: _getCursorOffset ().dy,
279295 ),
280- width: _cellSize.cellWidth,
281- height: _cellSize.cellHeight,
282- left: _getCursorOffset ().dx,
283- top: _getCursorOffset ().dy,
284- ),
285- ],
296+ ],
297+ ),
286298 ),
287299 color: Color (widget.terminal.backgroundColor).withOpacity (
288300 widget.opacity,
@@ -301,8 +313,8 @@ class _TerminalViewState extends State<TerminalView> {
301313
302314 /// Get global cell position from mouse position.
303315 Position getMouseOffset (double px, double py) {
304- final col = (px / _cellSize.cellWidth).floor ();
305- final row = (py / _cellSize.cellHeight).floor ();
316+ final col = ((px - widget.padding) / _cellSize.cellWidth).floor ();
317+ final row = ((py - widget.padding) / _cellSize.cellHeight).floor ();
306318
307319 final x = col;
308320 final y = widget.terminal.convertViewLineToRawLine (row) -
0 commit comments