Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
add jumptoline for IEditor.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikMennen committed Mar 23, 2024
1 parent 20fcbbd commit a3a1fdb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/OneWare.Essentials/Helpers/PlatformHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
Expand Down Expand Up @@ -305,5 +307,15 @@ public static void ActivateWindow(IntPtr mainWindowHandle, IntPtr displayHandle)
: KeyModifiers.Control;

#endregion

private static readonly IPEndPoint DefaultLoopbackEndpoint = new(IPAddress.Loopback, 0);

public static int GetAvailablePort()
{
using var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.Bind(DefaultLoopbackEndpoint);

return (socket.LocalEndPoint as IPEndPoint)?.Port ?? throw new Exception("Error getting free port!");
}
}
}
5 changes: 5 additions & 0 deletions src/OneWare.Essentials/ViewModels/IEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ namespace OneWare.Essentials.ViewModels;
public interface IEditor : IExtendedDocument
{
public ExtendedTextEditor Editor { get; }

public TextDocument CurrentDocument { get; }

public void Select(int offset, int length);

public void JumpToLine(int lineNumber, bool select = true);

public event EventHandler? FileSaved;
}

0 comments on commit a3a1fdb

Please sign in to comment.