/*
* JR_Cursor.c (1.0)
* Console光标的操作
*
* By Eric-JR Chen
* 2011-2-16
*/
#include "JR_Cursor.h"
#include <windows.h>
/* 将光标移到指定位置 */
void JR_SetCursor(int x, int y){
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
COORD pos = {x, y};
SetConsoleCursorPosition(hOut, pos);
}
/* 将光标移到左上角 */
void JR_SetCursorStart(){
JR_SetCursor(0, 0);
}
/* 将光标向右移动N列 */
void JR_SetCursorRight(int n){
COORD pos= {0, 0};
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
PCONSOLE_SCREEN_BUFFER_INFO cinfo = malloc(sizeof(PCONSOLE_SCREEN_BUFFER_INFO));
GetConsoleScreenBufferInfo(hOut, cinfo);
pos.X = cinfo->dwCursorPosition.X + n;
pos.Y = cinfo->dwCursorPosition.Y;
SetConsoleCursorPosition(hOut, pos);
free(cinfo);
}
/* 将光标向左移动N列 */
void JR_SetCursorLeft(int n){
COORD pos= {0, 0};
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
PCONSOLE_SCREEN_BUFFER_INFO cinfo = malloc(sizeof(PCONSOLE_SCREEN_BUFFER_INFO));
GetConsoleScreenBufferInfo(hOut, cinfo);
pos.X = cinfo->dwCursorPosition.X - n;
pos.Y = cinfo->dwCursorPosition.Y;
SetConsoleCursorPosition(hOut, pos);
free(cinfo);
}
/* 将光标向上移动N行 */
void JR_SetCursorUp(int n){
COORD pos= {0, 0};
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
PCONSOLE_SCREEN_BUFFER_INFO cinfo = malloc(sizeof(PCONSOLE_SCREEN_BUFFER_INFO));
GetConsoleScreenBufferInfo(hOut, cinfo);
pos.X = cinfo->dwCursorPosition.X;
pos.Y = cinfo->dwCursorPosition.Y - n;
SetConsoleCursorPosition(hOut, pos);
free(cinfo);
}
/* 将光标向下移动N行 */
void JR_SetCursorDown(int n){
COORD pos= {0, 0};
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
PCONSOLE_SCREEN_BUFFER_INFO cinfo = malloc(sizeof(PCONSOLE_SCREEN_BUFFER_INFO));
GetConsoleScreenBufferInfo(hOut, cinfo);
pos.X = cinfo->dwCursorPosition.X;
pos.Y = cinfo->dwCursorPosition.Y + n;
SetConsoleCursorPosition(hOut, pos);
free(cinfo);
}
可乐崽
- 粉丝: 41
- 资源: 23
最新资源
- GigaDevice.GD32F4xx-DFP.2.1.0 器件安装包
- 智慧校园数字孪生,三维可视化
- 多种土地使用类型图像分类数据集【已标注,约30,000张数据】
- 3.0(1).docx
- 国产文本编辑器:EverEdit用户手册 1.1.0
- 多边形框架物体检测27-YOLO(v5至v11)、COCO、CreateML、Paligemma、TFRecord、VOC数据集合集.rar
- 基于stm32风速风向测量仪V2.0
- 高效排序算法:快速排序Java与Python实现详解
- Metropolis-Hastings算法和吉布斯采样(Gibbs sampling)算法Python代码实现
- IP网络的仿真及实验.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
前往页