Can the Terminal PLEASE be someone else's fucking issue now?

This commit is contained in:
Michael 2017-07-19 19:24:28 -04:00
parent b8eb7dccfd
commit d3ce724d28
2 changed files with 27 additions and 12 deletions

View file

@ -161,6 +161,8 @@ namespace ShiftOS.Frontend.Apps
{
int vertMeasure = 2;
int horizMeasure = 2;
if (string.IsNullOrEmpty(Text))
return new System.Drawing.Point(horizMeasure, vertMeasure);
int lineindex = 0;
int line = GetCurrentLine();
for (int l = 0; l < line; l++)
@ -245,13 +247,22 @@ namespace ShiftOS.Frontend.Apps
{
try
{
var tostring3 = Lines[Lines.Length - 1];
var tostringlen = tostring3.Length + 1;
var workaround = $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ";
var derp = workaround.Length + 1;
if (tostringlen != derp)
if (PerformTerminalBehaviours)
{
var tostring3 = Lines[Lines.Length - 1];
var tostringlen = tostring3.Length + 1;
var workaround = $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ";
var derp = workaround.Length + 1;
if (tostringlen != derp)
{
AppearanceManager.CurrentPosition--;
base.OnKeyEvent(a);
RecalculateLayout();
InvalidateTopLevel();
}
}
else
{
AppearanceManager.CurrentPosition--;
base.OnKeyEvent(a);
RecalculateLayout();
InvalidateTopLevel();
@ -283,7 +294,8 @@ namespace ShiftOS.Frontend.Apps
var selstart = Index;
var remstrlen = Text.Length - stringlen;
var finalnum = selstart - remstrlen;
if (!PerformTerminalBehaviours)
headerlen = 0;
if (finalnum > headerlen)
{
AppearanceManager.CurrentPosition--;
@ -291,7 +303,7 @@ namespace ShiftOS.Frontend.Apps
}
}
}
else if (a.Key == Keys.Up)
else if (a.Key == Keys.Up && PerformTerminalBehaviours)
{
var tostring3 = Lines[Lines.Length - 1];
if (tostring3 == $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ")
@ -319,6 +331,8 @@ namespace ShiftOS.Frontend.Apps
blinkTime = 250;
}
public bool PerformTerminalBehaviours = true;
protected override void OnPaint(GraphicsContext gfx)
{
gfx.Clear(LoadedSkin.TerminalBackColorCC.ToColor().ToMonoColor());
@ -333,7 +347,7 @@ namespace ShiftOS.Frontend.Apps
cursorPos = GetPointAtIndex(cgfx);
}
var cursorSize = gfx.MeasureString(Text[Index - 1].ToString(), LoadedSkin.TerminalFont);
var cursorSize = gfx.MeasureString("#", LoadedSkin.TerminalFont);
var lineMeasure = gfx.MeasureString(Lines[GetCurrentLine()], LoadedSkin.TerminalFont);
if (cursorPos.X > lineMeasure.X)
@ -399,8 +413,6 @@ namespace ShiftOS.Frontend.Apps
{
public static SizeF SmartMeasureString(this Graphics gfx, string s, Font font, int width)
{
if (string.IsNullOrEmpty(s))
s = " ";
var textformat = new StringFormat(StringFormat.GenericTypographic);
textformat.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;
//textformat.Trimming = StringTrimming.Character;
@ -408,6 +420,8 @@ namespace ShiftOS.Frontend.Apps
gfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
var measure = gfx.MeasureString(s, font, width, textformat);
if (string.IsNullOrEmpty(s))
measure.Width = 0;
return new SizeF((float)Math.Ceiling(measure.Width), (float)Math.Ceiling(measure.Height));
}

View file

@ -19,6 +19,7 @@ namespace ShiftOS.Frontend.Apps
{
contentsLabel = new TerminalControl();
contentsLabel.Dock = GUI.DockStyle.Fill;
contentsLabel.PerformTerminalBehaviours = false;
AddControl(contentsLabel);
}
@ -42,7 +43,7 @@ namespace ShiftOS.Frontend.Apps
public void OpenFile(string file)
{
//contentsLabel.Text = Objects.ShiftFS.Utils.ReadAllText(file);
contentsLabel.Text = Objects.ShiftFS.Utils.ReadAllText(file);
AppearanceManager.SetupWindow(this);
}
}