Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions AGENTS.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/TuiCode.Abstractions/ISettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace TuiCode.Abstractions;
/// <summary>
/// User-facing settings: read current values, mutate them (with live preview side-effects),
/// enumerate available themes, persist to disk. Wraps Terminal.Gui's static
/// <c>ConfigurationManager</c> / <c>ThemeManager</c> surface so the rest of the app stays DI-uniform.
/// <c>TuiConfigurationBuilder</c> / <c>ThemeManager</c> surface so the rest of the app stays DI-uniform.
/// </summary>
public interface ISettingsService
{
Expand Down
11 changes: 11 additions & 0 deletions src/TuiCode.Abstractions/PaneTabs.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Terminal.Gui.ViewBase;
using Terminal.Gui.Views;

namespace TuiCode.Abstractions;
Expand All @@ -18,4 +19,14 @@ public PaneTabs()
}

private static bool? StayPut() => true;

/// <summary>Redraws <paramref name="tab"/>'s header after its title changes; TG would place it at the old width.</summary>
public static void ShowTitle(View tab)
{
if (tab.Border.View is not BorderView { TitleView: { } header }) return;
header.Text = tab.Title;
header.TextFormatter.ConstrainToSize = null;
if (header is ITitleView title) title.MeasuredTabLength = 0;
tab.SetNeedsLayout();
}
}
2 changes: 1 addition & 1 deletion src/TuiCode.Abstractions/TuiCode.Abstractions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Terminal.Gui" Version="2.1.0" />
<PackageReference Include="Terminal.Gui" Version="2.5.0" />
</ItemGroup>

</Project>
3 changes: 1 addition & 2 deletions src/TuiCode.Editor/DiffTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,7 @@ internal void UpdateTitle()
Title = IsDeleted ? $"{File.Name} ↔ {LeftLabel} (deleted)"
: RightLabel is { } right ? $"{File.Name} {LeftLabel} ↔ {right}"
: $"{File.Name} ↔ {LeftLabel}";
if (Border.View is BorderView { TitleView: ITitleView header }) header.MeasuredTabLength = 0;
SetNeedsLayout();
PaneTabs.ShowTitle(this);
}

/// <summary>The file's lines as the editor would load them.</summary>
Expand Down
6 changes: 1 addition & 5 deletions src/TuiCode.Editor/EditorTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -586,13 +586,9 @@
// The trailing space keeps the marker off the tab's right border.
var mark = DiskMark.For(_disk, IconStyle);
Title = $"{(_dirty ? "● " : "")}{File.Name}{(mark.Length > 0 ? $" {mark} " : "")}";
// TG redraws the tab header from Title only on layout, and positions headers from a cached width first.
PaneTabs.ShowTitle(this);
if (Border.View is BorderView { TitleView: { } view })
{
if (view is ITitleView header) header.MeasuredTabLength = 0;
ColourWhileMarked(view);
}
SetNeedsLayout();
}

// TG has no VisualRole for a warning and GetAttributeForRole isn't virtual in 2.1.0, so the marked
Expand All @@ -614,7 +610,7 @@
/// TextView that paints syntax colours (#21) and find-in-file match highlights (#33), raises
/// <see cref="TextView.ContentsChanged"/> only for edits that change the text, and keeps the content-width cache across edits.
/// </summary>
internal sealed partial class EditorTextView : TextView

Check warning on line 613 in src/TuiCode.Editor/EditorTab.cs

View workflow job for this annotation

GitHub Actions / AOT osx-arm64

'TextView' is obsolete: 'TextView is superseded by tui-cs/Editor's EditorView, which provides a rope-backed document model, cell-aware rendering, multi-caret editing, undo, syntax highlighting, folding, find/replace, and soft wrap. See https://github.com/tui-cs/Editor for details.'

Check warning on line 613 in src/TuiCode.Editor/EditorTab.cs

View workflow job for this annotation

GitHub Actions / AOT win-x64

