📄 q_application.cpp
字号:
#include "qcurses/Q_Application.hpp"//----------------------------------------------------------------------------------------------------------//弹出窗口int Q_Application::POPWin(char *str,char *cap){ WINDOW *POPWin_Form; //基础窗口 Q_Window *POPWin_Win; //操作面板 Q_Button *POPWin_Button[2]; //确定、取消 int RC=0,i=0,j=0,k=0; POPWin_Form = newwin(10,40,8,16); POPWin_Win = new Q_Window(POPWin_Form,10,40,0,0,true,COLOR_WHITE,COLOR_RED); POPWin_Win->SetCaption(cap,COLOR_WHITE,COLOR_RED); POPWin_Button[0] = new Q_Button(POPWin_Win->GetHandle(),7,8,12,COLOR_WHITE,COLOR_RED); POPWin_Button[0]->Set(" 确 定 "); POPWin_Button[1] = new Q_Button(POPWin_Win->GetHandle(),7,8,22,COLOR_WHITE,COLOR_RED); POPWin_Button[1]->Set(" 取 消 "); for (i=0;i<strlen(str);i++) { if (i%34==0 && i!=0) { j++; if (j>POPWin_Form->_maxy-4) break; k=0; } if (str[i]=='\n') continue; mvwprintw(POPWin_Win->GetHandle(),1+j,3+k,"%c",str[i]); k++; } POPWin_Win->Refresh(); while(1) { if (i>1) i=0; POPWin_Button[i]->Get(); if (POPWin_Button[i]->Value) { RC=i+1; break; } i++; } delete POPWin_Button[0]; delete POPWin_Button[1]; delete POPWin_Win; delwin(POPWin_Form); return RC;}//----------------------------------------------------------------------------------------------------------//构造函数Q_Application::Q_Application(char *appname){ _AppName = new char[80]; memset(_AppName,'\0',80); strcpy(_AppName,appname); initscr(); start_color();}//----------------------------------------------------------------------------------------------------------//析构函数Q_Application::~Q_Application(){ delete []_AppName;}//----------------------------------------------------------------------------------------------------------//察看文件大小long Q_Application::get_file_size(char *filename){ struct stat f_stat; if( stat( filename, &f_stat ) == -1 ) return -1; return (long)f_stat.st_size;}//----------------------------------------------------------------------------------------------------------//执行命令bool Q_Application::RunCommand(char *Command,...){ char COMMAND[256]; memset(COMMAND,'\0',256); va_list ap; va_start (ap,Command); if(vsprintf(COMMAND,Command,ap)<0) return(false); va_end(ap); strcat(COMMAND,">.OK 2>.ERR"); system(COMMAND); if(get_file_size(".ERR")>0) return(false); return(true);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -