Skip to content

Commit

Permalink
ezrSquared prerelease-1.5.1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Uralstech committed May 3, 2023
1 parent ca88ba3 commit 284b949
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 20 deletions.
5 changes: 5 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
CHANGELOG - What's new?

* prerelease-1.5.1.3.0 - [03-05-23]
* Added new functions `get_window_size`, `set_window_size`, `get_window_position` and `set_window_position` -
to `Console` class in the IO library
* Function `set_buffer_size` in `Console` class in the IO library now uses the `SetBufferSize` C# function

* prerelease-1.5.1.2.0 - [01-04-23]
* Added new functions `get_buffer_size` and `set_buffer_size` to `Console` class in the IO library
* Unsupported functions in `Console` class in the IO library will now show new error if called
Expand Down
4 changes: 2 additions & 2 deletions Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ namespace ezrSquared.Constants
{
public static class constants
{
public const string VERSION = "prerelease-1.5.1.2.0";
public const string VERSION_DATE = "01.04.2023";
public const string VERSION = "prerelease-1.5.1.3.0";
public const string VERSION_DATE = "03.05.2023";

public static readonly string[] KEYWORDS = { "item", "and", "or", "invert", "if", "else", "do", "count", "from", "as", "to", "step", "while", "function", "special", "with", "end", "return", "skip", "stop", "try", "error", "in", "object", "global", "include", "all" };
public static readonly string[] QEYWORDS = { "f", "l", "e", "c", "t", "n", "w", "fd", "sd", "od", "i", "s", "d", "g", "v" };
Expand Down
2 changes: 1 addition & 1 deletion Installer/ezrSquared 32-bit.iss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "environment.iss"

#define MyAppName "ezr²"
#define MyAppVersion "prerelease-1.5.1.2.0"
#define MyAppVersion "prerelease-1.5.1.3.0"
#define MyAppPublisher "Uralstech"
#define MyAppURL "https://uralstech.github.io/ezrSquared/"
#define MyAppExeName "ezrSquared.exe"
Expand Down
2 changes: 1 addition & 1 deletion Installer/ezrSquared 64-bit.iss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "environment.iss"

#define MyAppName "ezr²"
#define MyAppVersion "prerelease-1.5.1.2.0"
#define MyAppVersion "prerelease-1.5.1.3.0"
#define MyAppPublisher "Uralstech"
#define MyAppURL "https://uralstech.github.io/ezrSquared/"
#define MyAppExeName "ezrSquared.exe"
Expand Down
76 changes: 72 additions & 4 deletions Libraries/io/IO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ public override runtimeResult execute(item[] args)
internalContext.symbolTable.set("get_cursor_visibility", new predefined_function("console_get_cursor_visibility", getCursorVisibility, new string[0]));
internalContext.symbolTable.set("set_cursor_visibility", new predefined_function("console_set_cursor_visibility", setCursorVisibility, new string[1] { "visibility" }));
internalContext.symbolTable.set("set_buffer_size", new predefined_function("console_set_buffer_size", setBufferSize, new string[2] { "x_size", "y_size" }));
internalContext.symbolTable.set("set_window_position", new predefined_function("console_set_window_position", setWindowPosition, new string[2] { "x_position", "y_position" }));
internalContext.symbolTable.set("set_window_size", new predefined_function("console_set_window_size", setWindowSize, new string[2] { "x_size", "y_size" }));
}
else
{
Expand All @@ -376,6 +378,8 @@ public override runtimeResult execute(item[] args)
internalContext.symbolTable.set("get_cursor_visibility", new predefined_function("console_get_cursor_visibility", platformNotSupported, new string[0]));
internalContext.symbolTable.set("set_cursor_visibility", new predefined_function("console_set_cursor_visibility", platformNotSupported, new string[1] { "visibility" }));
internalContext.symbolTable.set("set_buffer_size", new predefined_function("console_set_buffer_size", platformNotSupported, new string[2] { "x_size", "y_size" }));
internalContext.symbolTable.set("set_window_position", new predefined_function("console_set_window_position", platformNotSupported, new string[2] { "x_position", "y_position" }));
internalContext.symbolTable.set("set_window_size", new predefined_function("console_set_window_size", platformNotSupported, new string[2] { "x_size", "y_size" }));
}

internalContext.symbolTable.set("get_background", new predefined_function("console_get_background", getConsoleBackground, new string[0]));
Expand All @@ -386,6 +390,8 @@ public override runtimeResult execute(item[] args)
internalContext.symbolTable.set("get_cursor_position", new predefined_function("console_get_cursor_position", getCursorPosition, new string[0]));
internalContext.symbolTable.set("set_cursor_position", new predefined_function("console_set_cursor_position", setCursorPosition, new string[2] { "x_position", "y_position" }));
internalContext.symbolTable.set("get_buffer_size", new predefined_function("console_get_buffer_size", getBufferSize, new string[0]));
internalContext.symbolTable.set("get_window_position", new predefined_function("console_get_window_position", getWindowPosition, new string[0]));
internalContext.symbolTable.set("get_window_size", new predefined_function("console_get_window_size", getWindowSize, new string[0]));
internalContext.symbolTable.set("exit", new predefined_function("console_exit", stopApplication, new string[0]));

return new runtimeResult().success(new @object(name, internalContext).setPosition(startPos, endPos).setContext(context));
Expand Down Expand Up @@ -433,6 +439,69 @@ private runtimeResult setCursorSize(context context, position[] positions)
Console.CursorSize = sizeValue;
return result.success(new nothing());
}

