Assembled 2
A column based text editor
Loading...
Searching...
No Matches
Classes | Macros | Functions
interface.h File Reference
#include <includes.h>

Go to the source code of this file.

Classes

struct  AS_Bound
 
struct  AS_RenderCtx
 
struct  AS_Screen
 

Macros

#define AS_MAX_SCREEN_COUNT   256
 Maximum number of screens.
 
#define GET_SCR_IDX(name)   (general_hash(name) % AS_MAX_SCREEN_COUNT)
 Retrieve the index of a screen in the hashmap.
 
#define LOCAL_ARROW_YMOVE   0
 Local function code to move the cursor in the Y axis.
 
#define LOCAL_ARROW_XMOVE   1
 Local function code to move the cursor in the X axis.
 
#define LOCAL_ENTER   2
 Local function code when the user has pressed the enter key.
 
#define LOCAL_LINE_INSERT   3
 Local function code when a line has been inserted by buffer.c.
 
#define LOCAL_LINE_DELETION   4
 Local function code when a line has been removed by buffer.c.
 
#define LOCAL_BUFFER_MOVE   5
 Local function code when the user moves to another buffer.
 
#define LOCAL_BUFFER_CHAR   6
 Local function code when the user inserts a character.
 
#define LOCAL_WINDOW_MOVE   7
 Local function code when the user moves to another file.
 
#define LOCAL_WINDOW_SELECTION   8
 Local function when the user starts a selection.
 
#define LOCAL_BUFFER_MOVE_LINE   9
 Local function when the user moves a line.
 
#define LOCAL_FILE_LOAD   10
 Local function when the user wants to load a file.
 
#define LOCAL_FILE_SAVE   11
 Local function when the user wants to save the file.
 
#define LOCAL_COLDESC_SWITCH   12
 Local function code when the user wants to switch column descriptors (layouts).
 
#define IN_BOUND(x, y, bound)
 Determine if given coordinate is inside given bounding box.
 
#define SCR_OPT_ON_UPDATE   (1 << 0)
 
#define SCR_OPT_ALWAYS   (1 << 1)
 

Functions

int switch_to_screen (char *name)
 
int switch_to_last_screen ()
 
int register_screen (char *name, void(*render)(struct AS_RenderCtx *), void(*update)(struct AS_RenderCtx *), void(*local)(int, int))
 
void draw_border (struct AS_Bound bound)
 

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

The screen manager.

Macro Definition Documentation

◆ IN_BOUND

#define IN_BOUND ( x,
y,
bound )
Value:
(x >= bound.x && x <= bound.x + bound.w) && \
(y >= bound.y && y <= bound.y + bound.h)

Determine if given coordinate is inside given bounding box.

◆ SCR_OPT_ALWAYS

#define SCR_OPT_ALWAYS   (1 << 1)

The screen should update always.

This value is in AS_Screen.render_options.

◆ SCR_OPT_ON_UPDATE

#define SCR_OPT_ON_UPDATE   (1 << 0)

The screen should update only when there is new user input.

This value is in AS_Screen.render_options.

Function Documentation

◆ draw_border()

void draw_border ( struct AS_Bound bound)

Utility function to draw a border around a given boundary

Parameters
structAS_Bound bound - The boundary around which to draw the border.

◆ register_screen()

int register_screen ( char * name,
void(*)(struct AS_RenderCtx *) render,
void(*)(struct AS_RenderCtx *) update,
void(*)(int, int) local )

Registers a screen in the hashmap.

The following initializes an entry in the hashmap with the given arguments. The index within the hashmap is calculated using the name parameter.

Parameters
char*name - The string by which to calculate the index within the hashmap
void(*render)(struct AS_RenderCtx *) - The render function of the screen.
void(*update)(struct AS_RenderCtx *) - The update function of the screen.
void(*local)(int, int) - The local function of the screen.

◆ switch_to_last_screen()

int switch_to_last_screen ( )

Switches to the last screen.

The function flips the as_ctx.screen and the internal last_screen pointers.

Returns
The index of the screen in the hashmap.

◆ switch_to_screen()

int switch_to_screen ( char * name)

Switch to the given screen

Change as_ctx.screen to the screen found at the given name in the screens hashmap.

Parameters
char*name - The name of the screen to switch to.
Returns
The index of the screen in the hashmap.