📄 move.c
字号:
#include "zped.h"
#include "myExternal.h"
long int whereisX()
{
int i;
int n;
for(n = 0; current_x - (COLS-3)-n*((COLS-4)-3) > 0; n++) ;
if(n == 0) {
return current_x;
}
return current_x-(COLS-3)-(n-1)*((COLS-4)-3)+5;
}
bool do_left()
{
long int cursor_x;
move_x = current_x;
if(current_x > 0) {
current_x--;
move_x--;
cursor_x = whereisX();
wmove(edit,cursor_y,cursor_x);
} else {
return 0;
}
return 1;
}
bool do_right()
{
long int cursor_x;
long int number = 0;
move_x = current_x;
if(current_R == fileBot) {
number = current_R->num;
} else {
number = current_R->num-1;
}
if(number > current_x) {
current_x++;
move_x++;
cursor_x = whereisX();
wmove(edit,cursor_y,cursor_x);
} else {
return 0;
}
return 1;
}
bool do_up()
{
long int cursor_x;
int count = 0;
if(current_R == fileTop) {
return 0;
} else if(current_R == editTop) {
while(count < (LINES-3)/2 && editTop != fileTop) {
editTop = editTop->pre;
cursor_y++;
count++;
}
if(count < (LINES-3)/2) {
current_R = current_R->pre;
cursor_y--;
}
else {
editTop = editTop->pre;
current_R = current_R->pre;
}
} else {
current_R = current_R->pre;
cursor_y--;
}
if(current_R->num-1 < move_x) {
current_x = current_R->num-1;
} else
current_x = move_x;
cursor_x = whereisX();
current_y--;
wmove(edit,cursor_y,cursor_x);
return 1;
}
bool do_down()
{
long int cursor_x;
long int number;
int count = 0;
if(current_R == fileBot) {
return 0;
} else if(cursor_y == LINES-3) {
while(count < (LINES-3)/2 && editTop != fileBot) {
editTop = editTop->next;
count++;
cursor_y--;
}
if(count < (LINES-3)/2) {
current_R = current_R->next;
cursor_y++;
} else {
editTop = editTop->next;
current_R = current_R->next;
}
} else {
current_R = current_R->next;
cursor_y++;
}
if(current_R == fileBot) {
number = current_R->num;
} else {
number = current_R->num-1;
}
if(number < move_x) {
current_x = number;
} else
current_x = move_x;
cursor_x = whereisX();
current_y++;
wmove(edit,cursor_y,cursor_x);
return 1;
}
bool do_home()
{
current_x = 0;
move_x = current_x;
wmove(edit,cursor_y,current_x);
return 1;
}
bool do_end()
{
int cursor_x;
if(current_R == fileBot)
current_x = current_R->num;
else
current_x = current_R->num-1;
cursor_x = whereisX();
move_x = current_x;
wmove(edit,cursor_y,cursor_x);
return 1;
}
bool do_pageup()
{
long count = 0;
int cursor_x = 0;
while(count < LINES-2 && current_R != fileTop) {
current_R = current_R->pre;
count++;
current_y--;
}
editTop = current_R;
if(current_R->num-1 < move_x) {
current_x = current_R->num-1;
} else
current_x = move_x;
cursor_y = 0;
cursor_x = whereisX();
wmove(edit,cursor_y,cursor_x);
return 1;
}
bool do_pagedown()
{
long count = 0;
long number = 0;
int cursor_x = 0;
while(count < LINES-3 && current_R != fileBot) {
current_R = current_R->next;
count++;
current_y++;
}
editTop = current_R;
if(current_R == fileBot) {
number = current_R->num;
} else {
number = current_R->num-1;
}
if(number < move_x) {
current_x = number;
} else
current_x = move_x;
cursor_y = 0;
cursor_x = whereisX();
wmove(edit,cursor_y,cursor_x);
return 1;
}
bool do_back_word()
{
return 1;
}
bool do_end_word()
{
return 1;
}
bool do_go_to_line(long lineNum)
{
long count = 0;
Rnode * Rtemp;
Rtemp = fileTop;
if(lineNum > totalLine)
lineNum = totalLine-1;
while(count < lineNum) {
Rtemp = Rtemp->next;
count++;
}
if(lineNum < LINES-3) {
editTop = fileTop;
current_y = lineNum;
current_x = 0;
cursor_y = lineNum;
current_R = Rtemp;
} else {
count = 0;
current_R = Rtemp;
while(count < (LINES-3)/2) {
Rtemp = Rtemp->pre;
count++;
}
editTop = Rtemp;
current_y = lineNum;
cursor_y = (LINES-3)/2;
current_x = 0;
}
wmove(edit,cursor_y,0);
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -