|
1 | 1 | using XTerm; |
| 2 | +using XTerm.Buffer; |
2 | 3 | using XTerm.Options; |
3 | 4 |
|
4 | 5 | namespace XTerm.Tests; |
@@ -891,4 +892,89 @@ public void GetLine_WithScrollback_ReturnsCorrectContent() |
891 | 892 | } |
892 | 893 |
|
893 | 894 | #endregion |
| 895 | + |
| 896 | + [Fact] |
| 897 | + public void Reset_ClearsLineAttributes() |
| 898 | + { |
| 899 | + // Arrange |
| 900 | + var terminal = new Terminal(); |
| 901 | + |
| 902 | + // Set some lines to double-height mode using ESC # 3 (top) and ESC # 4 (bottom) |
| 903 | + terminal.Write("Line 0\n"); |
| 904 | + terminal.Write("\x1B#3"); // ESC # 3 - Double-height top |
| 905 | + terminal.Write("Line 1 Top\n"); |
| 906 | + terminal.Write("\x1B#4"); // ESC # 4 - Double-height bottom |
| 907 | + terminal.Write("Line 2 Bottom\n"); |
| 908 | + terminal.Write("\x1B#6"); // ESC # 6 - Double-width |
| 909 | + terminal.Write("Line 3 Wide\n"); |
| 910 | + |
| 911 | + // Verify line attributes are set |
| 912 | + Assert.Equal(LineAttribute.DoubleHeightTop, terminal.Buffer.Lines[1]?.LineAttribute); |
| 913 | + Assert.Equal(LineAttribute.DoubleHeightBottom, terminal.Buffer.Lines[2]?.LineAttribute); |
| 914 | + Assert.Equal(LineAttribute.DoubleWidth, terminal.Buffer.Lines[3]?.LineAttribute); |
| 915 | + |
| 916 | + // Act - Reset the terminal (simulates 'reset' command which sends ESC c / RIS) |
| 917 | + terminal.Reset(); |
| 918 | + |
| 919 | + // Assert - All line attributes should be reset to Normal |
| 920 | + for (int i = 0; i < terminal.Rows; i++) |
| 921 | + { |
| 922 | + var line = terminal.Buffer.Lines[i]; |
| 923 | + if (line != null) |
| 924 | + { |
| 925 | + Assert.Equal(LineAttribute.Normal, line.LineAttribute); |
| 926 | + } |
| 927 | + } |
| 928 | + } |
| 929 | + |
| 930 | + [Fact] |
| 931 | + public void Reset_ClearsLineAttributesInScrollback() |
| 932 | + { |
| 933 | + // Arrange |
| 934 | + var terminal = new Terminal(new TerminalOptions { Rows = 5, Cols = 80, Scrollback = 100 }); |
| 935 | + |
| 936 | + // Write lines with double-height attributes |
| 937 | + for (int i = 0; i < 10; i++) |
| 938 | + { |
| 939 | + if (i % 2 == 0) |
| 940 | + { |
| 941 | + terminal.Write("\x1B#3"); // ESC # 3 - Double-height top |
| 942 | + } |
| 943 | + else |
| 944 | + { |
| 945 | + terminal.Write("\x1B#6"); // ESC # 6 - Double-width |
| 946 | + } |
| 947 | + terminal.Write($"Line {i}\n"); |
| 948 | + } |
| 949 | + |
| 950 | + // Verify some line attributes are set (check a few lines in scrollback) |
| 951 | + bool foundDoubleHeight = false; |
| 952 | + bool foundDoubleWidth = false; |
| 953 | + for (int i = 0; i < terminal.Buffer.Lines.Length; i++) |
| 954 | + { |
| 955 | + var line = terminal.Buffer.Lines[i]; |
| 956 | + if (line != null) |
| 957 | + { |
| 958 | + if (line.LineAttribute == LineAttribute.DoubleHeightTop) |
| 959 | + foundDoubleHeight = true; |
| 960 | + if (line.LineAttribute == LineAttribute.DoubleWidth) |
| 961 | + foundDoubleWidth = true; |
| 962 | + } |
| 963 | + } |
| 964 | + Assert.True(foundDoubleHeight || foundDoubleWidth, "Expected to find at least one line with non-normal attribute"); |
| 965 | + |
| 966 | + // Act - Reset the terminal (simulates 'reset' command which sends ESC c / RIS) |
| 967 | + terminal.Reset(); |
| 968 | + |
| 969 | + // Assert - All lines in the buffer (including scrollback) should have Normal line attributes |
| 970 | + for (int i = 0; i < terminal.Buffer.Lines.Length; i++) |
| 971 | + { |
| 972 | + var line = terminal.Buffer.Lines[i]; |
| 973 | + if (line != null) |
| 974 | + { |
| 975 | + Assert.Equal(LineAttribute.Normal, line.LineAttribute); |
| 976 | + } |
| 977 | + } |
| 978 | + } |
894 | 979 | } |
| 980 | + |
0 commit comments