Add mouse an auto adaptation of the windows size
This commit is contained in:
parent
ba88773d13
commit
9ac121993d
@ -84,7 +84,10 @@ void showConfiguration(void)
|
|||||||
showType_te myType = getType();
|
showType_te myType = getType();
|
||||||
showTypeSize_te mySize = getTypeSize();
|
showTypeSize_te mySize = getTypeSize();
|
||||||
|
|
||||||
|
// TODO : Redraw periodicly
|
||||||
|
//CleanDisplay();
|
||||||
printf(GO_TOP);
|
printf(GO_TOP);
|
||||||
|
|
||||||
printf(COLOR_BOLD_GREEN);
|
printf(COLOR_BOLD_GREEN);
|
||||||
drawLine();
|
drawLine();
|
||||||
printf(COLOR_GREEN);
|
printf(COLOR_GREEN);
|
||||||
@ -333,7 +336,7 @@ void compareFile(FILE *filePointer1, FILE *filePointer2 ,int32_t curentFilePosit
|
|||||||
// Display the main show
|
// Display the main show
|
||||||
printf(COLOR_BOLD_YELLOW);
|
printf(COLOR_BOLD_YELLOW);
|
||||||
drawLine();
|
drawLine();
|
||||||
for (j=0; j < NB_MAX_LINE; j++) {
|
for (j=0; j < (GetNumberOfRaw()-NB_HEARDER_RAW); j++) {
|
||||||
uint32_t readFile1 = 0;
|
uint32_t readFile1 = 0;
|
||||||
uint32_t readFile2 = 0;
|
uint32_t readFile2 = 0;
|
||||||
int32_t lineNumber = 0;
|
int32_t lineNumber = 0;
|
||||||
|
@ -75,14 +75,17 @@ typedef signed long long int int64_t;
|
|||||||
// Return to the normal color setings
|
// Return to the normal color setings
|
||||||
#define COLOR_NORMAL "\e[0m"
|
#define COLOR_NORMAL "\e[0m"
|
||||||
|
|
||||||
|
#define MOUSE_REPORTING_ENABLE "\e[?9h"
|
||||||
|
#define MOUSE_REPORTING_DISABLE "\e[?9l"
|
||||||
|
|
||||||
|
#define CURSOR_DISPLAY_DISABLE "\e[?25l"
|
||||||
|
#define CURSOR_DISPLAY_ENABLE "\e[?12l\e[?25h"
|
||||||
|
|
||||||
//go to the Top of bash
|
//go to the Top of bash
|
||||||
#define GO_TOP "\e[0;0f"
|
#define GO_TOP "\e[0;0f"
|
||||||
|
|
||||||
|
|
||||||
#define NB_DATA_PER_LINE (4)
|
#define NB_DATA_PER_LINE (4)
|
||||||
#define NB_MAX_LINE (45)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
64
main.c
64
main.c
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool filePresent[2] = {false, false};
|
bool filePresent[2] = {false, false};
|
||||||
FILE *filePointer[2] = {NULL, NULL};
|
FILE *filePointer[2] = {NULL, NULL};
|
||||||
uint32_t filesize[2] = {0, 0};
|
uint32_t filesize[2] = {0, 0};
|
||||||
@ -138,14 +139,14 @@ void OpenFiles(void) {
|
|||||||
// Open file 1
|
// Open file 1
|
||||||
filePointer[0] = fopen(fileName[0], "rb");
|
filePointer[0] = fopen(fileName[0], "rb");
|
||||||
if ( NULL == filePointer[0]) {
|
if ( NULL == filePointer[0]) {
|
||||||
printf("Can not Open [File_1] = %s\n", fileName[0]);
|
//printf("Can not Open [File_1] = %s\n", fileName[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (true == filePresent[1]) {
|
if (true == filePresent[1]) {
|
||||||
// open File 2
|
// open File 2
|
||||||
filePointer[1] = fopen(fileName[1], "rb");
|
filePointer[1] = fopen(fileName[1], "rb");
|
||||||
if ( NULL == filePointer[1]) {
|
if ( NULL == filePointer[1]) {
|
||||||
printf("Can not Open [File_2] = %s\n", fileName[1]);
|
//printf("Can not Open [File_2] = %s\n", fileName[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UpdateFilesSize();
|
UpdateFilesSize();
|
||||||
@ -171,6 +172,8 @@ int main (int argc, char**argv)
|
|||||||
strcpy(fileName[0], "No-File");
|
strcpy(fileName[0], "No-File");
|
||||||
strcpy(fileName[1], "No-File");
|
strcpy(fileName[1], "No-File");
|
||||||
|
|
||||||
|
UpdateNumberOfRawAndColomn();
|
||||||
|
|
||||||
// check error
|
// check error
|
||||||
if (3 < argc || argc < 2) {
|
if (3 < argc || argc < 2) {
|
||||||
printf("You set more than 3 argument at the commande line\n");
|
printf("You set more than 3 argument at the commande line\n");
|
||||||
@ -194,8 +197,12 @@ int main (int argc, char**argv)
|
|||||||
system("stty -icanon");
|
system("stty -icanon");
|
||||||
// supression de l'écho des caractères
|
// supression de l'écho des caractères
|
||||||
system("stty -echo");
|
system("stty -echo");
|
||||||
|
// enable mouse event ...
|
||||||
|
printf(MOUSE_REPORTING_ENABLE);
|
||||||
|
// hide cursor ...
|
||||||
|
printf(CURSOR_DISPLAY_DISABLE);
|
||||||
system("clear");
|
system("clear");
|
||||||
|
CleanDisplay();
|
||||||
|
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -206,9 +213,45 @@ int main (int argc, char**argv)
|
|||||||
{
|
{
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
uint32_t inputValue;
|
int32_t inputValue;
|
||||||
inputValue = getc (stdin);
|
inputValue = getc(stdin);
|
||||||
//printf("\n get data : 0x%08x ..... : \n", (unsigned int)inputValue);
|
if (inputValue == 0x1b) {
|
||||||
|
// mose event :
|
||||||
|
int32_t val2 = getc(stdin);
|
||||||
|
int32_t val3 = getc(stdin);
|
||||||
|
int32_t val4 = getc(stdin);
|
||||||
|
int32_t val5 = getc(stdin);
|
||||||
|
int32_t val6 = getc(stdin);
|
||||||
|
int32_t bt=0;
|
||||||
|
switch (val4) {
|
||||||
|
case 97:
|
||||||
|
bt = 4;
|
||||||
|
break;
|
||||||
|
case 96:
|
||||||
|
bt = 5;
|
||||||
|
break;
|
||||||
|
case 32:
|
||||||
|
bt = 1;
|
||||||
|
break;
|
||||||
|
case 33:
|
||||||
|
bt = 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//printf("\n mouse event : %d, %d, %d, %d=%d x=%d y=%d\n", inputValue, val2, val3, val4, bt, val5-33, val6-33);
|
||||||
|
(void)val2;
|
||||||
|
(void)val3;
|
||||||
|
(void)val4;
|
||||||
|
(void)val5;
|
||||||
|
(void)val6;
|
||||||
|
if (bt == 4) {
|
||||||
|
upDownOfsetFile(5);
|
||||||
|
} else if (bt == 5) {
|
||||||
|
upDownOfsetFile(-5);
|
||||||
|
}
|
||||||
|
inputValue = 0;
|
||||||
|
} else {
|
||||||
|
//printf("\n get data : 0x%08x ..... : \n", (unsigned int)inputValue);
|
||||||
|
}
|
||||||
switch(inputValue)
|
switch(inputValue)
|
||||||
{
|
{
|
||||||
case 'q':
|
case 'q':
|
||||||
@ -233,9 +276,9 @@ int main (int argc, char**argv)
|
|||||||
} else if ( inputValue == 0x42) {
|
} else if ( inputValue == 0x42) {
|
||||||
upDownOfsetFile(5);
|
upDownOfsetFile(5);
|
||||||
} else if ( inputValue == 0x43) {
|
} else if ( inputValue == 0x43) {
|
||||||
upDownOfsetFile(NB_MAX_LINE);
|
upDownOfsetFile((GetNumberOfRaw()-NB_HEARDER_RAW));
|
||||||
} else if ( inputValue == 0x44) {
|
} else if ( inputValue == 0x44) {
|
||||||
upDownOfsetFile(-NB_MAX_LINE);
|
upDownOfsetFile(-(GetNumberOfRaw()-NB_HEARDER_RAW));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -282,6 +325,7 @@ int main (int argc, char**argv)
|
|||||||
case 'r':
|
case 'r':
|
||||||
case 'R':
|
case 'R':
|
||||||
CloseFiles();
|
CloseFiles();
|
||||||
|
//UpdateNumberOfRawAndColomn();
|
||||||
OpenFiles();
|
OpenFiles();
|
||||||
needRedraw();
|
needRedraw();
|
||||||
break;
|
break;
|
||||||
@ -312,6 +356,10 @@ int main (int argc, char**argv)
|
|||||||
exit_programme :
|
exit_programme :
|
||||||
CloseFiles();
|
CloseFiles();
|
||||||
|
|
||||||
|
// disable mouse event ...
|
||||||
|
printf(MOUSE_REPORTING_DISABLE);
|
||||||
|
// Back cursor ON ...
|
||||||
|
printf(CURSOR_DISPLAY_ENABLE);
|
||||||
// remettre la lecture des données canonique
|
// remettre la lecture des données canonique
|
||||||
system("stty icanon");
|
system("stty icanon");
|
||||||
// repositionnement de l'écho des caractères
|
// repositionnement de l'écho des caractères
|
||||||
|
45
parameter.c
45
parameter.c
@ -24,6 +24,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "parameter.h"
|
#include "parameter.h"
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <stdio.h>
|
||||||
// Parameter Local Value :
|
// Parameter Local Value :
|
||||||
|
|
||||||
static uint32_t fileOfset = 0;
|
static uint32_t fileOfset = 0;
|
||||||
@ -37,6 +39,25 @@ static showTypeSize_te curentTypeSize = SHOW_TYPE_SIZE_8;
|
|||||||
|
|
||||||
extern uint32_t filesize[2];
|
extern uint32_t filesize[2];
|
||||||
|
|
||||||
|
void CleanDisplay(void)
|
||||||
|
{
|
||||||
|
//system("clear");
|
||||||
|
UpdateNumberOfRawAndColomn();
|
||||||
|
printf(GO_TOP);
|
||||||
|
for (int32_t iii=0; iii< GetNumberOfRaw(); iii++) {
|
||||||
|
for (int32_t jjj=0; jjj < GetNumberOfColomn()-1; jjj++) {
|
||||||
|
printf(" ");
|
||||||
|
}
|
||||||
|
if (iii< GetNumberOfRaw()-1) {
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf(GO_TOP);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setOfsetFile(int32_t offset)
|
void setOfsetFile(int32_t offset)
|
||||||
{
|
{
|
||||||
if (0 > offset) {
|
if (0 > offset) {
|
||||||
@ -118,7 +139,7 @@ void nextType(void)
|
|||||||
curentType = SHOW_TYPE_HEX;
|
curentType = SHOW_TYPE_HEX;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
system("clear");
|
CleanDisplay();
|
||||||
parmamModifier = true;
|
parmamModifier = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +171,7 @@ void nextTypeSize(void)
|
|||||||
curentTypeSize = SHOW_TYPE_SIZE_8;
|
curentTypeSize = SHOW_TYPE_SIZE_8;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
system("clear");
|
CleanDisplay();
|
||||||
parmamModifier = true;
|
parmamModifier = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,5 +181,25 @@ showTypeSize_te getTypeSize(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32_t nbRaw = 20;
|
||||||
|
int32_t nbColomn = 70;
|
||||||
|
|
||||||
|
void UpdateNumberOfRawAndColomn(void)
|
||||||
|
{
|
||||||
|
struct winsize w;
|
||||||
|
ioctl(0, TIOCGWINSZ, &w);
|
||||||
|
nbRaw = w.ws_row;
|
||||||
|
nbColomn = w.ws_col;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32_t GetNumberOfRaw(void)
|
||||||
|
{
|
||||||
|
return nbRaw;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t GetNumberOfColomn(void)
|
||||||
|
{
|
||||||
|
return nbColomn;
|
||||||
|
}
|
||||||
|
|
||||||
|
10
parameter.h
10
parameter.h
@ -45,5 +45,15 @@ showTypeSize_te getTypeSize(void);
|
|||||||
void displayPaddingOffset(int32_t size);
|
void displayPaddingOffset(int32_t size);
|
||||||
void displayPaddingOffsetClear(void);
|
void displayPaddingOffsetClear(void);
|
||||||
int32_t getPaddingOffsetFile(void);
|
int32_t getPaddingOffsetFile(void);
|
||||||
|
|
||||||
|
|
||||||
|
#define NB_HEARDER_RAW (8)
|
||||||
|
|
||||||
|
void UpdateNumberOfRawAndColomn(void);
|
||||||
|
int32_t GetNumberOfRaw(void);
|
||||||
|
int32_t GetNumberOfColomn(void);
|
||||||
|
|
||||||
|
void CleanDisplay(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user