mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-12 02:57:22 +00:00
fix: terminal, web, fonts (#12376)
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:flutter_hbb/common.dart';
|
import 'package:flutter_hbb/common.dart';
|
||||||
import 'package:flutter_hbb/models/model.dart';
|
import 'package:flutter_hbb/models/model.dart';
|
||||||
import 'package:flutter_hbb/models/terminal_model.dart';
|
import 'package:flutter_hbb/models/terminal_model.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:xterm/xterm.dart';
|
import 'package:xterm/xterm.dart';
|
||||||
import '../../desktop/pages/terminal_connection_manager.dart';
|
import '../../desktop/pages/terminal_connection_manager.dart';
|
||||||
|
|
||||||
@@ -31,6 +32,12 @@ class _TerminalPageState extends State<TerminalPage>
|
|||||||
late FFI _ffi;
|
late FFI _ffi;
|
||||||
late TerminalModel _terminalModel;
|
late TerminalModel _terminalModel;
|
||||||
|
|
||||||
|
// For web only.
|
||||||
|
// 'monospace' does not work on web, use Google Fonts, `??` is only for null safety.
|
||||||
|
final String _robotoMonoFontFamily = isWeb
|
||||||
|
? (GoogleFonts.robotoMono().fontFamily ?? 'monospace')
|
||||||
|
: 'monospace';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -81,6 +88,7 @@ class _TerminalPageState extends State<TerminalPage>
|
|||||||
_terminalModel.terminal,
|
_terminalModel.terminal,
|
||||||
controller: _terminalModel.terminalController,
|
controller: _terminalModel.terminalController,
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
|
textStyle: _getTerminalStyle(),
|
||||||
backgroundOpacity: 0.7,
|
backgroundOpacity: 0.7,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 5.0, vertical: 2.0),
|
padding: const EdgeInsets.symmetric(horizontal: 5.0, vertical: 2.0),
|
||||||
onSecondaryTapDown: (details, offset) async {
|
onSecondaryTapDown: (details, offset) async {
|
||||||
@@ -101,6 +109,17 @@ class _TerminalPageState extends State<TerminalPage>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/TerminalStudio/xterm.dart/issues/42#issuecomment-877495472
|
||||||
|
// https://github.com/TerminalStudio/xterm.dart/issues/198#issuecomment-2526548458
|
||||||
|
TerminalStyle _getTerminalStyle() {
|
||||||
|
return isWeb
|
||||||
|
? TerminalStyle(
|
||||||
|
fontFamily: _robotoMonoFontFamily,
|
||||||
|
fontSize: 14,
|
||||||
|
)
|
||||||
|
: const TerminalStyle();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get wantKeepAlive => true;
|
bool get wantKeepAlive => true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -689,6 +689,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.3"
|
version: "2.1.3"
|
||||||
|
google_fonts:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: google_fonts
|
||||||
|
sha256: b1ac0fe2832c9cc95e5e88b57d627c5e68c223b9657f4b96e1487aa9098c7b82
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.2.1"
|
||||||
graphs:
|
graphs:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ dependencies:
|
|||||||
extended_text: 14.0.0
|
extended_text: 14.0.0
|
||||||
xterm: 4.0.0
|
xterm: 4.0.0
|
||||||
sqflite: 2.2.0
|
sqflite: 2.2.0
|
||||||
|
google_fonts: ^6.2.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
icons_launcher: ^2.0.4
|
icons_launcher: ^2.0.4
|
||||||
|
|||||||
Reference in New Issue
Block a user