editor: add nec/nec_bold fonts
This also adds a new "viewport" bit-field, which will be initially be used for incremental search data. Several redundant range checks were removed.
This commit is contained in:
parent
8dd460f48f
commit
0d69d9ea57
8
Makefile
8
Makefile
@ -94,9 +94,15 @@ scsp/sound_cpu__interrupt.elf: scsp/sound_cpu__interrupt.o m68k/interrupt.bin.o
|
|||||||
res/sperrypc.bitmap.bin: tools/ttf-bitmap
|
res/sperrypc.bitmap.bin: tools/ttf-bitmap
|
||||||
./tools/ttf-bitmap 20 7f res/Bm437_SperryPC_CGA.otb $@
|
./tools/ttf-bitmap 20 7f res/Bm437_SperryPC_CGA.otb $@
|
||||||
|
|
||||||
|
res/nec.bitmap.bin: tools/ttf-bitmap
|
||||||
|
./tools/ttf-bitmap 20 7f res/Bm437_NEC_MultiSpeed.otb $@
|
||||||
|
|
||||||
|
res/nec_bold.bitmap.bin: tools/ttf-bitmap
|
||||||
|
./tools/ttf-bitmap 20 7f res/Bm437_NEC_MultiSpeed_bold.otb $@
|
||||||
|
|
||||||
editor/main_saturn.o: common/keyboard.hpp editor/editor.hpp
|
editor/main_saturn.o: common/keyboard.hpp editor/editor.hpp
|
||||||
|
|
||||||
editor/main_saturn.elf: editor/main_saturn.o res/sperrypc.bitmap.bin.o sh/lib1funcs.o common/keyboard.o saturn/start.o
|
editor/main_saturn.elf: editor/main_saturn.o res/nec.bitmap.bin.o res/nec_bold.bitmap.bin.o sh/lib1funcs.o common/keyboard.o saturn/start.o
|
||||||
|
|
||||||
# clean
|
# clean
|
||||||
clean: clean-sh
|
clean: clean-sh
|
||||||
|
@ -23,7 +23,7 @@ struct cursor {
|
|||||||
|
|
||||||
enum struct mode {
|
enum struct mode {
|
||||||
normal,
|
normal,
|
||||||
mark
|
mark,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct selection {
|
struct selection {
|
||||||
@ -49,8 +49,11 @@ inline constexpr bool selection::contains(int32_t col, int32_t row)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
struct buffer {
|
struct buffer {
|
||||||
|
static_assert((C & (C - 1)) == 0);
|
||||||
|
static_assert(C < 32 || C % 32 == 0);
|
||||||
|
|
||||||
line<C> row[R];
|
line<C> row[R];
|
||||||
line<C> * lines[R];
|
line<C> * lines[R];
|
||||||
int32_t length;
|
int32_t length;
|
||||||
@ -64,6 +67,7 @@ struct buffer {
|
|||||||
int32_t cell_height;
|
int32_t cell_height;
|
||||||
int32_t top;
|
int32_t top;
|
||||||
int32_t left;
|
int32_t left;
|
||||||
|
int32_t viewport[V][C < 32 ? 1 : C / 32];
|
||||||
} window;
|
} window;
|
||||||
struct cursor cursor;
|
struct cursor cursor;
|
||||||
struct cursor mark;
|
struct cursor mark;
|
||||||
@ -130,8 +134,8 @@ struct buffer {
|
|||||||
inline constexpr void scroll_new_col(const int32_t col);
|
inline constexpr void scroll_new_col(const int32_t col);
|
||||||
};
|
};
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr buffer<C, R>::buffer(int32_t width, int32_t height)
|
inline constexpr buffer<C, R, V>::buffer(int32_t width, int32_t height)
|
||||||
{
|
{
|
||||||
this->length = 1;
|
this->length = 1;
|
||||||
this->shadow.length = 1;
|
this->shadow.length = 1;
|
||||||
@ -148,14 +152,16 @@ inline constexpr buffer<C, R>::buffer(int32_t width, int32_t height)
|
|||||||
this->lines[i] = nullptr;
|
this->lines[i] = nullptr;
|
||||||
this->shadow.lines[i] = nullptr;
|
this->shadow.lines[i] = nullptr;
|
||||||
|
|
||||||
|
/*
|
||||||
for (int32_t j = 0; j < C; j++) {
|
for (int32_t j = 0; j < C; j++) {
|
||||||
this->row[i].buf[j] = 0x7f;
|
this->row[i].buf[j] = 0x7f;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr line<C> * buffer<C, R>::allocate()
|
inline constexpr line<C> * buffer<C, R, V>::allocate()
|
||||||
{
|
{
|
||||||
line<C> * l;
|
line<C> * l;
|
||||||
while ((l = &this->row[this->alloc_ix])->length != -1) {
|
while ((l = &this->row[this->alloc_ix])->length != -1) {
|
||||||
@ -168,30 +174,29 @@ inline constexpr line<C> * buffer<C, R>::allocate()
|
|||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr void buffer<C, R>::deallocate(line<C> *& l)
|
inline constexpr void buffer<C, R, V>::deallocate(line<C> *& l)
|
||||||
{
|
{
|
||||||
// does not touch alloc_ix
|
// does not touch alloc_ix
|
||||||
fill<uint8_t>(l->buf, 0x7f, l->length);
|
|
||||||
l->length = -1;
|
l->length = -1;
|
||||||
l->refcount = 0;
|
l->refcount = 0;
|
||||||
l = nullptr;
|
l = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr void buffer<C, R>::decref(line<C> *& l)
|
inline constexpr void buffer<C, R, V>::decref(line<C> *& l)
|
||||||
{
|
{
|
||||||
if (l == nullptr) return;
|
if (l == nullptr) return;
|
||||||
else if (l->refcount == 1)
|
else if (l->refcount == 1)
|
||||||
buffer<C, R>::deallocate(l);
|
buffer<C, R, V>::deallocate(l);
|
||||||
else {
|
else {
|
||||||
l->refcount--;
|
l->refcount--;
|
||||||
l = nullptr;
|
l = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr line<C> * buffer<C, R>::dup(line<C> const * const src)
|
inline constexpr line<C> * buffer<C, R, V>::dup(line<C> const * const src)
|
||||||
{
|
{
|
||||||
line<C> * dst = this->allocate();
|
line<C> * dst = this->allocate();
|
||||||
copy(&dst->buf[0], &src->buf[0], src->length);
|
copy(&dst->buf[0], &src->buf[0], src->length);
|
||||||
@ -199,8 +204,8 @@ inline constexpr line<C> * buffer<C, R>::dup(line<C> const * const src)
|
|||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr line<C> * buffer<C, R>::mutref(line<C> *& l)
|
inline constexpr line<C> * buffer<C, R, V>::mutref(line<C> *& l)
|
||||||
{
|
{
|
||||||
if (l == nullptr) {
|
if (l == nullptr) {
|
||||||
l = this->allocate();
|
l = this->allocate();
|
||||||
@ -212,29 +217,29 @@ inline constexpr line<C> * buffer<C, R>::mutref(line<C> *& l)
|
|||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr line<C> * buffer<C, R>::incref(line<C> * l)
|
inline constexpr line<C> * buffer<C, R, V>::incref(line<C> * l)
|
||||||
{
|
{
|
||||||
if (l != nullptr) l->refcount++;
|
if (l != nullptr) l->refcount++;
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr int32_t buffer<C, R>::line_length(line<C> const * const l)
|
inline constexpr int32_t buffer<C, R, V>::line_length(line<C> const * const l)
|
||||||
{
|
{
|
||||||
if (l == nullptr) return 0;
|
if (l == nullptr) return 0;
|
||||||
else return l->length;
|
else return l->length;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr bool buffer<C, R>::put(const uint8_t c)
|
inline constexpr bool buffer<C, R, V>::put(const uint8_t c)
|
||||||
{
|
{
|
||||||
editor::cursor& cur = this->cursor;
|
editor::cursor& cur = this->cursor;
|
||||||
line<C> * l = mutref(this->lines[cur.row]);
|
line<C> * l = mutref(this->lines[cur.row]);
|
||||||
|
|
||||||
// v
|
// v
|
||||||
// 0123
|
// 0123
|
||||||
if (l->length >= C || cur.col >= C || cur.col < 0)
|
if (cur.col >= C)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (l->length > cur.col) {
|
if (l->length > cur.col) {
|
||||||
@ -252,8 +257,8 @@ inline constexpr bool buffer<C, R>::put(const uint8_t c)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr bool buffer<C, R>::delete_forward()
|
inline constexpr bool buffer<C, R, V>::delete_forward()
|
||||||
{
|
{
|
||||||
if (this->mode == mode::mark) {
|
if (this->mode == mode::mark) {
|
||||||
this->mode = mode::normal;
|
this->mode = mode::normal;
|
||||||
@ -262,9 +267,6 @@ inline constexpr bool buffer<C, R>::delete_forward()
|
|||||||
|
|
||||||
editor::cursor& cur = this->cursor;
|
editor::cursor& cur = this->cursor;
|
||||||
|
|
||||||
if (cur.col < 0 || cur.col > C)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (line_length(this->lines[cur.row]) == 0) {
|
if (line_length(this->lines[cur.row]) == 0) {
|
||||||
if (this->length == 1) return false;
|
if (this->length == 1) return false;
|
||||||
decref(this->lines[cur.row]);
|
decref(this->lines[cur.row]);
|
||||||
@ -290,8 +292,8 @@ inline constexpr bool buffer<C, R>::delete_forward()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr bool buffer<C, R>::delete_backward()
|
inline constexpr bool buffer<C, R, V>::delete_backward()
|
||||||
{
|
{
|
||||||
if (this->mode == mode::mark) {
|
if (this->mode == mode::mark) {
|
||||||
this->mode = mode::normal;
|
this->mode = mode::normal;
|
||||||
@ -300,9 +302,6 @@ inline constexpr bool buffer<C, R>::delete_backward()
|
|||||||
|
|
||||||
editor::cursor& cur = this->cursor;
|
editor::cursor& cur = this->cursor;
|
||||||
|
|
||||||
if (cur.col < 0 || cur.col > C)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (cur.col == 0) {
|
if (cur.col == 0) {
|
||||||
if (cur.row == 0) return false;
|
if (cur.row == 0) return false;
|
||||||
// make selection
|
// make selection
|
||||||
@ -329,8 +328,8 @@ inline constexpr bool buffer<C, R>::delete_backward()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr void buffer<C, R>::delete_word_forward()
|
inline constexpr void buffer<C, R, V>::delete_word_forward()
|
||||||
{
|
{
|
||||||
mark_set();
|
mark_set();
|
||||||
cursor_scan_word_forward();
|
cursor_scan_word_forward();
|
||||||
@ -343,8 +342,8 @@ inline constexpr void buffer<C, R>::delete_word_forward()
|
|||||||
this->mode = mode::normal;
|
this->mode = mode::normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr void buffer<C, R>::delete_word_backward()
|
inline constexpr void buffer<C, R, V>::delete_word_backward()
|
||||||
{
|
{
|
||||||
mark_set();
|
mark_set();
|
||||||
cursor_scan_word_backward();
|
cursor_scan_word_backward();
|
||||||
@ -357,8 +356,8 @@ inline constexpr void buffer<C, R>::delete_word_backward()
|
|||||||
this->mode = mode::normal;
|
this->mode = mode::normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr bool buffer<C, R>::cursor_left()
|
inline constexpr bool buffer<C, R, V>::cursor_left()
|
||||||
{
|
{
|
||||||
editor::cursor& cur = this->cursor;
|
editor::cursor& cur = this->cursor;
|
||||||
|
|
||||||
@ -380,8 +379,8 @@ inline constexpr bool buffer<C, R>::cursor_left()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr bool buffer<C, R>::cursor_right()
|
inline constexpr bool buffer<C, R, V>::cursor_right()
|
||||||
{
|
{
|
||||||
editor::cursor& cur = this->cursor;
|
editor::cursor& cur = this->cursor;
|
||||||
|
|
||||||
@ -404,8 +403,8 @@ inline constexpr bool buffer<C, R>::cursor_right()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr bool buffer<C, R>::cursor_up()
|
inline constexpr bool buffer<C, R, V>::cursor_up()
|
||||||
{
|
{
|
||||||
editor::cursor& cur = this->cursor;
|
editor::cursor& cur = this->cursor;
|
||||||
|
|
||||||
@ -421,8 +420,8 @@ inline constexpr bool buffer<C, R>::cursor_up()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr bool buffer<C, R>::cursor_down()
|
inline constexpr bool buffer<C, R, V>::cursor_down()
|
||||||
{
|
{
|
||||||
editor::cursor& cur = this->cursor;
|
editor::cursor& cur = this->cursor;
|
||||||
|
|
||||||
@ -438,8 +437,8 @@ inline constexpr bool buffer<C, R>::cursor_down()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr bool buffer<C, R>::cursor_home()
|
inline constexpr bool buffer<C, R, V>::cursor_home()
|
||||||
{
|
{
|
||||||
editor::cursor& cur = this->cursor;
|
editor::cursor& cur = this->cursor;
|
||||||
cur.col = 0;
|
cur.col = 0;
|
||||||
@ -447,8 +446,8 @@ inline constexpr bool buffer<C, R>::cursor_home()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr bool buffer<C, R>::cursor_end()
|
inline constexpr bool buffer<C, R, V>::cursor_end()
|
||||||
{
|
{
|
||||||
editor::cursor& cur = this->cursor;
|
editor::cursor& cur = this->cursor;
|
||||||
|
|
||||||
@ -464,16 +463,16 @@ static inline constexpr bool word_boundary(int8_t c)
|
|||||||
|| (c >= '0' && c <= '9'));
|
|| (c >= '0' && c <= '9'));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr uint8_t buffer<C, R>::cursor_get(const editor::cursor& cur)
|
inline constexpr uint8_t buffer<C, R, V>::cursor_get(const editor::cursor& cur)
|
||||||
{
|
{
|
||||||
return this->lines[cur.row] == nullptr ? 0 :
|
return this->lines[cur.row] == nullptr ? 0 :
|
||||||
(cur.col == this->lines[cur.row]->length ? '\n' :
|
(cur.col == this->lines[cur.row]->length ? '\n' :
|
||||||
this->lines[cur.row]->buf[cur.col]);
|
this->lines[cur.row]->buf[cur.col]);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr bool buffer<C, R>::cursor_increment(editor::cursor& cur)
|
inline constexpr bool buffer<C, R, V>::cursor_increment(editor::cursor& cur)
|
||||||
{
|
{
|
||||||
if (cur.col >= line_length(this->lines[cur.row])) {
|
if (cur.col >= line_length(this->lines[cur.row])) {
|
||||||
if (cur.row + 1 >= this->length) {
|
if (cur.row + 1 >= this->length) {
|
||||||
@ -488,8 +487,8 @@ inline constexpr bool buffer<C, R>::cursor_increment(editor::cursor& cur)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr void buffer<C, R>::cursor_scan_word_forward()
|
inline constexpr void buffer<C, R, V>::cursor_scan_word_forward()
|
||||||
{
|
{
|
||||||
// copy of this->cursor
|
// copy of this->cursor
|
||||||
editor::cursor cur = this->cursor;
|
editor::cursor cur = this->cursor;
|
||||||
@ -508,8 +507,8 @@ inline constexpr void buffer<C, R>::cursor_scan_word_forward()
|
|||||||
scroll_new_cursor(cur);
|
scroll_new_cursor(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr bool buffer<C, R>::cursor_decrement(editor::cursor& cur)
|
inline constexpr bool buffer<C, R, V>::cursor_decrement(editor::cursor& cur)
|
||||||
{
|
{
|
||||||
if (cur.col == 0) {
|
if (cur.col == 0) {
|
||||||
if (cur.row - 1 < 0) {
|
if (cur.row - 1 < 0) {
|
||||||
@ -524,8 +523,8 @@ inline constexpr bool buffer<C, R>::cursor_decrement(editor::cursor& cur)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr void buffer<C, R>::cursor_scan_word_backward()
|
inline constexpr void buffer<C, R, V>::cursor_scan_word_backward()
|
||||||
{
|
{
|
||||||
// copy of this->cursor
|
// copy of this->cursor
|
||||||
editor::cursor cur = this->cursor;
|
editor::cursor cur = this->cursor;
|
||||||
@ -545,12 +544,12 @@ inline constexpr void buffer<C, R>::cursor_scan_word_backward()
|
|||||||
scroll_new_cursor(cur);
|
scroll_new_cursor(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr bool buffer<C, R>::enter()
|
inline constexpr bool buffer<C, R, V>::enter()
|
||||||
{
|
{
|
||||||
editor::cursor& cur = this->cursor;
|
editor::cursor& cur = this->cursor;
|
||||||
|
|
||||||
if (cur.row >= R || cur.row < 0)
|
if (cur.row >= R)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ((this->length - 1) > cur.row) {
|
if ((this->length - 1) > cur.row) {
|
||||||
@ -570,7 +569,6 @@ inline constexpr bool buffer<C, R>::enter()
|
|||||||
old_l = mutref(old_l);
|
old_l = mutref(old_l);
|
||||||
old_l->length -= new_l->length;
|
old_l->length -= new_l->length;
|
||||||
copy(&new_l->buf[0], &old_l->buf[cur.col], new_l->length);
|
copy(&new_l->buf[0], &old_l->buf[cur.col], new_l->length);
|
||||||
fill<uint8_t>(&old_l->buf[cur.col], 0x7f, new_l->length);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// nothing to do, new_l->length is already 0
|
// nothing to do, new_l->length is already 0
|
||||||
@ -587,8 +585,8 @@ inline constexpr bool buffer<C, R>::enter()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr void buffer<C, R>::line_kill()
|
inline constexpr void buffer<C, R, V>::line_kill()
|
||||||
{
|
{
|
||||||
editor::cursor& cur = this->cursor;
|
editor::cursor& cur = this->cursor;
|
||||||
|
|
||||||
@ -608,16 +606,16 @@ inline constexpr void buffer<C, R>::line_kill()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr void buffer<C, R>::mark_set()
|
inline constexpr void buffer<C, R, V>::mark_set()
|
||||||
{
|
{
|
||||||
this->mark.row = this->cursor.row;
|
this->mark.row = this->cursor.row;
|
||||||
this->mark.col = this->cursor.col;
|
this->mark.col = this->cursor.col;
|
||||||
this->mode = mode::mark;
|
this->mode = mode::mark;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr selection buffer<C, R>::mark_get()
|
inline constexpr selection buffer<C, R, V>::mark_get()
|
||||||
{
|
{
|
||||||
editor::cursor& cur = this->cursor;
|
editor::cursor& cur = this->cursor;
|
||||||
editor::cursor& mark = this->mark;
|
editor::cursor& mark = this->mark;
|
||||||
@ -643,8 +641,8 @@ inline constexpr selection buffer<C, R>::mark_get()
|
|||||||
return sel;
|
return sel;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr void buffer<C, R>::delete_from_line(line<C> *& l,
|
inline constexpr void buffer<C, R, V>::delete_from_line(line<C> *& l,
|
||||||
const int32_t col_start_ix,
|
const int32_t col_start_ix,
|
||||||
const int32_t col_end_ix)
|
const int32_t col_end_ix)
|
||||||
{
|
{
|
||||||
@ -664,8 +662,8 @@ inline constexpr void buffer<C, R>::delete_from_line(line<C> *& l,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr void buffer<C, R>::selection_delete(const selection& sel)
|
inline constexpr void buffer<C, R, V>::selection_delete(const selection& sel)
|
||||||
{
|
{
|
||||||
if (sel.min == sel.max) {
|
if (sel.min == sel.max) {
|
||||||
return;
|
return;
|
||||||
@ -720,8 +718,8 @@ inline constexpr void buffer<C, R>::selection_delete(const selection& sel)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr bool buffer<C, R>::mark_delete()
|
inline constexpr bool buffer<C, R, V>::mark_delete()
|
||||||
{
|
{
|
||||||
const selection sel = mark_get();
|
const selection sel = mark_get();
|
||||||
selection_delete(sel);
|
selection_delete(sel);
|
||||||
@ -732,14 +730,14 @@ inline constexpr bool buffer<C, R>::mark_delete()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr void buffer<C, R>::quit()
|
inline constexpr void buffer<C, R, V>::quit()
|
||||||
{
|
{
|
||||||
this->mode = mode::normal;
|
this->mode = mode::normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr void buffer<C, R>::shadow_clear()
|
inline constexpr void buffer<C, R, V>::shadow_clear()
|
||||||
{
|
{
|
||||||
for (int32_t i = 0; i < this->shadow.length; i++)
|
for (int32_t i = 0; i < this->shadow.length; i++)
|
||||||
decref(this->shadow.lines[i]);
|
decref(this->shadow.lines[i]);
|
||||||
@ -747,8 +745,8 @@ inline constexpr void buffer<C, R>::shadow_clear()
|
|||||||
this->shadow.length = 1;
|
this->shadow.length = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr void buffer<C, R>::_shadow_cow(line<C> * src,
|
inline constexpr void buffer<C, R, V>::_shadow_cow(line<C> * src,
|
||||||
const int32_t dst_row_ix,
|
const int32_t dst_row_ix,
|
||||||
const int32_t col_start_ix,
|
const int32_t col_start_ix,
|
||||||
const int32_t col_end_ix)
|
const int32_t col_end_ix)
|
||||||
@ -765,8 +763,8 @@ inline constexpr void buffer<C, R>::_shadow_cow(line<C> * src,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr bool buffer<C, R>::shadow_copy()
|
inline constexpr bool buffer<C, R, V>::shadow_copy()
|
||||||
{
|
{
|
||||||
if (this->mode != mode::mark)
|
if (this->mode != mode::mark)
|
||||||
return false;
|
return false;
|
||||||
@ -812,8 +810,8 @@ inline constexpr bool buffer<C, R>::shadow_copy()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr bool buffer<C, R>::shadow_cut()
|
inline constexpr bool buffer<C, R, V>::shadow_cut()
|
||||||
{
|
{
|
||||||
if (this->mode != mode::mark)
|
if (this->mode != mode::mark)
|
||||||
return false;
|
return false;
|
||||||
@ -826,8 +824,8 @@ inline constexpr bool buffer<C, R>::shadow_cut()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr void buffer<C, R>::overwrite_line(line<C> *& dst,
|
inline constexpr void buffer<C, R, V>::overwrite_line(line<C> *& dst,
|
||||||
const int32_t dst_col,
|
const int32_t dst_col,
|
||||||
line<C> * src,
|
line<C> * src,
|
||||||
const int32_t src_col)
|
const int32_t src_col)
|
||||||
@ -853,8 +851,8 @@ inline constexpr void buffer<C, R>::overwrite_line(line<C> *& dst,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr bool buffer<C, R>::shadow_paste()
|
inline constexpr bool buffer<C, R, V>::shadow_paste()
|
||||||
{
|
{
|
||||||
if (this->mode == mode::mark)
|
if (this->mode == mode::mark)
|
||||||
this->mode = mode::normal;
|
this->mode = mode::normal;
|
||||||
@ -936,15 +934,15 @@ inline constexpr bool buffer<C, R>::shadow_paste()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr void buffer<C, R>::scroll_up()
|
inline constexpr void buffer<C, R, V>::scroll_up()
|
||||||
{
|
{
|
||||||
if (this->cursor.row < this->window.top)
|
if (this->cursor.row < this->window.top)
|
||||||
this->window.top = this->cursor.row;
|
this->window.top = this->cursor.row;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr void buffer<C, R>::scroll_down()
|
inline constexpr void buffer<C, R, V>::scroll_down()
|
||||||
{
|
{
|
||||||
// 0: a -
|
// 0: a -
|
||||||
// 1: bv -
|
// 1: bv -
|
||||||
@ -957,15 +955,15 @@ inline constexpr void buffer<C, R>::scroll_down()
|
|||||||
this->window.top = (this->cursor.row - (this->window.cell_height - 1));
|
this->window.top = (this->cursor.row - (this->window.cell_height - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr void buffer<C, R>::scroll_left()
|
inline constexpr void buffer<C, R, V>::scroll_left()
|
||||||
{
|
{
|
||||||
if (this->cursor.col < this->window.left)
|
if (this->cursor.col < this->window.left)
|
||||||
this->window.left = this->cursor.col;
|
this->window.left = this->cursor.col;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr void buffer<C, R>::scroll_right()
|
inline constexpr void buffer<C, R, V>::scroll_right()
|
||||||
{
|
{
|
||||||
// 0: a -
|
// 0: a -
|
||||||
// 1: bv -
|
// 1: bv -
|
||||||
@ -978,8 +976,8 @@ inline constexpr void buffer<C, R>::scroll_right()
|
|||||||
this->window.left = (this->cursor.col - (this->window.cell_width - 1));
|
this->window.left = (this->cursor.col - (this->window.cell_width - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr void buffer<C, R>::scroll_new_cursor(const editor::cursor& oth)
|
inline constexpr void buffer<C, R, V>::scroll_new_cursor(const editor::cursor& oth)
|
||||||
{
|
{
|
||||||
editor::cursor& cur = this->cursor;
|
editor::cursor& cur = this->cursor;
|
||||||
|
|
||||||
@ -990,8 +988,8 @@ inline constexpr void buffer<C, R>::scroll_new_cursor(const editor::cursor& oth)
|
|||||||
else { cur.col = oth.col; scroll_left(); }
|
else { cur.col = oth.col; scroll_left(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int C, int R>
|
template <int C, int R, int V>
|
||||||
inline constexpr void buffer<C, R>::scroll_new_col(const int32_t col)
|
inline constexpr void buffer<C, R, V>::scroll_new_col(const int32_t col)
|
||||||
{
|
{
|
||||||
editor::cursor& cur = this->cursor;
|
editor::cursor& cur = this->cursor;
|
||||||
|
|
||||||
|
@ -12,9 +12,10 @@
|
|||||||
|
|
||||||
#include "editor.hpp"
|
#include "editor.hpp"
|
||||||
|
|
||||||
extern void * _sperrypc_bitmap_start __asm("_binary_res_sperrypc_bitmap_bin_start");
|
extern void * _nec_bitmap_start __asm("_binary_res_nec_bitmap_bin_start");
|
||||||
|
extern void * _nec_bold_bitmap_start __asm("_binary_res_nec_bold_bitmap_bin_start");
|
||||||
|
|
||||||
using buffer_type = editor::buffer<64, 64>;
|
using buffer_type = editor::buffer<64, 64, 40>;
|
||||||
constexpr int32_t viewport_max_col = 320 / 8;
|
constexpr int32_t viewport_max_col = 320 / 8;
|
||||||
constexpr int32_t viewport_max_row = 240 / 8;
|
constexpr int32_t viewport_max_row = 240 / 8;
|
||||||
|
|
||||||
@ -62,12 +63,16 @@ namespace pix_fmt_4bpp
|
|||||||
|
|
||||||
void cell_data()
|
void cell_data()
|
||||||
{
|
{
|
||||||
const uint8_t * buf = reinterpret_cast<uint8_t*>(&_sperrypc_bitmap_start);
|
const uint8_t * normal = reinterpret_cast<uint8_t*>(&_nec_bitmap_start);
|
||||||
|
const uint8_t * bold = reinterpret_cast<uint8_t*>(&_nec_bold_bitmap_start);
|
||||||
|
|
||||||
for (int ix = 0; ix <= (0x7f - 0x20); ix++) {
|
for (int ix = 0; ix <= (0x7f - 0x20); ix++) {
|
||||||
for (int y = 0; y < 8; y++) {
|
for (int y = 0; y < 8; y++) {
|
||||||
uint8_t row = buf[ix * 8 + y];
|
const uint8_t row_n = normal[ix * 8 + y];
|
||||||
vdp2.vram.u32[(ix * 8) + y] = pix_fmt_4bpp::bits(row);
|
vdp2.vram.u32[ 0 + (ix * 8) + y] = pix_fmt_4bpp::bits(row_n);
|
||||||
|
|
||||||
|
const uint8_t row_b = bold[ix * 8 + y];
|
||||||
|
vdp2.vram.u32[96 + (ix * 8) + y] = pix_fmt_4bpp::bits(row_b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ using namespace editor;
|
|||||||
|
|
||||||
static void test_allocate()
|
static void test_allocate()
|
||||||
{
|
{
|
||||||
buffer<8, 4> b {4, 2};
|
buffer<8, 4, 4> b {4, 2};
|
||||||
decltype(b)::line_type * l;
|
decltype(b)::line_type * l;
|
||||||
|
|
||||||
assert(b.row[0].length == -1);
|
assert(b.row[0].length == -1);
|
||||||
@ -62,7 +62,7 @@ static void test_put()
|
|||||||
{
|
{
|
||||||
// v
|
// v
|
||||||
// "as" -> "abs"
|
// "as" -> "abs"
|
||||||
buffer<8, 4> b {4, 2};
|
buffer<8, 4, 4> b {4, 2};
|
||||||
decltype(b)::line_type * l;
|
decltype(b)::line_type * l;
|
||||||
|
|
||||||
assert(b.cursor.col == 0);
|
assert(b.cursor.col == 0);
|
||||||
@ -101,7 +101,7 @@ static void test_put()
|
|||||||
|
|
||||||
void test_backspace()
|
void test_backspace()
|
||||||
{
|
{
|
||||||
buffer<8, 4> b {4, 2};
|
buffer<8, 4, 4> b {4, 2};
|
||||||
decltype(b)::line_type * l;
|
decltype(b)::line_type * l;
|
||||||
|
|
||||||
b.put('a');
|
b.put('a');
|
||||||
@ -137,7 +137,7 @@ void test_enter()
|
|||||||
// [0] as
|
// [0] as
|
||||||
// [1] Df
|
// [1] Df
|
||||||
// [2] qwer
|
// [2] qwer
|
||||||
buffer<8, 4> b {4, 2};
|
buffer<8, 4, 4> b {4, 2};
|
||||||
|
|
||||||
b.cursor.row = 0;
|
b.cursor.row = 0;
|
||||||
b.cursor.col = 0;
|
b.cursor.col = 0;
|
||||||
@ -191,7 +191,7 @@ void test_enter_backspace1()
|
|||||||
// ab
|
// ab
|
||||||
// cd
|
// cd
|
||||||
|
|
||||||
buffer<8, 4> b {4, 2};
|
buffer<8, 4, 4> b {4, 2};
|
||||||
|
|
||||||
b.put('a');
|
b.put('a');
|
||||||
b.put('b');
|
b.put('b');
|
||||||
@ -216,7 +216,7 @@ void test_enter_backspace1()
|
|||||||
|
|
||||||
void test_enter_backspace2()
|
void test_enter_backspace2()
|
||||||
{
|
{
|
||||||
buffer<8, 4> b {4, 2};
|
buffer<8, 4, 4> b {4, 2};
|
||||||
|
|
||||||
b.put('a');
|
b.put('a');
|
||||||
b.enter();
|
b.enter();
|
||||||
@ -231,7 +231,7 @@ void test_enter_backspace2()
|
|||||||
|
|
||||||
void test_enter_scroll()
|
void test_enter_scroll()
|
||||||
{
|
{
|
||||||
buffer<8, 4> b {4, 2};
|
buffer<8, 4, 4> b {4, 2};
|
||||||
|
|
||||||
assert(b.window.top == 0);
|
assert(b.window.top == 0);
|
||||||
b.put('a');
|
b.put('a');
|
||||||
@ -253,7 +253,7 @@ void test_enter_scroll()
|
|||||||
|
|
||||||
void test_first_enter()
|
void test_first_enter()
|
||||||
{
|
{
|
||||||
buffer<8, 4> b {4, 2};
|
buffer<8, 4, 4> b {4, 2};
|
||||||
|
|
||||||
b.enter();
|
b.enter();
|
||||||
assert(b.length == 2);
|
assert(b.length == 2);
|
||||||
@ -266,7 +266,7 @@ void test_enter_backspace3()
|
|||||||
//
|
//
|
||||||
// b
|
// b
|
||||||
|
|
||||||
buffer<8, 8> b {4, 2};
|
buffer<8, 8, 8> b {4, 2};
|
||||||
|
|
||||||
b.put('a');
|
b.put('a');
|
||||||
b.enter();
|
b.enter();
|
||||||
@ -303,7 +303,7 @@ void test_copy()
|
|||||||
// qwer
|
// qwer
|
||||||
// j
|
// j
|
||||||
|
|
||||||
buffer<8, 8> b {4, 2};
|
buffer<8, 8, 8> b {4, 2};
|
||||||
|
|
||||||
b.put('a');
|
b.put('a');
|
||||||
b.put('s');
|
b.put('s');
|
||||||
@ -357,7 +357,7 @@ void test_copy()
|
|||||||
|
|
||||||
void test_copy_same_line()
|
void test_copy_same_line()
|
||||||
{
|
{
|
||||||
buffer<8, 8> b {4, 2};
|
buffer<8, 8, 8> b {4, 2};
|
||||||
|
|
||||||
// v
|
// v
|
||||||
// asdF
|
// asdF
|
||||||
@ -394,7 +394,7 @@ void test_copy_same_line()
|
|||||||
|
|
||||||
void test_copy_multi_line_cow()
|
void test_copy_multi_line_cow()
|
||||||
{
|
{
|
||||||
buffer<8, 8> b {4, 2};
|
buffer<8, 8, 8> b {4, 2};
|
||||||
|
|
||||||
// v
|
// v
|
||||||
// asdF
|
// asdF
|
||||||
@ -422,7 +422,7 @@ void test_copy_multi_line_cow()
|
|||||||
|
|
||||||
void test_copy_multi_line_offset()
|
void test_copy_multi_line_offset()
|
||||||
{
|
{
|
||||||
buffer<8, 8> b {4, 2};
|
buffer<8, 8, 8> b {4, 2};
|
||||||
|
|
||||||
b.put('a');
|
b.put('a');
|
||||||
b.put('s');
|
b.put('s');
|
||||||
@ -477,7 +477,7 @@ void test_copy_multi_line_offset()
|
|||||||
|
|
||||||
void test_delete_from_line()
|
void test_delete_from_line()
|
||||||
{
|
{
|
||||||
buffer<8, 8> b {4, 2};
|
buffer<8, 8, 8> b {4, 2};
|
||||||
|
|
||||||
b.put('a');
|
b.put('a');
|
||||||
b.put('s');
|
b.put('s');
|
||||||
@ -499,7 +499,7 @@ void test_delete_from_line()
|
|||||||
|
|
||||||
void test_selection_delete()
|
void test_selection_delete()
|
||||||
{
|
{
|
||||||
buffer<8, 8> b {4, 2};
|
buffer<8, 8, 8> b {4, 2};
|
||||||
|
|
||||||
b.put('s');
|
b.put('s');
|
||||||
b.put('p');
|
b.put('p');
|
||||||
@ -563,7 +563,7 @@ void test_selection_delete()
|
|||||||
|
|
||||||
void test_shadow_paste_oneline()
|
void test_shadow_paste_oneline()
|
||||||
{
|
{
|
||||||
buffer<8, 8> b {4, 2};
|
buffer<8, 8, 8> b {4, 2};
|
||||||
|
|
||||||
b.put('q');
|
b.put('q');
|
||||||
b.put('w');
|
b.put('w');
|
||||||
@ -636,7 +636,7 @@ void test_shadow_paste_oneline()
|
|||||||
|
|
||||||
void test_shadow_paste_multiline()
|
void test_shadow_paste_multiline()
|
||||||
{
|
{
|
||||||
buffer<8, 8> b {4, 2};
|
buffer<8, 8, 8> b {4, 2};
|
||||||
|
|
||||||
// (qw
|
// (qw
|
||||||
// er
|
// er
|
||||||
@ -733,7 +733,7 @@ void test_shadow_paste_multiline()
|
|||||||
|
|
||||||
void test_delete_forward()
|
void test_delete_forward()
|
||||||
{
|
{
|
||||||
buffer<8, 8> b {4, 2};
|
buffer<8, 8, 8> b {4, 2};
|
||||||
b.put('a');
|
b.put('a');
|
||||||
b.put('b');
|
b.put('b');
|
||||||
b.put('c');
|
b.put('c');
|
||||||
@ -765,7 +765,7 @@ void test_delete_forward()
|
|||||||
|
|
||||||
void test_delete_word_backward()
|
void test_delete_word_backward()
|
||||||
{
|
{
|
||||||
buffer<8, 8> b {4, 2};
|
buffer<8, 8, 8> b {4, 2};
|
||||||
|
|
||||||
b.put('q');
|
b.put('q');
|
||||||
b.put('w');
|
b.put('w');
|
||||||
|
BIN
res/Bm437_NEC_MultiSpeed.otb
Normal file
BIN
res/Bm437_NEC_MultiSpeed.otb
Normal file
Binary file not shown.
BIN
res/Bm437_NEC_MultiSpeed_bold.otb
Normal file
BIN
res/Bm437_NEC_MultiSpeed_bold.otb
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user