TextFormat
This commit is contained in:
@@ -8,6 +8,7 @@ using GeneralInputKey;
|
||||
using TerminalUI.Controls;
|
||||
using TerminalUI.Extensions;
|
||||
using TerminalUI.Models;
|
||||
using TerminalUI.TextFormat;
|
||||
using TerminalUI.Traits;
|
||||
using TerminalUI.ViewExtensions;
|
||||
|
||||
@@ -22,11 +23,26 @@ public class Dialogs
|
||||
|
||||
private Action? _readInputChildHandlerUnSubscriber;
|
||||
|
||||
|
||||
private readonly ITextFormat _specialItemNamePartFormat;
|
||||
|
||||
public Dialogs(IRootViewModel rootViewModel, ITheme theme)
|
||||
{
|
||||
_rootViewModel = rootViewModel;
|
||||
_theme = theme;
|
||||
|
||||
_specialItemNamePartFormat = new OrFormat
|
||||
{
|
||||
Format1 = new AnsiFormat
|
||||
{
|
||||
IsUnderline = true
|
||||
},
|
||||
Format2 = new SimpleFormat
|
||||
{
|
||||
Foreground = _theme.DefaultForegroundAccentColor
|
||||
}
|
||||
};
|
||||
|
||||
rootViewModel.FocusReadInputElement += element =>
|
||||
{
|
||||
_inputElementToFocus = element;
|
||||
@@ -185,16 +201,15 @@ public class Dialogs
|
||||
ColumnDefinitionsObject = "* *",
|
||||
ChildInitializer =
|
||||
{
|
||||
new ItemsControl<IPreviewElement, ItemNamePart>()
|
||||
new ItemsControl<IPreviewElement, ItemNamePart>
|
||||
{
|
||||
Orientation = Orientation.Horizontal,
|
||||
ItemTemplate = ItemNamePartItemTemplate
|
||||
}.Setup(i => i.Bind(
|
||||
i,
|
||||
dc => ((DoubleItemNamePartListPreview) dc).ItemNameParts1,
|
||||
c => c.ItemsSource,
|
||||
v => v)),
|
||||
new ItemsControl<IPreviewElement, ItemNamePart>()
|
||||
c => c.ItemsSource)),
|
||||
new ItemsControl<IPreviewElement, ItemNamePart>
|
||||
{
|
||||
Orientation = Orientation.Horizontal,
|
||||
Extensions =
|
||||
@@ -226,8 +241,8 @@ public class Dialogs
|
||||
);
|
||||
textBlock.Bind(
|
||||
textBlock,
|
||||
dc => dc.IsSpecial ? _theme.DefaultForegroundAccentColor : null,
|
||||
tb => tb.Foreground
|
||||
dc => dc.IsSpecial ? _specialItemNamePartFormat : null,
|
||||
tb => tb.TextFormat
|
||||
);
|
||||
|
||||
return textBlock;
|
||||
@@ -327,8 +342,7 @@ public class Dialogs
|
||||
.Setup(t => t.Bind(
|
||||
t,
|
||||
d => d.DialogService.ReadInput.Value.Inputs,
|
||||
c => c.ItemsSource,
|
||||
v => v
|
||||
c => c.ItemsSource
|
||||
));
|
||||
|
||||
readInputs.WithKeyHandler((_, e) =>
|
||||
|
||||
@@ -91,8 +91,7 @@ public class Timeline
|
||||
.Setup(i => i.Bind(
|
||||
i,
|
||||
dc => dc.TimelineViewModel.ParallelCommandsGroups[0].Commands,
|
||||
i => i.ItemsSource,
|
||||
v => v))
|
||||
i => i.ItemsSource))
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -185,6 +185,30 @@ public class MainWindow
|
||||
},
|
||||
ChildInitializer =
|
||||
{
|
||||
new StackPanel<IRootViewModel>
|
||||
{
|
||||
Orientation = Orientation.Horizontal,
|
||||
ChildInitializer =
|
||||
{
|
||||
new TextBlock<IRootViewModel>
|
||||
{
|
||||
Margin = "0 0 1 0",
|
||||
}
|
||||
.Setup(t => t.Bind(
|
||||
t,
|
||||
dc => dc.AppState.SelectedTab.Value.CurrentSelectedItem.Value.Attributes,
|
||||
tb => tb.Text)),
|
||||
new TextBlock<IRootViewModel>
|
||||
{
|
||||
Margin = "0 0 1 0",
|
||||
}
|
||||
.Setup(t => t.Bind(
|
||||
t,
|
||||
dc => dc.AppState.SelectedTab.Value.CurrentSelectedItem.Value.ModifiedAt,
|
||||
tb => tb.Text,
|
||||
v => v.ToString()))
|
||||
}
|
||||
},
|
||||
new TextBlock<IRootViewModel>
|
||||
{
|
||||
Extensions = {new GridPositionExtension(1, 0)}
|
||||
|
||||
@@ -13,7 +13,7 @@ public static class ColorSchema
|
||||
public static void PrintColorSchema(ITheme theme, IConsoleDriver consoleDriver)
|
||||
{
|
||||
consoleDriver.Dispose();
|
||||
consoleDriver.ResetColor();
|
||||
consoleDriver.ResetStyle();
|
||||
PrintThemeColors(theme, consoleDriver);
|
||||
|
||||
if (theme is IColorSampleProvider colorSampleProvider)
|
||||
@@ -46,7 +46,7 @@ public static class ColorSchema
|
||||
PrintColor(consoleDriver, colorProperty.Name, color, colorTextStartX);
|
||||
}
|
||||
|
||||
consoleDriver.ResetColor();
|
||||
consoleDriver.ResetStyle();
|
||||
consoleDriver.Write(Environment.NewLine);
|
||||
}
|
||||
|
||||
@@ -95,13 +95,13 @@ public static class ColorSchema
|
||||
PrintColor(consoleDriver, key, value, colorTextStartX);
|
||||
}
|
||||
|
||||
consoleDriver.ResetColor();
|
||||
consoleDriver.ResetStyle();
|
||||
consoleDriver.Write(Environment.NewLine);
|
||||
}
|
||||
|
||||
private static void PrintColor(IConsoleDriver consoleDriver, string name, IColor? color, int colorTextStartX)
|
||||
{
|
||||
consoleDriver.ResetColor();
|
||||
consoleDriver.ResetStyle();
|
||||
consoleDriver.Write(name + ":");
|
||||
var y = consoleDriver.GetCursorPosition().Y;
|
||||
consoleDriver.SetCursorPosition(new Position(colorTextStartX, y));
|
||||
@@ -124,7 +124,7 @@ public static class ColorSchema
|
||||
consoleDriver.Write("Sample text");
|
||||
}
|
||||
|
||||
consoleDriver.ResetColor();
|
||||
consoleDriver.ResetStyle();
|
||||
consoleDriver.Write(Environment.NewLine);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user