Browse Source

updated formatting

Kajetan Johannes Hammerle 3 years ago
parent
commit
cb7d86c2f6
4 changed files with 13 additions and 22 deletions
  1. 1 2
      .gitignore
  2. 1 1
      Main.cpp
  3. 1 1
      Makefile
  4. 10 18
      RawReader.h

+ 1 - 2
.gitignore

@@ -1,2 +1 @@
-raw_terminal
-nbproject
+raw_terminal

+ 1 - 1
Main.cpp

@@ -1,5 +1,5 @@
-#include <iostream>
 #include <cstring>
+#include <iostream>
 
 #include "RawReader.h"
 

+ 1 - 1
Makefile

@@ -7,4 +7,4 @@ raw_terminal: Main.cpp RawReader.h
 	g++ -o $@ Main.cpp -Wall -Wextra -Werror -pedantic
 
 clean:
-	rm -f raw_terminal
+	rm -f raw_terminal

+ 10 - 18
RawReader.h

@@ -10,25 +10,26 @@
 template<int N, int H>
 class RawReader final {
     struct termios original;
-    
+
     int index;
     char buffer[2][N];
     bool bufferIndex;
     bool noError;
     int move;
-    
+
     char history[H][N];
     int historyOffset;
     int historyIndex;
     int historyLength;
-    
+
     const char* prefix;
 
 public:
     typedef int DeciSeconds;
 
-    RawReader(DeciSeconds timeout, const char* prefix) : index(0), bufferIndex(false), noError(true), move(0),
-    historyOffset(0), historyIndex(0), historyLength(0), prefix(prefix) {
+    RawReader(DeciSeconds timeout, const char* prefix)
+        : index(0), bufferIndex(false), noError(true), move(0), historyOffset(0), historyIndex(0), historyLength(0),
+          prefix(prefix) {
         // https://viewsourcecode.org/snaptoken/kilo/02.enteringRawMode.html
         if(tcgetattr(STDIN_FILENO, &original) == -1) {
             markError();
@@ -101,7 +102,6 @@ public:
     }
 
 private:
-
     void print(const char* s) {
         fputs(s, stdout);
     }
@@ -183,18 +183,10 @@ private:
             return;
         }
         switch(readChar()) {
-            case 'A':
-                handleUpArrow();
-                break;
-            case 'B':
-                handleDownArrow();
-                break;
-            case 'C':
-                handleRightArrow();
-                break;
-            case 'D':
-                handleLeftArrow();
-                break;
+            case 'A': handleUpArrow(); break;
+            case 'B': handleDownArrow(); break;
+            case 'C': handleRightArrow(); break;
+            case 'D': handleLeftArrow(); break;
         }
     }