'TextView' is obsolete: 'TextView is superseded by tui-cs/Editor's EditorView, which provides a rope-backed document model, cell-aware rendering, multi-caret editing, undo, syntax highlighting, folding, find/replace, and soft wrap. See https://github.com/tui-cs/Editor for details.'

Check warning on line 613 in src/TuiCode.Editor/EditorTab.cs

View workflow job for this annotation

GitHub Actions / AOT linux-arm64

'TextView' is obsolete: 'TextView is superseded by tui-cs/Editor's EditorView, which provides a rope-backed document model, cell-aware rendering, multi-caret editing, undo, syntax highlighting, folding, find/replace, and soft wrap. See https://github.com/tui-cs/Editor for details.'

Check warning on line 613 in src/TuiCode.Editor/EditorTab.cs

View workflow job for this annotation

GitHub Actions / AOT linux-x64

'TextView' is obsolete: 'TextView is superseded by tui-cs/Editor's EditorView, which provides a rope-backed document model, cell-aware rendering, multi-caret editing, undo, syntax highlighting, folding, find/replace, and soft wrap. See https://github.com/tui-cs/Editor for details.'

Check warning on line 613 in src/TuiCode.Editor/EditorTab.cs

View workflow job for this annotation

GitHub Actions / AOT win-arm64

'TextView' is obsolete: 'TextView is superseded by tui-cs/Editor's EditorView, which provides a rope-backed document model, cell-aware rendering, multi-caret editing, undo, syntax highlighting, folding, find/replace, and soft wrap. See https://github.com/tui-cs/Editor for details.'

Check warning on line 613 in src/TuiCode.Editor/EditorTab.cs

View workflow job for this annotation

GitHub Actions / build-test (ubuntu-latest)

'TextView' is obsolete: 'TextView is superseded by tui-cs/Editor's EditorView, which provides a rope-backed document model, cell-aware rendering, multi-caret editing, undo, syntax highlighting, folding, find/replace, and soft wrap. See https://github.com/tui-cs/Editor for details.'

Check warning on line 613 in src/TuiCode.Editor/EditorTab.cs

View workflow job for this annotation

GitHub Actions / build-test (windows-latest)

'TextView' is obsolete: 'TextView is superseded by tui-cs/Editor's EditorView, which provides a rope-backed document model, cell-aware rendering, multi-caret editing, undo, syntax highlighting, folding, find/replace, and soft wrap. See https://github.com/tui-cs/Editor for details.'

Check warning on line 613 in src/TuiCode.Editor/EditorTab.cs

View workflow job for this annotation

GitHub Actions / build-test (windows-latest)

'TextView' is obsolete: 'TextView is superseded by tui-cs/Editor's EditorView, which provides a rope-backed document model, cell-aware rendering, multi-caret editing, undo, syntax highlighting, folding, find/replace, and soft wrap. See https://github.com/tui-cs/Editor for details.'
{
private static readonly Command[] KillCommands =
[Command.CutToEndOfLine, Command.CutToStartOfLine, Command.KillWordLeft, Command.KillWordRight];
Expand Down
2 changes: 1 addition & 1 deletion src/TuiCode.Editor/EditorTextView.History.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public EditorTextView()
AddCommand(Command.Cut, () => CopyAtCarets(cut: true));
}

