📄 vscroll.c
字号:
#include "vscroll.h"int VScroll::InitVScroll(int Y,int X,int Height,int Width,int Color,int FontStyle,int WinType){ if(InitBaseWindow(Y,X,Height,Width,Color,0,FontStyle,WinType,"")==FALSE) return FALSE; if(wintype==VSCROLL_NOBORDER) //draw_box (0,0,Height,Width, COLOR_PAIR(Color)|' ',COLOR_PAIR(Color)); wborder(basewin,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE); else //draw_box (0,0,Height,Width, COLOR_PAIR(Color)|'|',COLOR_PAIR(Color)); wborder(basewin,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE); curs_set(0); posSymbol='#'; curPos=0; wrefresh(basewin); return TRUE;}void VScroll::ReDraw(){ if(wintype==VSCROLL_NOBORDER) //draw_box (0,0,height,width, COLOR_PAIR(color)|' ',COLOR_PAIR(color)); wborder(basewin,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE); else //draw_box (0,0,height,width, COLOR_PAIR(color)|'|',COLOR_PAIR(color)); wborder(basewin,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE); mvwaddch(basewin,curPos,0,posSymbol|A_REVERSE); wrefresh(basewin);}int VScroll::ChangePos(int totalrow,int currow){ int unit=(int)(totalrow/GetHeight())+1; int newpos; if(currow+1==totalrow) newpos=GetHeight()-1; else newpos=(int)(currow/unit); if (curPos==newpos) goto out; //mvwaddch(basewin,curPos,0,COLOR_PAIR(GetColor())|'|'); wborder(basewin,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE,ACS_VLINE); mvwaddch(basewin,newpos,0,posSymbol|A_REVERSE); curPos=newpos; wrefresh(basewin);out: return 1;}int VScroll::ChangePos(){ mvwaddch(basewin,curPos,0,posSymbol|A_REVERSE); wrefresh(basewin); return 1;}int VScroll::GetCurPos(){ return curPos;}int VScroll::ScrollDriver(int key){ int ret=0; switch(key) { case KEY_LEFT: break; case KEY_RIGHT: break; case KEY_UP: if(curPos>0) { curPos--; ChangePos(); } break; case KEY_DOWN: if (curPos<GetHeight()-1) { curPos++; ChangePos(); } break; case KEY_F(8): break; case KEY_ENTER: break; } return ret;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -