convert to CMake.
This commit is contained in:
17
CMakeLists.txt
Normal file
17
CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(ke C) # Specify C language explicitly
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(KE_VERSION "0.9.3")
|
||||
|
||||
# Add executable
|
||||
add_executable(ke main.c)
|
||||
|
||||
# Define KE_VERSION for use in C code (e.g., #define KE_VERSION)
|
||||
target_compile_definitions(ke PRIVATE KE_VERSION="${KE_VERSION}")
|
||||
|
||||
# Set output properties
|
||||
set_target_properties(ke PROPERTIES
|
||||
FOLDER bin
|
||||
RUNTIME_OUTPUT_DIRECTORY bin
|
||||
)
|
||||
18
main.c
18
main.c
@@ -181,7 +181,7 @@ init_editor(void)
|
||||
editor.rows = 0;
|
||||
|
||||
if (get_winsz(&editor.rows, &editor.cols) == -1) {
|
||||
die("can't get window size");
|
||||
die("can't get window size - is this an interactive terminal?");
|
||||
}
|
||||
editor.rows--; /* status bar */
|
||||
editor.rows--; /* message line */
|
||||
@@ -225,9 +225,9 @@ reset_editor(void)
|
||||
void
|
||||
ab_append(struct abuf *buf, const char *s, int len)
|
||||
{
|
||||
char *nc = buf->b;
|
||||
int delta = (len < 0) ? 0 : len;
|
||||
int sz;
|
||||
const int delta = (len < 0) ? 0 : len;
|
||||
char *nc = buf->b;
|
||||
int sz;
|
||||
|
||||
assert((delta <= 0 && buf->len < INT_MAX - delta));
|
||||
sz = buf->len + delta;
|
||||
@@ -425,14 +425,14 @@ erow_free(struct erow *row)
|
||||
void
|
||||
die(const char *s)
|
||||
{
|
||||
/*
|
||||
* NOTE(kyle): this is a duplication of the code in display.c
|
||||
* but I would like to be able to import these files from there.
|
||||
*/
|
||||
write(STDOUT_FILENO, "\x1b[2J", 4);
|
||||
write(STDOUT_FILENO, "\x1b[H", 3);
|
||||
|
||||
perror(s);
|
||||
if (errno != 0) {
|
||||
perror(s);
|
||||
} else {
|
||||
fprintf(stderr, "%s\n", s);
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user