private runtimeResult getWindowSize(context context, position[] positions)
{
int width = Console.WindowWidth;
int height = Console.WindowHeight;

return new runtimeResult().success(new array(new item[2] { new integer(width).setPosition(positions[0], positions[1]).setContext(context), new integer(height).setPosition(positions[0], positions[1]).setContext(context) }));
}

private runtimeResult setWindowSize(context context, position[] positions)
{
runtimeResult result = new runtimeResult();

item xsize = context.symbolTable.get("x_size");
if (xsize is not integer && xsize is not @float)
return result.failure(new runtimeError(positions[0], positions[1], RT_TYPE, "X_size must be an integer or float", context));

item ysize = context.symbolTable.get("y_size");
if (ysize is not integer && ysize is not @float)
return result.failure(new runtimeError(positions[0], positions[1], RT_TYPE, "Y_size must be an integer or float", context));

(int width, int height) = ((int)((value)xsize).storedValue, (int)((value)ysize).storedValue);

int maxWindowHeight2 = height + Console.WindowTop;
if (width < 1 || width > Console.LargestWindowWidth)
return result.failure(new runtimeError(positions[0], positions[1], RT_OVERFLOW, $"X size must be in range 1-{Console.LargestWindowWidth}", context));
if (height < 1 || height > Console.LargestWindowHeight || maxWindowHeight2 >= Int16.MaxValue)
return result.failure(new runtimeError(positions[0], positions[1], RT_OVERFLOW, $"Y size must be in range 1-{Console.LargestWindowHeight}", context));

Console.SetWindowSize(width, height);
return result.success(new nothing());
}

private runtimeResult getWindowPosition(context context, position[] positions)
{
int left = Console.WindowLeft;
int top = Console.WindowTop;

return new runtimeResult().success(new array(new item[2] { new integer(left).setPosition(positions[0], positions[1]).setContext(context), new integer(top).setPosition(positions[0], positions[1]).setContext(context) }));
}

