tape-kernel 1.0
a modular modern independent kernel
Loading...
Searching...
No Matches
editor.c File Reference
#include "../io/vga.h"
#include "../lib/utils.h"
#include "editor.h"
#include "../io/cm.h"
#include "../fs/fs.h"
#include "../io/kb.h"
#include "../lib/pit.h"
Include dependency graph for editor.c:

Go to the source code of this file.

Macros

#define MAX_LINES   32
#define MAX_LINE_LEN   80

Functions

static void editor_display (const char *filename)
 editor_display renders the editor interface to the screen
static void editor_load (const char *filename)
 editor_load loads a files contents into the editor buffer
static void editor_save (const char *filename)
 editor_save writes the editor buffer to the filesystem
void __editor (const char *filename)
 a simple multiline text editor

Variables

arena_tfs_arena
 the filesystem child arena
static char lines [32][80+1]
static int line_count = 0

Macro Definition Documentation

◆ MAX_LINE_LEN

#define MAX_LINE_LEN   80

Definition at line 11 of file editor.c.

Referenced by __editor(), editor_load(), and editor_save().

◆ MAX_LINES

#define MAX_LINES   32

Definition at line 10 of file editor.c.

Referenced by __editor(), editor_load(), and editor_save().

Function Documentation

◆ __editor()

void __editor ( const char * filename)

a simple multiline text editor

to call this editor simply use

#include "../usr/editor.h" //or simply editor.h
editor(filename); //fill in the file to edit
#define editor
Definition editor.h:4

and it will automatically break back to your loop or func (not exit)

Definition at line 120 of file editor.c.

References clscr, cob, delay, editor_display(), editor_load(), editor_save(), gtchr, line_count, lines, MAX_LINE_LEN, MAX_LINES, NULL, prt, and rdln.

◆ editor_display()

void editor_display ( const char * filename)
static

editor_display renders the editor interface to the screen

editor_display is a static function that clears the screen and draws the editor header, hotkeys bar, and all current lines

Parameters
filename,thename of the file being edited
See also
editor(), editor_load()

Definition at line 27 of file editor.c.

References clscr, cob, line_count, lines, and prt.

Referenced by __editor().

◆ editor_load()

void editor_load ( const char * filename)
static

editor_load loads a files contents into the editor buffer

editor_load is a static function that reads a file from the filesystem and splits its content into lines for editing

Parameters
filename,thename of the file to load
See also
editor_display(), editor_save(), fsread()

Definition at line 50 of file editor.c.

References fsread, line_count, lines, MAX_LINE_LEN, MAX_LINES, and NULL.

Referenced by __editor().

◆ editor_save()

void editor_save ( const char * filename)
static

editor_save writes the editor buffer to the filesystem

editor_save is a static function that joins all lines with newlines and writes the combined content to disk as a file

Parameters
filename,thename of the file to save to
See also
editor_load(), fswrite()

Definition at line 88 of file editor.c.

References fs_arena, fswrite, line_count, lines, MAX_LINE_LEN, MAX_LINES, and prt.

Referenced by __editor().

Variable Documentation

◆ fs_arena

arena_t* fs_arena
extern

the filesystem child arena

fs_arena is a 256kb arena allocated from kheap and used for filesystem operations like storing filenames and file data

See also
kheap, cmd_arena, anew()

Definition at line 56 of file main.c.

◆ line_count

int line_count = 0
static

Definition at line 16 of file editor.c.

Referenced by __editor(), editor_display(), editor_load(), and editor_save().

◆ lines

char lines[32][80+1]
static

Definition at line 15 of file editor.c.

Referenced by __editor(), __shell(), cmd_readfile(), editor_display(), editor_load(), and editor_save().