Debugger: Make shift+home/end select rows in disassembly/source view and trace logger

This commit is contained in:
Sour 2025-03-23 15:36:51 +09:00
parent 004ec5f3db
commit c4472f3a4d
6 changed files with 47 additions and 29 deletions

View file

@ -149,14 +149,15 @@ namespace Mesen.Debugger.Utilities
private void Viewer_KeyDown(object? sender, KeyEventArgs e)
{
bool shift = e.KeyModifiers.HasFlag(KeyModifiers.Shift);
switch(e.Key) {
case Key.PageDown: _model.MoveCursor(_model.VisibleRowCount - 2, e.KeyModifiers.HasFlag(KeyModifiers.Shift)); e.Handled = true; break;
case Key.PageUp: _model.MoveCursor(-(_model.VisibleRowCount - 2), e.KeyModifiers.HasFlag(KeyModifiers.Shift)); e.Handled = true; break;
case Key.Home: _model.ScrollToTop(); e.Handled = true; break;
case Key.End: _model.ScrollToBottom(); e.Handled = true; break;
case Key.PageDown: _model.MoveCursor(_model.VisibleRowCount - 2, shift); e.Handled = true; break;
case Key.PageUp: _model.MoveCursor(-(_model.VisibleRowCount - 2), shift); e.Handled = true; break;
case Key.Home: _model.ScrollToTop(shift); e.Handled = true; break;
case Key.End: _model.ScrollToBottom(shift); e.Handled = true; break;
case Key.Up: _model.MoveCursor(-1, e.KeyModifiers.HasFlag(KeyModifiers.Shift)); e.Handled = true; break;
case Key.Down: _model.MoveCursor(1, e.KeyModifiers.HasFlag(KeyModifiers.Shift)); e.Handled = true; break;
case Key.Up: _model.MoveCursor(-1, shift); e.Handled = true; break;
case Key.Down: _model.MoveCursor(1, shift); e.Handled = true; break;
}
}

View file

@ -7,7 +7,6 @@ using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Tmds.DBus;
namespace Mesen.Debugger.Utilities
{

View file

@ -6,8 +6,8 @@ namespace Mesen.Debugger.Utilities
{
void ResizeSelectionTo(int rowNumber);
void MoveCursor(int rowOffset, bool extendSelection);
void ScrollToTop();
void ScrollToBottom();
void ScrollToTop(bool extendSelection);
void ScrollToBottom(bool extendSelection);
void SetSelectedRow(int rowNumber);
bool IsSelected(int rowNumber);
void Scroll(int offset);

View file

@ -1,7 +1,6 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Threading;
using Dock.Model.Core;
using Mesen.Config;
using Mesen.Debugger.Controls;
using Mesen.Debugger.Disassembly;
@ -15,7 +14,6 @@ using ReactiveUI.Fody.Helpers;
using System;
using System.Linq;
using System.Text;
using Tmds.DBus.Protocol;
namespace Mesen.Debugger.ViewModels
{
@ -127,17 +125,25 @@ namespace Mesen.Debugger.ViewModels
SetTopAddress(DataProvider.GetRowAddress(TopAddress, lineNumberOffset));
}
public void ScrollToTop()
public void ScrollToTop(bool extendSelection)
{
SetSelectedRow(0, false, true);
ScrollToAddress(0, ScrollDisplayPosition.Top);
if(extendSelection) {
ResizeSelectionTo(0);
} else {
SetSelectedRow(0, false, true);
ScrollToAddress(0, ScrollDisplayPosition.Top);
}
}
public void ScrollToBottom()
public void ScrollToBottom(bool extendSelection)
{
int address = DataProvider.GetLineCount() - 1;
SetSelectedRow(address, false, true);
ScrollToAddress((uint)address, ScrollDisplayPosition.Bottom);
if(extendSelection) {
ResizeSelectionTo(DataProvider.GetLineCount() - 1);
} else {
int address = DataProvider.GetLineCount() - 1;
SetSelectedRow(address, false, true);
ScrollToAddress((uint)address, ScrollDisplayPosition.Bottom);
}
}
public void InvalidateVisual()

View file

@ -342,16 +342,20 @@ public class SourceViewViewModel : DisposableViewModel, ISelectableModel
ScrollToLocation(History.GoForward(), false);
}
public void ScrollToTop()
public void ScrollToTop(bool extendSelection)
{
if(SelectedFile != null) {
if(extendSelection) {
ResizeSelectionTo(0);
} else if(SelectedFile != null) {
ScrollToLocation(new SourceCodeLocation(SelectedFile, 0), true);
}
}
public void ScrollToBottom()
public void ScrollToBottom(bool extendSelection)
{
if(SelectedFile != null) {
if(extendSelection) {
ResizeSelectionTo(MaxScrollPosition);
} else if(SelectedFile != null) {
ScrollToLocation(new SourceCodeLocation(SelectedFile, SelectedFile.Data.Length - 1), true);
}
}

View file

@ -277,7 +277,7 @@ namespace Mesen.Debugger.ViewModels
TraceLogLines = lines;
if(scrollToBottom) {
ScrollToBottom();
ScrollToBottom(false);
}
});
}
@ -346,16 +346,24 @@ namespace Mesen.Debugger.ViewModels
ScrollPosition += offset;
}
public void ScrollToTop()
public void ScrollToTop(bool extendSelection)
{
ScrollPosition = 0;
SetSelectedRow(0);
if(extendSelection) {
ResizeSelectionTo(-ScrollPosition);
} else {
ScrollPosition = 0;
SetSelectedRow(0);
}
}
public void ScrollToBottom()
public void ScrollToBottom(bool extendSelection)
{
ScrollPosition = MaxScrollPosition;
SetSelectedRow(DebugApi.TraceLogBufferSize - 1);
if(extendSelection) {
ResizeSelectionTo(DebugApi.TraceLogBufferSize - 1 - ScrollPosition);
} else {
ScrollPosition = MaxScrollPosition;
SetSelectedRow(DebugApi.TraceLogBufferSize - 1);
}
}
public void SelectAll()