| 
					
				 | 
			
			
				@@ -27,7 +27,7 @@ static atomic_bool running = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 static thrd_t readThread = {0}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 static struct termios original; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-static CoreQueue buffer = {0}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+static Queue buffer = {0}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 static ConsoleLine currentBuffer = {0}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 static int move = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 static int cursorMove = 0; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -40,14 +40,13 @@ static int historyLength = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 static void getAttributes(struct termios* t) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if(tcgetattr(STDIN_FILENO, t)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CORE_LOG_WARNING("cannot get terminal attributes"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LOG_WARNING("cannot get terminal attributes"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 static void restoreAttributes() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if(tcsetattr(STDIN_FILENO, TCSAFLUSH, &original)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CORE_LOG_WARNING("cannot restore terminal attributes: %s", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                         strerror(errno)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LOG_WARNING("cannot restore terminal attributes: %s", strerror(errno)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -103,20 +102,20 @@ static void addToHistory() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 static void lock() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if(mtx_lock(&bufferMutex) != thrd_success || MUTEX_LOCK_FAIL) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CORE_LOG_WARNING("could not lock buffer mutex"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LOG_WARNING("could not lock buffer mutex"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 static void unlock() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if(mtx_unlock(&bufferMutex) != thrd_success || MUTEX_UNLOCK_FAIL) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CORE_LOG_WARNING("could not unlock buffer mutex"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LOG_WARNING("could not unlock buffer mutex"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 static void addLine() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     addToHistory(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     lock(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    corePushQueueData(&buffer, ¤tBuffer); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    pushQueueData(&buffer, ¤tBuffer); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     unlock(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     clear(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -247,7 +246,7 @@ static int loop(void* data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-bool coreStartReadLine(void) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+bool startReadLine(void) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // https://viewsourcecode.org/snaptoken/kilo/02.enteringRawMode.html 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     getAttributes(&original); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     struct termios raw = original; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -257,40 +256,40 @@ bool coreStartReadLine(void) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     raw.c_cc[VTIME] = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if(tcsetattr(STDIN_FILENO, TCSANOW, &raw)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CORE_LOG_WARNING("cannot set terminal attributes"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LOG_WARNING("cannot set terminal attributes"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    coreInitQueue(&buffer, 10, sizeof(ConsoleLine)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    initQueue(&buffer, 10, sizeof(ConsoleLine)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     atomic_store(&running, true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if(MUTEX_INIT_FAIL || mtx_init(&bufferMutex, mtx_plain) != thrd_success) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CORE_LOG_ERROR("cannot init buffer mutex"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        coreStopReadLine(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LOG_ERROR("cannot init buffer mutex"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        stopReadLine(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } else if(THREAD_INIT_FAIL || 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               thrd_create(&readThread, loop, nullptr) != thrd_success) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CORE_LOG_ERROR("cannot start read thread"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        coreStopReadLine(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LOG_ERROR("cannot start read thread"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        stopReadLine(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-bool coreReadLine(char* buffer_, size_t n) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+bool readLine(char* buffer_, size_t n) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if(buffer.length == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     lock(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ConsoleLine* line = coreGetQueueIndex(&buffer, 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ConsoleLine* line = getQueueIndex(&buffer, 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     snprintf(buffer_, n, "%s", line->data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    corePopQueueData(&buffer); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    popQueueData(&buffer); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     unlock(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-void coreStopReadLine() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void stopReadLine() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     atomic_store(&running, false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     thrd_join(readThread, nullptr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     restoreAttributes(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    coreDestroyQueue(&buffer); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    destroyQueue(&buffer); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     mtx_destroy(&bufferMutex); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |