+/Femto
toy text editor
git clone https://git.julia.blue/+/Femto
bc37ee9
master
1#ifndef FILEIO_H 2#define FILEIO_H 3 4#define _DEFAULT_SOURCE 5#define _BSD_SOURCE 6#define _GNU_SOURCE 7 8#include <fcntl.h> 9#include <stdio.h> 10#include <stdlib.h> 11#include <string.h> 12#include <sys/types.h> 13#include <unistd.h> 14 15#include "editor.h" 16#include "terminal.h" 17 18/** 19* Loads a file into the editor, removing newlines and tabs. If filename 20* doesn't exist, empties the editor. 21* @param filename relative path to file to be opened 22*/ 23void openFile (char * filename ); 24 25/** 26* Attempts to write the editor's contents to a file. If the current file 27* hasn't been named yet the user is prompted to do so. A message is displayed 28* with the success or failure of the operation. 29*/ 30void saveFile (); 31 32/** 33* Concatenates the contents of the editor to a single string in preparation to 34* write to a file, re-adding newlines. 35* @param buflen length of the resulting string 36* @return resulting string 37*/ 38char * joinRows (int * buflen ); 39 40/** 41* Examines the extension of the current file to determine its type and if 42* recognized, sets the editor's syntax highlighting to that language. 43*/ 44void detectLang (); 45 46/** 47* Replaces literal tabs with spaces in a string. 48* @param in input string 49* @param len input string length 50* @param out output string 51* @return output string length 52*/ 53ssize_t removeTabs (char * in ,ssize_t len ,char ** out ); 54 55#endif