Compare commits

..

No commits in common. "testing-ground" and "master" have entirely different histories.

21 changed files with 111 additions and 489316 deletions

View file

@ -18,7 +18,7 @@ namespace cce {
byte reset = 0;
(int, int) since = (0,0);
while (true) {
Title = Program.title + " >>> Settings";
Title = Title + " >>> Settings";
if (since.Item1 >= 4) {
saved = false;
since.Item1 = 0;
@ -56,22 +56,11 @@ namespace cce {
since.Item2++;
}
}
static internal void Dev() {
if (!File.Exists("dev")) {
BackgroundColor = ConsoleColor.Red;
WriteLine(" \n" +
" Unable to comply, not a dev \n" +
" ");
ResetColor();
return;
}
}
}
internal class AppSettings {
static internal byte Lgwrite = 1;
static internal string Common = "common.json";
static internal string Extended = "extended.json";
static internal string Dictionary = "dictionary.json";
static internal string Settings = "settings.json";
static internal (int, int) top_bottom = (0, 0);
static internal void Check() {

View file

@ -27,21 +27,20 @@ namespace cce {
WriteCrypto();
choice = Chooser();
CursorVisible = false;
var entry = new List<string>();
var entry = "";
if ((new int[] {1,2}).Contains(choice)) {
Utils.LagWrite("Please enter the sentence (Enter to submit, Ctrl+Enter for another line):", true);
Utils.LagWrite("Please enter the sentence: ");
CursorVisible = true;
//Write("Please enter the sentence: ");
entry = Utils.Entry();
entry = ReadLine();
CursorVisible = false;
}
bool skip = false;
if (choice == 1) { Transcoder.Encode(entry, out string enc); Utils.Clip(enc); }
if (choice == 1) { Transcoder.Encode(entry); Utils.Clip(Transcoder.result); }
else if (choice == 2) Transcoder.Decode(entry);
else if (choice == 5) Transcoder.Teacher();
else if (choice == 8) skip = App.Settings();
else if (choice == 9) App.Dev();
else if (choice == 253) { Clear(); continue; }
else if (choice == 9) Transcoder.head_transcribe();
else if (choice == 254) Help();
else if (choice == 255) { Beep(4000, 200); return; }
@ -62,8 +61,7 @@ namespace cce {
+"\n[5] Teach new words"
+"\n-------------------------"
+"\n[8] Settings"
+"\n[9] DEV"
+"\n[c] Clear Console"
+"\n[9] DEV: Update JSON files using sorted files from python"
+"\n[?] Help"
+"\n[Backspace] Exit"
+"\n>>> ");
@ -93,10 +91,6 @@ namespace cce {
case ',':
if ((new char[] { '?','/','-',','}).Contains(choice.KeyChar)) return 254;
return byte.Parse(choice.KeyChar.ToString());
case 'c':
case 'C':
if ((new char[] { 'c', 'C' }).Contains(choice.KeyChar)) return 253;
return byte.Parse(choice.KeyChar.ToString());
default:
WriteLine("Not a valid option");
break;

View file

@ -12,8 +12,8 @@ using static System.Threading.Thread;
namespace cce {
class Transcoder {
static internal string result = "";
static private List<string> extended_dict = null;
static private List<string> common_dict = null;
static private Dictionary<string, string> extended_dict = null;
static private Dictionary<string, string> common_dict = null;
static private Dictionary<char, char> substitution = new Dictionary<char, char>{
{'a','a' },
{'b','t' },
@ -88,15 +88,15 @@ namespace cce {
if (extended_dict == null || common_dict == null) init();
switch (cki) {
case '1':
if (common_dict.Contains(translation)) {
if (common_dict.ContainsKey(translation)) {
WriteLine("Error: Unable to add a new translation. Translation already present.");
} else common_dict.Add(translation);
} else common_dict.Add(translation, cyphered);
entered = true;
break;
case '2':
if (extended_dict.Contains(translation)) {
if (extended_dict.ContainsKey(translation)) {
WriteLine("Error: Unable to add a new translation. Translation already present.");
} else extended_dict.Add(translation);
} else extended_dict.Add(translation, cyphered);
entered = true;
break;
default:
@ -108,47 +108,12 @@ namespace cce {
WriteLine("Translation Added"); ResetColor();
update();
}
static internal void Encode(List<string> entry, out string encrypted) {
var temp = new List<string>();
WriteLine("Transcoding:\n{0}\n", String.Join("\n", entry));
for (int i = 0; i < entry.Count; i++) {
result = raw_encode(entry[i]);
Utils.LagWrite(result);
temp.Add(result);
if(entry.Count>1) WriteLine();
}
encrypted = String.Join("\n", temp);
static internal void Encode(string entry) {
result = raw_encode(entry);
WriteLine("Transcoding:\n{0}\n", entry);
Utils.LagWrite(result);
}
static internal void Decode(List<string> lines) {
for (int i = 0; i < lines.Count; i++) {
raw_decode(lines[i]);
if (lines.Count <= 1 || i == lines.Count-1) break;
SetCursorPosition(0, WindowHeight - 2);
Write("Press Enter to write the next line");
while (true) {
var cki = ReadKey();
if (cki.Key == ConsoleKey.Enter) break;
}
}
}
static private void update() {
uniquere();
var dict = new Dictionary<string, List<string>>();
File.WriteAllText(AppSettings.Dictionary, JsonConvert.SerializeObject(dict));
}
static private string raw_encode(string entry) {
var sentence = entry.ToLower();
char[] encoded = new char[entry.Length];
for (int i = 0; i < sentence.Length; i++) {
if (substitution.TryGetValue(sentence[i], out char substituted)) {
encoded[i] = Char.IsUpper(entry[i]) ? Char.ToUpper(substituted) : Char.ToLower(substituted);
} else {
encoded[i] = entry[i];
}
}
return String.Join("", encoded);
}
static private void raw_decode(string entry) {
static internal void Decode(string entry) {
var sentence = entry.ToLower();
//120x30, buffer 240x60
if (sentence.Length >= 120) { BufferWidth = sentence.Length * 2; WindowWidth = sentence.Length + 20; }
@ -179,12 +144,26 @@ namespace cce {
Write(string.Join("", writeout));
for (int i = 0; i < decode.Length; i++) {
if (symbols[left] != 'x') left++;
//var options = new List<string>();
CursorTop = memTop;
Console.BackgroundColor = ConsoleColor.Green;
Console.ForegroundColor = ConsoleColor.Black;
wordwrite(common_dict, decode[i], entry, left);
wordwrite(common_dict, decode[i], entry, left, i);
/*foreach (var item in common_dict) {
if (item.Value == decode[i]) {
CursorLeft = left;
//options.Add(item.Key);
for (int j = 0; j < item.Key.Length; j++) {
Write(Char.IsUpper(entry[i]) ? char.Parse(item.Key[j].ToString().ToUpper()) : char.Parse(item.Key[j].ToString().ToLower()));
}
Write(item.Key.ToUpper());
Sleep(100);
CursorTop++;
}
}*/
Console.BackgroundColor = ConsoleColor.Blue;
wordwrite(extended_dict, decode[i], entry, left);
Console.ForegroundColor = ConsoleColor.Black;
wordwrite(extended_dict, decode[i], entry, left, i);
ResetColor();
List<List<char>> letter_decode = new List<List<char>>();
for (int j = 0; j < decode[i].Length; j++) {
@ -194,8 +173,7 @@ namespace cce {
letterlist.Add(substituted[h]);
}
letter_decode.Add(letterlist);
}
else {
} else {
letter_decode.Add(new List<char> { sentence[j] });
}
}
@ -219,31 +197,95 @@ namespace cce {
ResetColor();
//return string.Join(" ", decoded);
}
static internal void head_transcribe() {
if(!File.Exists("dev")) {
Clear();
BackgroundColor = ConsoleColor.Red;
Utils.LagWrite(" \n" +
" Unable to comply. Not a dev version \n"+
" ", true);
ResetColor();
return;
}
raw_transcribe("common_dict.txt", "common_dict.json");
raw_transcribe("extended_dict.txt", "extended_dict.json");
uniquire();
}
static private void update() {
uniquire();
File.WriteAllText(AppSettings.Extended, JsonConvert.SerializeObject(extended_dict));
File.WriteAllText(AppSettings.Common, JsonConvert.SerializeObject(common_dict));
}
static private string raw_encode(string entry) {
var sentence = entry.ToLower();
char[] encoded = new char[entry.Length];
for (int i = 0; i < sentence.Length; i++) {
if (substitution.TryGetValue(sentence[i], out char substituted)) {
encoded[i] = Char.IsUpper(entry[i]) ? Char.ToUpper(substituted) : Char.ToLower(substituted);
} else {
encoded[i] = entry[i];
}
}
return String.Join("", encoded);
}
static internal bool init() {
if (common_dict != null && extended_dict != null) return true;
var checker = true;
var dict = new Dictionary<string, List<string>>();
WriteLine("[Loading Dictionary]");
if (File.Exists(AppSettings.Dictionary)) dict = JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(File.ReadAllText(AppSettings.Dictionary));
if (File.Exists(AppSettings.Extended)) extended_dict = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(AppSettings.Extended));
else { WriteLine("File missing"); checker = false; }
if (File.Exists(AppSettings.Common)) common_dict = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(AppSettings.Common));
else { WriteLine("File missing"); checker = false; }
common_dict = dict["common"];
extended_dict = dict["extended"];
return checker;
}
static private void uniquere() {
static private void uniquire() {
init();
foreach (var item in common_dict) {
if (extended_dict.Contains(item)) extended_dict.Remove(item);
if (extended_dict.ContainsKey(item.Key)) extended_dict.Remove(item.Key);
}
}
static private void wordwrite(List<string> collection, string decode, string entry,int left) {
static private void raw_transcribe(string input, string output) {
var lines = File.ReadAllLines(input);
for (int i = 0; i < lines.Length; i++) {
lines[i] = lines[i].ToLower();
}
var English = new string[lines.Length];
lines.CopyTo(English, 0);
for (int i = 0; i < English.Length; i++) {
var word = new char[English[i].Length];
for (int j = 0; j < English[i].Length; j++) {
if (substitution.TryGetValue(English[i][j], out char substituted)) {
word[j] = substituted;
}
else {
word[j] = English[i][j];
}
}
lines[i] = String.Join("", word);
WriteLine($"{English[i]}:{lines[i]}");
}
Dictionary<string, string> vals = new Dictionary<string, string>();
for (int i = 0; i < English.Length; i++) {
if (vals.ContainsKey(English[i])) continue;
vals.Add(English[i], lines[i]);
}
File.WriteAllText(output, JsonConvert.SerializeObject(vals));
}
static internal void concat() {
init();
var dict = new Dictionary<string, Dictionary<string, string>>();
dict.Add("short", common_dict);
dict.Add("long", extended_dict);
File.WriteAllText("dictionary.json", JsonConvert.SerializeObject(dict));
}
static private void wordwrite(Dictionary<string, string> collection, string decode, string entry,int left, int i) {
foreach (var item in collection) {
var trans = raw_encode(item);
if (trans == decode) {
if (item.Value == decode) {
CursorLeft = left;
//options.Add(item.Key);
for (int j = 0; j < item.Length; j++) {
Write(Char.IsUpper(entry[CursorLeft]) ? Char.ToUpper(item[j]) : Char.ToLower(item[j]));
for (int j = 0; j < item.Key.Length; j++) {
Write(Char.IsUpper(entry[CursorLeft]) ? Char.ToUpper(item.Key[j]) : Char.ToLower(item.Key[j]));
}
Utils.VarSleep(10, low: 20,high:100);
CursorTop++;

View file

@ -27,7 +27,7 @@ namespace cce {
WriteLine();
if (Char.ToLower(cki) == 'y') { Clipboard.SetText(clip); WriteLine("Writing to Clipboard: Done!"); } else WriteLine("Writing to Clipboard: Canceled by User");
}
static internal void LagWrite(string input, bool newline = false) {
internal static void LagWrite(string input, bool newline = false) {
if (AppSettings.Lgwrite == 0) {
if (newline) WriteLine(input);
else Write(input);
@ -59,40 +59,5 @@ namespace cce {
if (newline || i < phrases.Count - 1) WriteLine();
}
}
static internal List<string> Entry() {
var list = new List<string>();
ConsoleKeyInfo input = new ConsoleKeyInfo();
bool exit = false;
do {
List<char> chars = new List<char>();
exit = false;
for (int i = 0; i < 30; i++) {
input = ReadKey();
if (chars.Count > 0 && input.Key == ConsoleKey.Enter && input.Modifiers == ConsoleModifiers.Control) {
list.Add(String.Join("", chars));
break;
}
else if (i > 20 && input.Key == ConsoleKey.Spacebar || i > 29) {
list.Add(String.Join("", chars));
WriteLine();
break;
}
else if (chars.Count > 0 && input.Key == ConsoleKey.Enter && input.Modifiers == 0) {
list.Add(String.Join("", chars));
exit = true;
break;
}
else if (input.Key == ConsoleKey.Backspace) {
chars.RemoveAt(chars.Count-1);
if (CursorLeft >0) {
Write(" "); CursorLeft--;
}
}
else chars.Add(input.KeyChar);
}
} while (!exit);
return list;
}
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -1,26 +0,0 @@
import json
f1 = open('common.json', 'r')
f2 = open('extended.json', 'r')
data1 = json.load(f1)
data2 = json.load(f2)
f1.close()
f2.close()
words1 = []
words2 = []
for key in data1:
words1.append(key)
for key in data2:
words2.append(key)
dict = {
'common':words1,
'extended':words2
}
f = open("dictionary.json", "w")
json.dump(dict, f)
f.close()
print("done")

View file

@ -1 +0,0 @@
import json

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

File diff suppressed because one or more lines are too long

View file

@ -1 +0,0 @@
{"LagWrite":"1","Common":"common.json","Extended":"extended.json","Settings":"settings.json"}