Skip to content

Commit

Permalink
YA
Browse files Browse the repository at this point in the history
  • Loading branch information
GoombaProgrammer committed Jul 29, 2023
1 parent 50b4e89 commit 0984e41
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 21 deletions.
43 changes: 24 additions & 19 deletions Eaucool.csproj
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<Optimize>False</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<Optimize>False</Optimize>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Optimize>False</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Optimize>False</Optimize>
</PropertyGroup>

<ItemGroup>
<Compile Remove="eaupak\**" />
<EmbeddedResource Remove="eaupak\**" />
<None Remove="eaupak\**" />
</ItemGroup>
<!-- If on Windows, include winforms -->
<PropertyGroup Condition="'$(OS)' == 'Windows_NT'">
<DefineConstants>Windows</DefineConstants>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<Compile Remove="eaupak\**" />
<EmbeddedResource Remove="eaupak\**" />
<None Remove="eaupak\**" />
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ namespace Eaucool
// Eaucool Programming Language - Licensed under GNU GPL v3.0
internal class Program
{
#if Windows
public static Form form;
#endif
public static Dictionary<string, string> variables = new Dictionary<string, string>();
public static Dictionary<string, string[]> methodCode = new Dictionary<string, string[]>();
public static int randMax = 10;
Expand Down Expand Up @@ -208,6 +211,11 @@ static void Main(string[] args)
Console.WriteLine("Press any key to continue...");
Console.ReadKey();
}

while (form.Visible)
{
Application.DoEvents();
}
}

internal static bool IsVariable(string v)
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,15 @@ The new percentCool
# How to pronounce Eaucool
Oh, cool!

# Examples

## Hello World
```
echo "Hello World!"
```

## Simple GUI
```
newgui "Eaucool GUI" 800 600
addlabel "Hello, World!" 0 0 100 100
```
141 changes: 140 additions & 1 deletion Utilities/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,152 @@ public static void Init()
keywords.Add("urlpost ", Kw_Urlpost);
#endregion

#if Windows
#region GUI Keywords
keywords.Add("newgui ", Kw_Newgui);
keywords.Add("addbutton ", Kw_Addbutton);
keywords.Add("addlabel ", Kw_Addlabel);
keywords.Add("addtextbox ", Kw_Addtextbox);
#endregion
#endif

#region Method Keywords
keywords.Add("method ", Kw_Method);
keywords.Add("stopmethod", Kw_Stopmethod);
keywords.Add("callmethod ", Kw_Callmethod);
#endregion
}
#if Windows
private static void Kw_Addtextbox()
{
string[] args = CodeParser.ParseLineIntoTokens(line);
string x = Utils.GetString(args, 1);
string y = Utils.GetString(args, 2);
string width = Utils.GetString(args, 3);
string height = Utils.GetString(args, 4);
string method = Utils.GetString(args, 5);

if (x == string.Empty || y == string.Empty || width == string.Empty || height == string.Empty || method == string.Empty)
{
return;
}

// Check if we are on Windows
if (Environment.OSVersion.Platform != PlatformID.Win32NT)
{
Program.Error("GUIs are only supported on Windows");
return;
}

// Create the textbox
TextBox textbox = new TextBox();
textbox.Left = int.Parse(x);
textbox.Top = int.Parse(y);
textbox.Width = int.Parse(width);
textbox.Height = int.Parse(height);
textbox.TextChanged += (sender, e) =>
{
Program.methodCode[method] = textbox.Text.Split('\n');
};
Program.form.Controls.Add(textbox);
}

private static void Kw_Addlabel()
{
string[] args = CodeParser.ParseLineIntoTokens(line);
string text = Utils.GetString(args, 1);
string x = Utils.GetString(args, 2);
string y = Utils.GetString(args, 3);
string width = Utils.GetString(args, 4);
string height = Utils.GetString(args, 5);

if (text == string.Empty || x == string.Empty || y == string.Empty || width == string.Empty || height == string.Empty)
{
return;
}

// Check if we are on Windows
if (Environment.OSVersion.Platform != PlatformID.Win32NT)
{
Program.Error("GUIs are only supported on Windows");
return;
}

// Create the label
Label label = new Label();
label.Text = text;
label.Left = int.Parse(x);
label.Top = int.Parse(y);
label.Width = int.Parse(width);
label.Height = int.Parse(height);
Program.form.Controls.Add(label);
}

private static void Kw_Addbutton()
{
string[] args = CodeParser.ParseLineIntoTokens(line);
string text = Utils.GetString(args, 1);
string x = Utils.GetString(args, 2);
string y = Utils.GetString(args, 3);
string width = Utils.GetString(args, 4);
string height = Utils.GetString(args, 5);
string method = Utils.GetString(args, 6);

if (text == string.Empty || x == string.Empty || y == string.Empty || width == string.Empty || height == string.Empty || method == string.Empty)
{
return;
}

// Check if we are on Windows
if (Environment.OSVersion.Platform != PlatformID.Win32NT)
{
Program.Error("GUIs are only supported on Windows");
return;
}

// Create the button
Button button = new Button();
button.Text = text;
button.Left = int.Parse(x);
button.Top = int.Parse(y);
button.Width = int.Parse(width);
button.Height = int.Parse(height);
button.Click += (sender, e) =>
{
int oldj = Program.j;
Program.ParseCOOL(string.Join("\n", Program.methodCode[method]), true);
Program.j = oldj;
};
Program.form.Controls.Add(button);
}

private static void Kw_Newgui()
{
string[] args = CodeParser.ParseLineIntoTokens(line);
string title = Utils.GetString(args, 1);
string width = Utils.GetString(args, 2);
string height = Utils.GetString(args, 3);

if (title == string.Empty || width == string.Empty || height == string.Empty)
{
return;
}

// Check if we are on Windows
if (Environment.OSVersion.Platform != PlatformID.Win32NT)
{
Program.Error("GUIs are only supported on Windows");
return;
}

// Create the form
Program.form = new Form();
Program.form.Text = title;
Program.form.Width = int.Parse(width);
Program.form.Height = int.Parse(height);
Program.form.Show();
}
#endif
private static void Kw_Execute()
{
string[] args = CodeParser.ParseLineIntoTokens(line);
Expand All @@ -87,7 +226,7 @@ private static void Kw_Execute()

try
{
Process.Start(command, arguments).WaitForExit();
Process.Start(command, arguments).WaitForExit(-1);
}
catch (FileNotFoundException)
{
Expand Down
2 changes: 1 addition & 1 deletion eaupak/eaupak.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net6.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down

0 comments on commit 0984e41

Please sign in to comment.