-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9333eea
commit 1338946
Showing
4 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
|
||
namespace ziv | ||
{ | ||
public class Editor | ||
{ | ||
// If ziv ended yet. | ||
private static bool Ended = false; | ||
|
||
// A list of colors that are hard to see if the white text is in front of it | ||
private static ConsoleColor[] LightColors = { ConsoleColor.White, ConsoleColor.DarkCyan,ConsoleColor.DarkYellow,ConsoleColor.Cyan,ConsoleColor.Yellow,ConsoleColor.Gray,ConsoleColor.Green,ConsoleColor.Blue,ConsoleColor.Magenta }; | ||
public static void Entry(string file) | ||
{ | ||
Console.Clear(); | ||
ConsoleColor back = (ConsoleColor)Program.rng.Next(0,15); // Random color | ||
//Console.WriteLine(back); | ||
ConsoleColor fore = ConsoleColor.White; | ||
if (LightColors.Contains(back)) | ||
{ | ||
fore = ConsoleColor.Black; | ||
} | ||
Bar(back, $"ziv - {file} - Type $-wq on 1 line to save and quit.", fore); | ||
MainLoop(file); | ||
} | ||
|
||
public static void MainLoop(string file) | ||
{ | ||
Console.Write(Program.buffer); | ||
while (true) | ||
{ | ||
string Buffer2 = Console.ReadLine(); | ||
if (Buffer2 == "$-wq") | ||
{ | ||
Console.Clear(); | ||
Console.WriteLine("Saving file to disk..."); | ||
File.WriteAllText(file,Program.buffer); | ||
Environment.Exit(0); | ||
} else if (Buffer2 == "$-q") | ||
{ | ||
Console.Clear(); | ||
Environment.Exit(0); | ||
} | ||
else | ||
{ | ||
Program.buffer += $"{Buffer2}\n"; | ||
} | ||
} | ||
} | ||
|
||
public static void Bar(ConsoleColor barcolor, string Ltext, ConsoleColor LtextColor) | ||
{ | ||
ConsoleColor oldc = Console.BackgroundColor; // Make an archive of the old background color | ||
Console.BackgroundColor = barcolor; // Change background color to desired one | ||
Console.SetCursorPosition(0, Console.CursorTop); // Go the the beginning of the current console line | ||
Console.Write(new string(' ', Console.BufferWidth)); // Draw a white space, as many times as it takes to fill the terminal. | ||
Console.SetCursorPosition(0, Console.CursorTop-1); // Go back to the beginning of the line that we drew the white spaces in | ||
ConsoleColor oldlc = Console.ForegroundColor; // Make an archive of the old foreground color | ||
Console.ForegroundColor = LtextColor; // Change foreground color to desired one | ||
Console.Write(Ltext); // Draw the bar text | ||
Console.ForegroundColor = oldlc; // Restore foreground color | ||
Console.BackgroundColor = oldc; // Restore background color | ||
Console.SetCursorPosition(0, Console.CursorTop + 1); // Go to the beginning of the line after the line that we drew the white spaces in | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
CSC=dotnet | ||
projname=ziv | ||
tgtversion=7.0 | ||
tgtsys=linux-x64 | ||
bin=bin/Debug/net$(tgtversion)/$(tgtsys)/$(projname).dll | ||
CSC_flags=-r $(tgtsys) --self-contained false | ||
all: file | ||
build: | ||
@ echo Building $(projname)... | ||
$(CSC) build $(CSC_flags) | ||
|
||
file: | ||
@ echo Building $(projname) into one file... | ||
$(CSC) publish -r $(tgtsys) -p:PublishSingleFile=true --self-contained false | ||
|
||
run: | ||
@ dotnet $(bin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
|
||
namespace ziv | ||
{ | ||
public class Program | ||
{ | ||
public static Random rng = new Random(); // Global random object | ||
public static string version = "Milestone 1 [Build 230411]"; // Version string | ||
public static string buffer = ""; // Text buffer | ||
public static void Main(string[] args) // Runner, sets up the buffer | ||
{ | ||
if (args.Length == 1) // If one argument is passed | ||
{ | ||
if (File.Exists(args[0])) // If the first argument exists as a file | ||
{ | ||
buffer = File.ReadAllText(args[0]); // Setup the buffer | ||
} | ||
else | ||
{ | ||
if (args[0] == "--version" || args[0] == "-v") | ||
{ | ||
Console.WriteLine($"ziv {version}"); | ||
} | ||
else | ||
{ | ||
Console.WriteLine("ziv says: No files? I'll make one then!"); | ||
} | ||
} | ||
Editor.Entry(args[0]); // Call the actual ziv editor | ||
} | ||
else | ||
{ | ||
Console.WriteLine("It would be nice if actually gave me a file to edit."); | ||
Environment.Exit(0); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |