Assembled 2
A column based text editor
Loading...
Searching...
No Matches
Functions
buffer.c File Reference
#include <editor/buffer/editor.h>
#include <editor/buffer/buffer.h>
#include <interface/interface.h>
#include <global.h>
#include <includes.h>
#include <string.h>

Functions

void free_line_list_element (struct AS_LLElement *element)
 
struct AS_TextBufnew_buffer (int col_start, int col_end)
 
void destroy_buffer (struct AS_TextBuf *buffer)
 
void buffer_char_insert (char c)
 
void buffer_char_del ()
 
int buffer_move_ln_up (struct AS_TextBuf *active_buffer)
 
int buffer_move_ln_down (struct AS_TextBuf *active_buffer)
 

Detailed Description

Author
awewsomegamer awews.nosp@m.omeg.nosp@m.amer@.nosp@m.gmai.nosp@m.l.com

LICENSE

Assembled - Column based text editor Copyright (C) 2023-2024 awewsomegamer

This file is apart of Assembled.

Assembled is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

DESCRIPTION

This file handles actions related to struct AS_TextBufs, such as character insertion and deletion.

Function Documentation

◆ buffer_char_del()

void buffer_char_del ( )

Deletes the current character.

Deletes the current character in as_ctx.text_file->active_buffer->current_element. If current_element is completely empty, then it will be deleted.

◆ buffer_char_insert()

void buffer_char_insert ( char c)

Inserts a new character into the active buffer.

Insert the given character into as_ctx.text_file->active_buffer->current_element.

Parameters
charc - The character to be inserted. If it is '\n', then a new struct AS_LLElement will be inserted.

◆ buffer_move_ln_down()

int buffer_move_ln_down ( struct AS_TextBuf * active_buffer)

Moves the current line in the given buffer down.

Parameters
structAS_TextBuf *active_buffer - The buffer in which to move active_buffer->current_element down one.
Returns
Returns the number of lines moved down (0: if the function failed).

◆ buffer_move_ln_up()

int buffer_move_ln_up ( struct AS_TextBuf * active_buffer)

Moves the current line in the given buffer up.

Parameters
structAS_TextBuf *active_buffer - The buffer in which to move active_buffer->current_element up one.
Returns
Returns the number of lines moved up (0: if the function failed).

◆ destroy_buffer()

void destroy_buffer ( struct AS_TextBuf * buffer)

Frees a struct AS_TextBuf

Parameters
structAS_TextBUf *buffer - The buffer to be freed.

◆ free_line_list_element()

void free_line_list_element ( struct AS_LLElement * element)

Function to free a struct AS_LLElement

Parameters
element- Pointer to the element to be freed
Returns
void

◆ new_buffer()

struct AS_TextBuf * new_buffer ( int col_start,
int col_end )

Creates a new struct AS_TextBuf

Creates a new, and initializes all fields of a new struct AS_TextBuf.

Parameters
intcol_start - The 0-based index where the buffer's column starts
intcol_end - The 0-based index where the buffer's column ends
Returns
The pointer to the struct AS_TextBuf