diff --git a/docs/CONTROL_CHARACTERS.md b/docs/CONTROL_CHARACTERS.md
new file mode 100644
index 0000000..003356a
--- /dev/null
+++ b/docs/CONTROL_CHARACTERS.md
@@ -0,0 +1,36 @@
+The first 32 characters differ from the standard ASCII control characters when data is being transmitted over NOTP.
+| Dec | Hex | Bin | Usage |
+| --- | --- | --- | --- |
+| 00 | 00 | 00000 | Null |
+| 01 | 01 | 00001 | Start of NOTP transmisson |
+| 02 | 02 | 00010 | End of NOTP transmission |
+| 03 | 03 | 00011 | Start of a NOTP key |
+| 04 | 04 | 00100 | End of a NOTP key |
+| 05 | 05 | 00101 | Start of a NOTP Object |
+| 06 | 06 | 00110 | End of a NOTP Object |
+| 07 | 07 | 00111 | Start of a NOTP String |
+| 08 | 08 | 01000 | End of a NOTP String |
+| 09 | 09 | 01001 | Start of a NOTP List |
+| 10 | 0A | 01010 | End of a NOTP List |
+| 11 | 0B | 01011 | Start of a NOTP Int |
+| 12 | 0C | 01100 | End of a NOTP Int |
+| 13 | 0D | 01101 | |
+| 14 | 0E | 01110 | |
+| 15 | 0F | 01111 | |
+| 16 | 10 | 10000 | Newline and Carriage Return |
+| 17 | 11 | 10001 | Tab |
+| 18 | 12 | 10010 | |
+| 19 | 13 | 10011 | |
+| 20 | 14 | 10100 | |
+| 21 | 15 | 10101 | |
+| 22 | 16 | 10110 | |
+| 23 | 17 | 10111 | |
+| 24 | 18 | 11000 | |
+| 25 | 19 | 11001 | |
+| 26 | 1A | 11010 | |
+| 27 | 1B | 11011 | |
+| 28 | 1C | 11100 | |
+| 29 | 1D | 11101 | |
+| 30 | 1E | 11110 | |
+| 31 | 1F | 11111 | |
+After this, the characters are just ASCII
diff --git a/src/files.rs b/src/files.rs
index 42f334b..c9fe6fa 100644
--- a/src/files.rs
+++ b/src/files.rs
@@ -82,11 +82,11 @@ fn backslash(bytes: &mut Vec, character: u8)
{
110 => // newline
{
- bytes.push(14);
+ bytes.push(16);
},
116 => // tab
{
- bytes.push(15);
+ bytes.push(17);
},
_ => bytes.push(character), // Otherwise just push the character
}
@@ -100,8 +100,8 @@ fn default_flag(bytes: &mut Vec, temp_string: &mut Vec, flag: &mut Mode,
temp_string.push(3); // ( for name start
*flag = Mode::Name;
}
- 123 => bytes.push(5),
- 125 => bytes.push(6),
+ 123 => bytes.push(5), // {
+ 125 => bytes.push(6), // }
58 =>
{
*index_flag = index + 1;
@@ -112,6 +112,8 @@ fn default_flag(bytes: &mut Vec, temp_string: &mut Vec, flag: &mut Mode,
temp_string.push(7);
*flag = Mode::String;
},
+ 91 => temp_string.push(9),
+ 93 => temp_string.push(10),
_ => (),
}
}
@@ -146,7 +148,14 @@ fn encode_npon(file_contents: &str, depth: u8) ->
}
match flag
{
- Mode::Default => default_flag(&mut bytes, &mut temp_string, &mut flag, &mut index_flag, character, index),
+ Mode::Default => default_flag(
+ &mut bytes,
+ &mut temp_string,
+ &mut flag,
+ &mut index_flag,
+ character,
+ index
+ ),
Mode::String => // in a string
{
match character
@@ -157,6 +166,14 @@ fn encode_npon(file_contents: &str, depth: u8) ->
bytes.append(&mut temp_string);
flag = Mode::Default;
},
+ 9 => // Tab
+ {
+ temp_string.push(17);
+ },
+ 10 => // Newline
+ {
+ temp_string.push(16);
+ },
92 => backslash_flag = true,
_ => temp_string.push(character),
}
diff --git a/src/main.rs b/src/main.rs
index ca73f88..d31ac77 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -28,7 +28,6 @@ const INDEX_FILE: &str = "index.npon";
// TODO, Have timers to see how inefficient my code is
fn main() -> io::Result<()>
{
- #![warn(clippy::pedantic, clippy::perf)]
let (tx, rx) = mpsc::channel();
// File watch thread
thread::spawn(
@@ -36,6 +35,7 @@ fn main() -> io::Result<()>
let mut bytes: Vec;
let mut file_list: Vec;
(bytes, file_list) = files::read_file(INDEX_FILE, 0);
+ //println!("{bytes:?}");
file_list.push(ROOT_DIR.join(INDEX_FILE));
tx.send(bytes.clone()).unwrap();