Skip to content

Commit

Permalink
0.6.5
Browse files Browse the repository at this point in the history
Release 0.6.5
  • Loading branch information
Rinwasyu authored Feb 4, 2020
2 parents 02c6ae5 + 03a0ecd commit 33407ca
Show file tree
Hide file tree
Showing 19 changed files with 515 additions and 88 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
*.geany
*.geany
src/*.d
src/*.o
src/kot
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 0.6.5 (2020-02-05)
- supported command-line option
- supported xterm
- refactored & fixed

## 0.6.4 (2018-11-17)
- supported CentOS etc

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@

Kot is a command-line based text editor.

## Build
```shell
cd src
make clean
make all
```

## License
Copyright 2018 Rinwasyu

Expand Down
42 changes: 42 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#
# Copyright 2019 Rinwasyu
#
# This file is part of kot.
#
# Kot 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, either version 3 of the License, or
# (at your option) any later version.
#
# Kot 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, see <http://www.gnu.org/licenses/>.
#
#

.PHONY: all clean

PROGNAME := kot
CC := gcc
CFLAGS := -O2 -Wall -W -std=c99
LDFLAGS :=
SRCS := $(wildcard *.c)
OBJS := $(SRCS:%.c=%.o)
DEPS := $(SRCS:%.c=%.d)

all: $(PROGNAME)

$(PROGNAME): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $^

%.o: %.c
$(CC) $(CFLAGS) -MD -c $<

clean:
rm -rf *.o *.d

-include $(DEPS)
22 changes: 9 additions & 13 deletions src/cursor.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Rinwasyu
* Copyright 2018,2019 Rinwasyu
*
* This file is part of kot.
*
Expand All @@ -18,17 +18,13 @@
*
*/

struct Cursor {
int col;
int row;
void (*currentPos)(struct Cursor *);
void (*right)(struct Cursor *);
void (*left)(struct Cursor *);
void (*up)(struct Cursor *);
void (*down)(struct Cursor *);
void (*end)(struct Cursor *);
void (*home)(struct Cursor *);
};
#include <stdio.h>
#include <string.h>

#include "cursor.h"
#include "doc.h"
#include "editor.h"
#include "kot.h"

void cursor_currentPos(struct Cursor *cursor) {
printf("\e[%d;%dH", cursor->row + DRAW_TITLEBAR_HEIGHT + 1, cursor->col + 1);
Expand Down Expand Up @@ -141,4 +137,4 @@ struct Cursor cursor = {
cursor_down,
cursor_end,
cursor_home
};
};
53 changes: 53 additions & 0 deletions src/cursor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright 2019 Rinwasyu
*
* This file is part of kot.
*
* Kot 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, either version 3 of the License, or
* (at your option) any later version.
*
* Kot 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, see <http://www.gnu.org/licenses/>.
*
*/

#ifndef KOT_CURSOR_H

#define KOT_CURSOR_H

struct Cursor {
int col;
int row;
void (*currentPos)(struct Cursor *);
void (*right)(struct Cursor *);
void (*left)(struct Cursor *);
void (*up)(struct Cursor *);
void (*down)(struct Cursor *);
void (*end)(struct Cursor *);
void (*home)(struct Cursor *);
};

void cursor_currentPos(struct Cursor *cursor);

void cursor_right(struct Cursor *cursor);

void cursor_left(struct Cursor *cursor);

void cursor_up(struct Cursor *cursor);

void cursor_down(struct Cursor *cursor);

void cursor_end(struct Cursor *cursor);

void cursor_home(struct Cursor *cursor);

struct Cursor cursor;

#endif
17 changes: 7 additions & 10 deletions src/doc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Rinwasyu
* Copyright 2018,2019 Rinwasyu
*
* This file is part of kot.
*
Expand All @@ -18,15 +18,12 @@
*
*/

struct Doc {
int rows;
char **buf;
char *file_name;
void (*init)(struct Doc *);
void (*new)(struct Doc *, char *);
void (*open)(struct Doc *, char *);
void (*save)(struct Doc *);
};
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "doc.h"
#include "kot.h"

void doc_init(struct Doc *doc) {
doc->buf = (char **)malloc(sizeof(char *) * DOC_MAXIMUM_ROWS);
Expand Down
45 changes: 45 additions & 0 deletions src/doc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2019 Rinwasyu
*
* This file is part of kot.
*
* Kot 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, either version 3 of the License, or
* (at your option) any later version.
*
* Kot 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, see <http://www.gnu.org/licenses/>.
*
*/

#ifndef KOT_DOC_H

#define KOT_DOC_H

struct Doc {
int rows;
char **buf;
char *file_name;
void (*init)(struct Doc *);
void (*new)(struct Doc *, char *);
void (*open)(struct Doc *, char *);
void (*save)(struct Doc *);
};

void doc_init(struct Doc *doc);

void doc_new(struct Doc *doc, char *file_name);

void doc_open(struct Doc *doc, char *file_name);

void doc_save(struct Doc *doc);

struct Doc doc;

#endif
21 changes: 11 additions & 10 deletions src/draw.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Rinwasyu
* Copyright 2018,2019 Rinwasyu
*
* This file is part of kot.
*
Expand All @@ -18,14 +18,15 @@
*
*/

struct Draw {
void (*init)();
void (*exit)();
void (*clear)();
void (*titlebar)();
void (*body)();
void (*repaint)(struct Draw *);
};
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "cursor.h"
#include "doc.h"
#include "draw.h"
#include "editor.h"
#include "kot.h"

void draw_init() {
system("stty echo -icanon min 1 time 0");
Expand Down Expand Up @@ -69,4 +70,4 @@ struct Draw draw = {
draw_titlebar,
draw_body,
draw_repaint
};
};
48 changes: 48 additions & 0 deletions src/draw.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2019 Rinwasyu
*
* This file is part of kot.
*
* Kot 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, either version 3 of the License, or
* (at your option) any later version.
*
* Kot 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, see <http://www.gnu.org/licenses/>.
*
*/

#ifndef KOT_DRAW_H

#define KOT_DRAW_H

struct Draw {
void (*init)();
void (*exit)();
void (*clear)();
void (*titlebar)();
void (*body)();
void (*repaint)(struct Draw *);
};

void draw_init();

void draw_exit();

void draw_clear();

void draw_titlebar();

void draw_body();

void draw_repaint(struct Draw *draw);

struct Draw draw;

#endif
14 changes: 7 additions & 7 deletions src/editor.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Rinwasyu
* Copyright 2018,2019 Rinwasyu
*
* This file is part of kot.
*
Expand All @@ -18,13 +18,13 @@
*
*/

struct winsize ws;
#include <sys/ioctl.h>
#include <unistd.h>

#include "editor.h"
#include "kot.h"

struct Editor {
int col;
int row;
int (*fit)();
};
struct winsize ws;

int editor_fit() {
int b_ws_col = ws.ws_col;
Expand Down
Loading

0 comments on commit 33407ca

Please sign in to comment.