⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scr.c

📁 hex editor for editing all files
💻 C
字号:
/* * scr.c   - main screen related routines *  *        Author: David Scott *  Date Started: 25-Aug-2000 *  *  Modification history: * *  .000830  initial beta release */#include <curses.h>#include <unistd.h>#include <stdlib.h>#include <stdio.h>#include <ctype.h>#include <sys/types.h>#include <sys/stat.h>#include "hview.h"/* * print an error message  * input: pointer to the current window *        message to print */int printerr( WINDOW *wp,  char *message, char *options){	WINDOW *errwin;          /* new window for the error message */	   int ch;	/*	 * center the window 	 */	errwin = newwin( 7, 40, (screen_y-8)/2, (screen_x-40)/2); 	move(0,0);	/* 	 * if we have a color term 	 */	if(color)	{		start_color();	 	init_pair(1,COLOR_RED, COLOR_BLACK);		wattron(errwin, COLOR_PAIR(1));	}		box(errwin, '|', '=');	if(color)		wattroff(errwin, COLOR_PAIR(1));			mvwprintw( errwin, 2, (40-strlen(message))/2, message );	mvwprintw( errwin, 4, (40-strlen(options))/2, options );	wrefresh(errwin);	ch = getchar();	delwin(errwin);		return(ch);}/*  * print the main screen  * input:   Window pointer to current window *          file stream to read *          position we are in the file * output:  long value of how many bytes were read * */long printscr( WINDOW *wp, FILE *in, int pos){		int x,y,z,offset,j,ch; /* some throway vars */		j = screen_y-4; 	/*          *  clear the current screen so we don't	 * get any bleed from previous screens.         */	for( x = 1;x<=j;x++)	{		move(x,0);		clrtoeol();	}	fseek( in, pos, SEEK_SET);	offset = 0;	x = y = z = 0;	/*          *  while not end of file and no end of 	 *  screen.         */	while(!feof(in) && (offset<(j*16)))	{		ch = fgetc(in);		if( feof(in) )			break;		buffer[offset] = ch;		/*  		 * new line every 16 bytes 		 */			if(!(offset%16))			{ 		   x++; y = 10; z = 0;		   move( x, 0);		   clrtoeol();	   	   printw("%8.8x: ",offset+pos);			}		move(x,y);		/*		 *  for some reason fgetc was putting the character	 	 *  into a signed int.  This was causing the char to  		 *  be padded with 0xffffff00 (ex: if the origional byte		 *  was 0xf4 it became 0xfffffff4.  So I mask out 		 *  anything other than the last byte on any negitive		 *  number.		 *	 	*/		printw("%-3.2X ", (buffer[offset] <0)?buffer[offset]^0xffffff00:buffer[offset] );		move(x,z+60);		printch(buffer[offset]); 				/* 		 * print a '-' between every 4 bytes except the last one 		 */		if( !((offset+1) % 4) && ((offset+1)%16) )		{			move(x,y+2);			printw("-");  		}		y+=3; z++;		offset++;				refresh();		move(0,0);	} /* end while */	return (offset);}/*  * print character * input: character to print * * since not every char in the ansi code is printable * we need to do a litte translation before it goes  * to the screen. */void printch( char ch ){	/* 	 * since I can't find any platfrom indepentdant	 * way to print control (non printable) chars 	 * I'll just replace them with a '.' char.	 */	char ch2;	if( isprint(ch) )	{		printw("%c",ch);	}		else	{		attron(A_REVERSE);		if(ch < 0x27)		{ 			ch2= ch + 'A' -1;			printw("%c",ch2);		}		else		{			printw("%c",'.');		}		attroff(A_REVERSE);	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -