Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various backports from VSMac #89

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
d86aa7c
Fixes a crash when reflowing narrower and content needs to be pushed out
sgmunn Apr 17, 2020
42895e4
Merge pull request #71 from xamarin/buffer-reflow-crash
migueldeicaza Apr 17, 2020
b602c14
Backport of DL fixes
sgmunn Apr 17, 2020
8a71f45
Add DL unit tests
sgmunn Apr 18, 2020
3afe798
Move InternalsVisibleTo definition to fix build issues on CI
sgmunn Apr 18, 2020
259b57b
Fix build errors
sgmunn Apr 18, 2020
9d76fe8
Move to package reference to fix build errors on CI
sgmunn Apr 18, 2020
0e2fd2f
Bump tests targetframework for CI
sgmunn Apr 18, 2020
af2a292
Add yaml to build and test
sgmunn Apr 18, 2020
6dfe1f5
Merge pull request #72 from xamarin/delete-line-fixes
migueldeicaza Apr 20, 2020
04ab7d6
Merge pull request #73 from sgmunn/ci-building
migueldeicaza Apr 20, 2020
d023043
Use 10.14 instead of 10.13
migueldeicaza Apr 20, 2020
397264e
Attempt to install .NET Core 3.1
migueldeicaza Apr 20, 2020
5d8ecbe
Update azure-pipelines.yml for Azure Pipelines
migueldeicaza Apr 20, 2020
e16ecac
Add Github CI badge
sgmunn Apr 28, 2020
6773620
Update README.md
sgmunn Apr 28, 2020
2525091
Fixes a crash when selecting word or expression
sgmunn Apr 29, 2020
16efd01
Merge pull request #74 from sgmunn/build-badge
migueldeicaza Apr 29, 2020
0c61b01
Merge pull request #75 from xamarin/fix-selection-crash
migueldeicaza Apr 29, 2020
635cffc
Cols are user visible based, not zero based
sgmunn Apr 29, 2020
34de1ba
Merge pull request #76 from xamarin/sgmunn-patch-1
migueldeicaza Apr 29, 2020
cab6dec
Fix IndexOutOfRangeException processing input
mrward May 18, 2020
aebdb7a
Merge pull request #80 from xamarin/dev/mrward/fix-index-out-of-range…
migueldeicaza May 20, 2020
4fcc03f
Use custom Point struct to remove System.Drawing
nosami May 24, 2021
bd987e1
Merge pull request #2 from xamarin/dev/nosami/remove-system-drawing
nosami May 24, 2021
7d159ef
Build libtpy as a fat library
slluis Sep 6, 2021
ef12b1d
Merge pull request #3 from xamarin/dev/lluis/libpty-as-fat-lib
sandyarmstrong Dec 16, 2021
c2825d6
Convert test project to net6
sgmunn Oct 7, 2021
93019c5
Fix
sgmunn Jan 12, 2022
861e649
arm
sgmunn Jan 12, 2022
83186d0
Fix passing arg and env arguments to the native helper in .NET6
sgmunn Jan 12, 2022
f1aebb4
If execve fails, call _exit()
sgmunn Jan 12, 2022
8e15e71
Fix make all target
sgmunn Jan 14, 2022
74409cc
Clean up marshaling of winsize
sgmunn Jan 14, 2022
08eea4a
Return pid of shell process
nosami Jan 27, 2022
7cc33ed
throw if we don't have a PID
nosami Jan 27, 2022
e4a3e8b
Set SetLastError=true on HeavyFork
nosami Jan 27, 2022
97075ec
Merge pull request #4 from xamarin/dev/nosami/fix-1464804
nosami Feb 14, 2022
5b49dec
Missed an IntPtr->NativeHandle
sandyarmstrong Mar 3, 2022
905c0b4
Merge pull request #5 from xamarin/dev/sandy/pointy
nosami Mar 3, 2022
d297f5d
Fix wide character support
nosami Apr 6, 2022
bda1911
Merge pull request #6 from xamarin/dev/nosami/fix-1501927
sandyarmstrong May 12, 2022
ef9803b
Update for macos workload RC3 API changes
sandyarmstrong May 12, 2022
fe59fad
Merge pull request #7 from xamarin/dev/sandy/macos-rc3
sandyarmstrong Jun 13, 2022
17dfff5
Add null checking to SelectionService
nosami Sep 15, 2022
c38abfb
Merge pull request #8 from xamarin/dev/nosami/add-null-checks
nosami Sep 21, 2022
7feb668
Set minimum OS version for the dylib
Therzok Sep 21, 2022
ed9d770
Set spacing characters in East Asian Ambiguous (A)
nosami Nov 8, 2022
b836593
Merge pull request #9 from xamarin/dev/nosami/fix-1646486
nosami Nov 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: macos-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Build helper
- name: Build ptylib
run: |
cd helper
cc -shared pty.c -shared -o libpty.dylib