private runtimeResult setWindowPosition(context context, position[] positions)
{
runtimeResult result = new runtimeResult();

item xposition = context.symbolTable.get("x_position");
if (xposition is not integer && xposition is not @float)
return result.failure(new runtimeError(positions[0], positions[1], RT_TYPE, "X_position must be an integer or float", context));

item yposition = context.symbolTable.get("y_position");
if (yposition is not integer && yposition is not @float)
return result.failure(new runtimeError(positions[0], positions[1], RT_TYPE, "Y_position must be an integer or float", context));

(int left, int top) = ((int)((value)xposition).storedValue, (int)((value)yposition).storedValue);

if (left < 0 || left + Console.WindowWidth > Console.BufferWidth)
return result.failure(new runtimeError(positions[0], positions[1], RT_OVERFLOW, $"X position must be in range 0-{Console.BufferWidth - Console.WindowWidth}", context));
if (top < 0 || top + Console.WindowHeight > Console.BufferHeight)
return result.failure(new runtimeError(positions[0], positions[1], RT_OVERFLOW, $"Y position must be in range 0-{Console.BufferHeight - Console.WindowHeight}", context));

Console.SetWindowPosition(left, top);
return result.success(new nothing());
}

private runtimeResult getBufferSize(context context, position[] positions)
{
Expand All @@ -459,12 +528,11 @@ private runtimeResult setBufferSize(context context, position[] positions)
int minWidth = Console.WindowLeft + Console.WindowWidth;
int minHeight = Console.WindowTop + Console.WindowHeight;
if (width < minWidth || width >= Int16.MaxValue)
return result.failure(new runtimeError(positions[0], positions[1], RT_OVERFLOW, $"X size must be in range {minWidth}-{Int16.MaxValue-1}", context));
return result.failure(new runtimeError(positions[0], positions[1], RT_OVERFLOW, $"X size must be in range {minWidth}-{Int16.MaxValue - 1}", context));
if (height < minHeight || height >= Int16.MaxValue)
return result.failure(new runtimeError(positions[0], positions[1], RT_OVERFLOW, $"Y size must be in range {minHeight}-{Int16.MaxValue-1}", context));
return result.failure(new runtimeError(positions[0], positions[1], RT_OVERFLOW, $"Y size must be in range {minHeight}-{Int16.MaxValue - 1}", context));

Console.BufferWidth = width;
Console.BufferHeight = height;
Console.SetBufferSize(width, height);
return result.success(new nothing());
}

Expand Down
10 changes: 4 additions & 6 deletions Libraries/io/io.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<Reference Include="ezrSquared">
<HintPath>..\..\bin\Release\net7.0\win-x64\ezrSquared.dll</HintPath>
</Reference>
</ItemGroup>

<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\ezrSquared.csproj" />
</ItemGroup>
</Project>
10 changes: 4 additions & 6 deletions Libraries/std/std.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<Reference Include="ezrSquared">
<HintPath>..\..\bin\Release\net7.0\win-x64\ezrSquared.dll</HintPath>
</Reference>
</ItemGroup>

<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\ezrSquared.csproj" />
</ItemGroup>

</Project>
5 changes: 5 additions & 0 deletions docs/index.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ The documentation is packaged with the Windows installer. For other OSes, downlo
## Latest Updates
**For those confused by the versioning: 1st place -> Major; 2nd place -> Feature; 3rd place -> Quality of Life; 4th place -> Library; 5th place -> Patch**. I plan to switch to [***Semantic Versioning 2.0.0***](https://semver.org/) for the first stable release.

* **prerelease-1.5.1.3.0** - [03-05-23]
* Added new functions `get_window_size`, `set_window_size`, `get_window_position` and `set_window_position` -
to `Console` class in the IO library
* Function `set_buffer_size` in `Console` class in the IO library now uses the `SetBufferSize` C# function

* **prerelease-1.5.1.2.0** - [01-04-23]
* Added new functions `get_buffer_size` and `set_buffer_size` to `Console` class in the IO library
* Unsupported functions in `Console` class in the IO library will now show new error if called
Expand Down

0 comments on commit 284b949

Please sign in to comment.