public override string Text
public new string Text
{
get => base.Text;
set
Expand Down
4 changes: 2 additions & 2 deletions src/TuiCode.Editor/TuiCode.Editor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Terminal.Gui" Version="2.1.0" />
<PackageReference Include="TestableIO.System.IO.Abstractions.Wrappers" Version="22.1.1" />
<PackageReference Include="Terminal.Gui" Version="2.5.0" />
<PackageReference Include="TestableIO.System.IO.Abstractions.Wrappers" Version="22.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/TuiCode.Explorer/TuiCode.Explorer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Terminal.Gui" Version="2.1.0" />
<PackageReference Include="TestableIO.System.IO.Abstractions.Wrappers" Version="22.1.1" />
<PackageReference Include="Terminal.Gui" Version="2.5.0" />
<PackageReference Include="TestableIO.System.IO.Abstractions.Wrappers" Version="22.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/TuiCode.Icons/TuiCode.Icons.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Terminal.Gui" Version="2.1.0" />
<PackageReference Include="Terminal.Gui" Version="2.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/TuiCode.Search/TuiCode.Search.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Terminal.Gui" Version="2.1.0" />
<PackageReference Include="TestableIO.System.IO.Abstractions.Wrappers" Version="22.1.1" />
<PackageReference Include="Terminal.Gui" Version="2.5.0" />
<PackageReference Include="TestableIO.System.IO.Abstractions.Wrappers" Version="22.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/TuiCode.Syntax/TuiCode.Syntax.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="TestableIO.System.IO.Abstractions.Wrappers" Version="22.1.1" />
<PackageReference Include="TestableIO.System.IO.Abstractions.Wrappers" Version="22.2.0" />
<PackageReference Include="TextMateSharp" Version="2.0.4" />
<!-- Links Oniguruma into the AOT binary instead of shipping libonigwrap beside it. -->
<PackageReference Include="StaticLink.libonigwrap" Version="1.0.11.3" />
Expand Down
16 changes: 7 additions & 9 deletions src/TuiCode.Workbench/Configuration/DefaultSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
namespace TuiCode.Workbench.Configuration;

/// <summary>
/// DI-friendly thin wrapper around TG's static <see cref="ConfigurationManager"/> /
/// DI-friendly thin wrapper around TG's static <see cref="TuiConfigurationBuilder"/> /
/// <see cref="ThemeManager"/>. Tests substitute an in-memory implementation; production
/// code never touches the static surface directly.
///
/// <para>Theme persists via TG's native <c>ThemeManager.Theme</c>
/// (<c>[ConfigurationProperty(Scope = typeof(SettingsScope))]</c>) written as
/// <para>Theme persists via TG's native <c>Theme</c> setting, written as
/// <c>{"Theme": "Daylight"}</c> at the JSON root of <c>~/.tui/TuiCode.config.json</c>.
/// <see cref="Load"/> calls <c>ConfigurationManager.Enable</c> which reads the file and
/// <see cref="Load"/> calls <c>TuiConfigurationBuilder.ApplyToStaticFacades</c>, which reads the file and
/// applies the theme — no custom load logic needed. Saving still goes through us because
/// <c>ConfigurationManager</c> exposes no Save API.</para>
/// TG exposes no Save API.</para>
///
/// <para>Keybindings persist to a sibling file <c>~/.tui/TuiCode.keybindings.json</c>
/// that we read and write directly — TG's source-generated <c>JsonTypeInfo</c> only
Expand Down Expand Up @@ -56,7 +55,6 @@ public string Theme
{
if (string.Equals(ThemeManager.Theme, value, StringComparison.Ordinal)) return;
ThemeManager.Theme = value;
ConfigurationManager.Apply();
ThemeChanged?.Invoke(this, EventArgs.Empty);
}
}
Expand All @@ -65,7 +63,7 @@ public string Theme

// TG's built-ins don't describe the editor's gutter or cursor, so we only offer our own.
public IReadOnlyCollection<string> AvailableThemes =>
BundledThemes.Names.Where(theme => ThemeManager.Themes?.ContainsKey(theme) ?? false).ToArray();
BundledThemes.Names.Where(ThemeManager.GetThemeNames().Contains).ToArray();

public IReadOnlyList<KeybindingOverride> KeybindingOverrides => _keybindings;

Expand All @@ -91,8 +89,8 @@ public void SetGrammarAssociations(IReadOnlyDictionary<string, string> associati

public void Load()
{
ConfigurationManager.RuntimeConfig = BundledThemes.Config;
ConfigurationManager.Enable(ConfigLocations.All);
TuiConfigurationBuilder.Shared.RuntimeConfig = BundledThemes.Config;
TuiConfigurationBuilder.Shared.ApplyToStaticFacades();
Theme = BundledThemes.Migrate(ThemeManager.Theme);
}

Expand Down
Loading
Loading