Browse Source

First commit

Miguel de Icaza 7 years ago
commit
28afe26ba2
4 changed files with 113 additions and 0 deletions
  1. 2 0
      .gitignore
  2. 51 0
      Application.cs
  3. 44 0
      Terminal.csproj
  4. 16 0
      driver.cs

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+bin
+obj

+ 51 - 0
Application.cs

@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+
+namespace Terminal {
+    public struct Rect {
+        public int X, Y, Width, Height;
+
+        public Rect (int x, int y, int width, int height)
+        {
+            X = x;
+            Y = y;
+            Width = width;
+            Height = height;
+        }
+
+        public override string ToString() => $"[{X},{Y}:{Width},{Height}]";
+    }
+
+    public class View {
+        public static ConsoleDriver Driver = Application.Driver;
+        View [] subviews;
+        public View [] Subviews => subviews == null ? Array.Empty<View> () : subviews;
+
+        Rect frame;
+
+        public View (Rect frame)
+        {
+            this.frame = frame;
+        }
+    }
+
+    public class Window : View {
+        public Window (Rect frame) : base (frame)
+        {
+        }
+
+        public static Window Toplevel () 
+        {
+            return new Window (new Rect (0, 0, Driver.Cols, Driver.Rows));
+        }
+    }
+
+    public class Application {
+        public static ConsoleDriver Driver = new CursesDriver ();
+
+        public void Init ()
+        {
+
+        }
+    }
+}

+ 44 - 0
Terminal.csproj

@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <ProjectGuid>{B0A602CD-E176-449D-8663-64238D54F857}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <RootNamespace>Terminal</RootNamespace>
+    <AssemblyName>Terminal</AssemblyName>
+    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug</OutputPath>
+    <DefineConstants>DEBUG;</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ExternalConsole>true</ExternalConsole>
+    <PlatformTarget>x86</PlatformTarget>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ExternalConsole>true</ExternalConsole>
+    <PlatformTarget>x86</PlatformTarget>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Application.cs" />
+    <Compile Include="driver.cs" />
+  </ItemGroup>
+  <ItemGroup>
+   <Reference Include="mono-curses.dll">
+     <HintPath>../mono-curses/mono-curses.dll</HintPath>
+   </Reference>
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+</Project>

+ 16 - 0
driver.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using Mono.Terminal;
+
+namespace Terminal {
+
+    public abstract class ConsoleDriver {
+        public virtual int Cols {get;}
+        public virtual int Rows {get;}
+    }
+
+    public class CursesDriver : ConsoleDriver {
+        public override int Cols => Curses.Cols;
+        public override int Rows => Curses.Lines;
+    }
+}