# Restore packages
- name: Restore
run: msbuild /t:restore

# Build
- name: Build
run: msbuild /t:build

# Test
- name: Test
run: dotnet test Tests/Tests.csproj
13 changes: 3 additions & 10 deletions GuiCsHost/GuiCsHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,10 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="NStack">
<HintPath>..\packages\NStack.Core.0.12.0\lib\netstandard1.5\NStack.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="Terminal.Gui">
<HintPath>..\packages\Terminal.Gui.0.19.0\lib\net461\Terminal.Gui.dll</HintPath>
</Reference>
<Reference Include="Mono.Posix" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="NStack.Core" Version="0.12.0" />
<PackageReference Include="Terminal.Gui" Version="0.19.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
Expand Down
13 changes: 9 additions & 4 deletions GuiCsHost/TerminalView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public override void Redraw (Rect region)

public override bool MouseEvent (MouseEvent mouseEvent)
{
if (terminal.MouseEvents) {
if (terminal.MouseMode.SendMotionEvent()) {
var f = mouseEvent.Flags;
int button = -1;
if (f.HasFlag (MouseFlags.Button1Clicked))
Expand All @@ -274,10 +274,10 @@ public override bool MouseEvent (MouseEvent mouseEvent)
button = 2;

if (button != -1){
var e = terminal.EncodeButton (button, release: false, shift: false, meta: false, control: false);
var e = terminal.EncodeMouseButton (button, release: false, shift: false, meta: false, control: false);
terminal.SendEvent (e, mouseEvent.X, mouseEvent.Y);
if (terminal.MouseSendsRelease) {
e = terminal.EncodeButton (button, release: true, shift: false, meta: false, control: false);
if (terminal.MouseMode.SendButtonRelease()) {
e = terminal.EncodeMouseButton (button, release: true, shift: false, meta: false, control: false);
terminal.SendEvent (e, mouseEvent.X, mouseEvent.Y);
}
return true;
Expand Down Expand Up @@ -325,6 +325,11 @@ public string WindowCommand (XtermSharp.Terminal source, WindowManipulationComma
return null;
}

bool ITerminalDelegate.IsProcessTrusted ()
{
return true;
}

public override void PositionCursor ()
{
Move (terminal.Buffer.X, terminal.Buffer.Y);
Expand Down
2 changes: 1 addition & 1 deletion MacTerminal/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>10.12</string>
<string>10.14</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand Down
100 changes: 15 additions & 85 deletions MacTerminal/MacTerminal.csproj
Original file line number Diff line number Diff line change
@@ -1,91 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1F7FAA67-E10C-4C71-8DA9-91A2A08E5F46}</ProjectGuid>
<ProjectTypeGuids>{A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFramework>net6.0-macos</TargetFramework>
<OutputType>Exe</OutputType>
<RootNamespace>MacTerminal</RootNamespace>
<AssemblyName>MacTerminal</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<TargetFrameworkIdentifier>Xamarin.Mac</TargetFrameworkIdentifier>
<MonoMacResourcePrefix>Resources</MonoMacResourcePrefix>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<EnableCodeSigning>false</EnableCodeSigning>
<CodeSigningKey>Mac Developer</CodeSigningKey>
<CreatePackage>false</CreatePackage>
<EnablePackageSigning>false</EnablePackageSigning>
<IncludeMonoRuntime>false</IncludeMonoRuntime>
<UseSGen>true</UseSGen>
<UseRefCounting>true</UseRefCounting>
<Profiling>true</Profiling>
<HttpClientHandler></HttpClientHandler>
<LinkMode></LinkMode>
<XamMacArch></XamMacArch>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<DefineConstants></DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<EnableCodeSigning>false</EnableCodeSigning>
<CreatePackage>true</CreatePackage>
<EnablePackageSigning>false</EnablePackageSigning>
<IncludeMonoRuntime>true</IncludeMonoRuntime>
<UseSGen>true</UseSGen>
<UseRefCounting>true</UseRefCounting>
<RuntimeIdentifier>osx-arm64</RuntimeIdentifier>
<UseMonoRuntime>false</UseMonoRuntime>
<LinkMode>SdkOnly</LinkMode>
<HttpClientHandler></HttpClientHandler>
<XamMacArch></XamMacArch>

<SupportedOSPlatformVersion>10.14</SupportedOSPlatformVersion>
<MonoMacResourcePrefix>Resources</MonoMacResourcePrefix>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<RootNamespace>MacTerminal</RootNamespace>
</PropertyGroup>

<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Xamarin.Mac" />
<PackageReference Include="NStack.Core" Version="0.12.0" />
</ItemGroup>
<ItemGroup>
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Contents.json" />
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-128.png" />
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-128%402x.png" />
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-16.png" />
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-16%402x.png" />
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-256.png" />
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-256%402x.png" />
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-32.png" />
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-32%402x.png" />
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-512.png" />
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-512%402x.png" />
<ImageAsset Include="Assets.xcassets\Contents.json" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
<None Include="Entitlements.plist" />
</ItemGroup>
<ItemGroup>
<Compile Include="AppDelegate.cs" />
<Compile Include="ViewController.cs" />
<Compile Include="ViewController.designer.cs">
<DependentUpon>ViewController.cs</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="Main.storyboard" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\XtermSharp\XtermSharp.csproj">
<Project>{218EB800-B5D6-46C3-8113-8DB312AE0C64}</Project>
Expand All @@ -96,8 +26,8 @@
<Name>XtermSharp.Mac</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Mac\Xamarin.Mac.CSharp.targets" />
<Target Name="AfterBuild">
<Copy SourceFiles="..\helper\libpty.dylib" DestinationFolder="$(OutputPath)\MacTerminal.app\Contents\MonoBundle" />

<Target Name="AfterBuild" AfterTargets="_CopyResolvedFilesToPublishAlways">
<Copy SourceFiles="..\helper\libpty.dylib" DestinationFolder="$(OutputPath)MacTerminal.app\Contents\MonoBundle" />
</Target>
</Project>
</Project>
3 changes: 2 additions & 1 deletion MacTerminal/ViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
using System;
using AppKit;
using Foundation;
using ObjCRuntime;
using XtermSharp.Mac;

namespace MacTerminal {
public partial class ViewController : NSViewController {
ProcessTerminalView terminalControl;
LocalProcess process;

public ViewController (IntPtr handle) : base (handle)
public ViewController (NativeHandle handle) : base (handle)
{
}

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
XtermSharp
----------

![Build Status](https://github.com/migueldeicaza/XtermSharp/workflows/CI/badge.svg)
[![Build Status](https://migueldeicaza.visualstudio.com/XtermSharp/_apis/build/status/XtermSharp-Mac-CI?branchName=master)](https://migueldeicaza.visualstudio.com/XtermSharp/_build/latest?definitionId=9&branchName=master)

<img width="45%" alt="XtermSharpGui" src="https://user-images.githubusercontent.com/36863/54497310-80eda980-48cf-11e9-84c2-14ddc054a4b6.png"><img width="45%" alt="XtermSharpMac" src="https://user-images.githubusercontent.com/36863/54497311-80eda980-48cf-11e9-9695-d7425e43262d.png">
Expand Down
4 changes: 1 addition & 3 deletions SimpleTester/SimpleTester.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="NStack">
<HintPath>..\packages\NStack.Core.0.11.0\lib\netstandard1.5\NStack.dll</HintPath>
</Reference>
<PackageReference Include="NStack.Core" Version="0.12.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
Expand Down
25 changes: 25 additions & 0 deletions Tests/BufferTests/ReflowNarrowerTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using XtermSharp;
using Xunit;

namespace XtermSharp.Tests.BufferTests {

public class ReflowNarrowerTests {
[Fact]
public void DoesNotCrashWhenReflowingToTinyWidth ()
{
var options = new TerminalOptions () { Cols = 10, Rows = 10 };
options.Scrollback = 1;
var terminal = new Terminal (null, options);

terminal.Feed ("1234567890\r\n");
terminal.Feed ("ABCDEFGH\r\n");
terminal.Feed ("abcdefghijklmnopqrstxxx\r\n");
terminal.Feed ("\r\n");

// if we resize to a small column width, content is pushed back up and out the top
// of the buffer. Ensure that this does not crash
terminal.Resize (3, 10);
}
}
}
32 changes: 32 additions & 0 deletions Tests/BufferTests/SelectionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Xunit;

namespace XtermSharp.Tests.BufferTests {
public class SelectionTests {
[Fact]
public void DoesNotCrashWhenSelectingWordOrExpressionOutsideColumnRange ()
{
var terminal = new Terminal (null, new TerminalOptions { Rows = 10, Cols = 10 });
var selection = new SelectionService (terminal);

terminal.Feed ("1234567890");

// depending on the size of terminal view, there might be a space near the margin where the user
// clicks which might result in a col or row outside the bounds of terminal,
selection.SelectWordOrExpression (-1, 0);
selection.SelectWordOrExpression (11, 0);
}

[Fact]
public void DoesNotCrashWhenSelectingWordOrExpressionOutsideRowRange ()
{
var terminal = new Terminal (null, new TerminalOptions { Rows = 10, Cols = 10, Scrollback = 0 });
var selection = new SelectionService (terminal);

terminal.Feed ("1234567890");

// depending on the size of terminal view, there might be a space near the margin where the user
// clicks which might result in a col or row outside the bounds of terminal,
selection.SelectWordOrExpression (0, -1);
}
}
}
Loading