Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
qluana7 committed Jun 7, 2021
1 parent 9bd390d commit d22a6e0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 26 deletions.
18 changes: 18 additions & 0 deletions CSAnalyzer-Preview/Windows/Editor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ private void EventHandling()
IsEdited = true;
};

TextEditor.TextArea.Caret.PositionChanged += TextEditor_PositionChanged;

AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
}

Expand Down Expand Up @@ -249,6 +251,13 @@ private void TextArea_TextEntering(object sender, TextCompositionEventArgs e)
completionWindow.CompletionList.RequestInsertion(e);
}

private void TextEditor_PositionChanged(object sender, EventArgs e)
{
var offset = TextEditor.TextArea.Caret.Position;
LineTextBlock.Text = "Ln: " + offset.Line;
ColumnTextBlock.Text = "Co: " + offset.Column;
}

public void ChangeStatus(Status sta, string str = null)
{
StatusImage.Source = (BitmapImage)Resources["Status_" + sta.ToString()];
Expand Down Expand Up @@ -441,6 +450,15 @@ private void ChangeIsEnabled(bool b)

for (int i = 0; i < controls.Length; i++)
controls[i].IsEnabled = b;

FrameworkElement[] vcontrols =
{
LineTextBlock,
ColumnTextBlock
};

for (int j = 0; j < vcontrols.Length; j++)
vcontrols[j].Visibility = b ? Visibility.Visible : Visibility.Hidden;
}

private void RecordRecent(string path)
Expand Down
44 changes: 18 additions & 26 deletions CSAnalyzer/Windows/Editor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ private void Init()
IsEdited = true;
};

TextEditor.TextArea.Caret.PositionChanged += TextEditor_PositionChanged;

CurrentFile = null;
IsEdited = false;
ToolUndoButton.IsEnabled = false;
Expand Down Expand Up @@ -132,6 +134,13 @@ private async void Window_Loaded(object sender, RoutedEventArgs e)
ChangeStatus(Status.Ready);
}

private void TextEditor_PositionChanged(object sender, EventArgs e)
{
var offset = TextEditor.TextArea.Caret.Position;
LineTextBlock.Text = "Ln: " + offset.Line;
ColumnTextBlock.Text = "Co: " + offset.Column;
}

public void ChangeStatus(Status sta, string str = null)
{
StatusImage.Source = (BitmapImage)Resources["Status_" + sta.ToString()];
Expand Down Expand Up @@ -276,32 +285,6 @@ private void TextEditor_PreviewTextInput(object sender, TextCompositionEventArgs
TextEditor.CaretOffset = co + s.Item2 + 1;
}

private void SelectWord()
{
int cursorPosition = TextEditor.SelectionStart;
int nextSpace = TextEditor.Text.IndexOf(' ', cursorPosition);
int selectionStart = 0;
string trimmedString;
if (nextSpace != -1)
{
trimmedString = TextEditor.Text.Substring(0, nextSpace);
}
else
{
trimmedString = TextEditor.Text;
}


if (trimmedString.LastIndexOf(' ') != -1)
{
selectionStart = 1 + trimmedString.LastIndexOf(' ');
trimmedString = trimmedString.Substring(1 + trimmedString.LastIndexOf(' '));
}

TextEditor.SelectionStart = selectionStart;
TextEditor.SelectionLength = trimmedString.Length;
}

#region MenuStrip
private async Task<bool> CheckSave()
{
Expand Down Expand Up @@ -344,6 +327,15 @@ private void ChangeIsEnabled(bool b)

for (int i = 0; i < controls.Length; i++)
controls[i].IsEnabled = b;

FrameworkElement[] vcontrols =
{
LineTextBlock,
ColumnTextBlock
};

for (int j = 0; j < vcontrols.Length; j++)
vcontrols[j].Visibility = b ? Visibility.Visible : Visibility.Hidden;
}

private void RecordRecent(string path)
Expand Down

0 comments on commit d22a6e0

Please sign in to comment.