mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
支持上传脚本
This commit is contained in:
@@ -12,14 +12,16 @@ class LineNumberController extends TextEditingController {
|
||||
LineNumberController(this.lineNumberBuilder);
|
||||
|
||||
@override
|
||||
TextSpan buildTextSpan({required BuildContext context, TextStyle? style, bool? withComposing}) {
|
||||
TextSpan buildTextSpan(
|
||||
{required BuildContext context, TextStyle? style, bool? withComposing}) {
|
||||
final children = <TextSpan>[];
|
||||
final list = text.split("\n");
|
||||
for (int k = 0; k < list.length; k++) {
|
||||
final el = list[k];
|
||||
final number = int.parse(el);
|
||||
var textSpan = TextSpan(text: el, style: style);
|
||||
if (lineNumberBuilder != null) textSpan = lineNumberBuilder!(number, style);
|
||||
if (lineNumberBuilder != null)
|
||||
textSpan = lineNumberBuilder!(number, style);
|
||||
children.add(textSpan);
|
||||
if (k < list.length - 1) children.add(TextSpan(text: "\n"));
|
||||
}
|
||||
@@ -199,7 +201,8 @@ class CodeFieldState extends State<CodeField> {
|
||||
}
|
||||
|
||||
// Wrap the codeField in a horizontal scrollView
|
||||
Widget _wrapInScrollView(Widget codeField, TextStyle textStyle, double minWidth) {
|
||||
Widget _wrapInScrollView(
|
||||
Widget codeField, TextStyle textStyle, double minWidth) {
|
||||
final leftPad = widget.lineNumberStyle.margin / 2;
|
||||
final intrinsic = IntrinsicWidth(
|
||||
child: Column(
|
||||
@@ -239,7 +242,8 @@ class CodeFieldState extends State<CodeField> {
|
||||
final defaultText = Colors.grey.shade200;
|
||||
|
||||
final theme = widget.controller.theme;
|
||||
Color? backgroundCol = widget.background ?? theme?[ROOT_KEY]?.backgroundColor ?? defaultBg;
|
||||
Color? backgroundCol =
|
||||
widget.background ?? theme?[ROOT_KEY]?.backgroundColor ?? defaultBg;
|
||||
if (widget.decoration != null) {
|
||||
backgroundCol = null;
|
||||
}
|
||||
@@ -249,14 +253,16 @@ class CodeFieldState extends State<CodeField> {
|
||||
fontSize: textStyle.fontSize ?? 16.0,
|
||||
);
|
||||
TextStyle numberTextStyle = widget.lineNumberStyle.textStyle ?? TextStyle();
|
||||
final numberColor = (theme?[ROOT_KEY]?.color ?? defaultText).withOpacity(0.7);
|
||||
final numberColor =
|
||||
(theme?[ROOT_KEY]?.color ?? defaultText).withOpacity(0.7);
|
||||
// Copy important attributes
|
||||
numberTextStyle = numberTextStyle.copyWith(
|
||||
color: numberTextStyle.color ?? numberColor,
|
||||
fontSize: textStyle.fontSize,
|
||||
fontFamily: textStyle.fontFamily,
|
||||
);
|
||||
final cursorColor = widget.cursorColor ?? theme?[ROOT_KEY]?.color ?? defaultText;
|
||||
final cursorColor =
|
||||
widget.cursorColor ?? theme?[ROOT_KEY]?.color ?? defaultText;
|
||||
|
||||
final lineNumberCol = TextField(
|
||||
smartQuotesType: widget.smartQuotesType,
|
||||
@@ -315,7 +321,9 @@ class CodeFieldState extends State<CodeField> {
|
||||
child: LayoutBuilder(
|
||||
builder: (BuildContext context, BoxConstraints constraints) {
|
||||
// Control horizontal scrolling
|
||||
return widget.wrap ? codeField : _wrapInScrollView(codeField, textStyle, constraints.maxWidth);
|
||||
return widget.wrap
|
||||
? codeField
|
||||
: _wrapInScrollView(codeField, textStyle, constraints.maxWidth);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user