글자색, 배경색 15색 사용하기
2007.04.12 13:03
// 글자 15색+ 배경 15색 지원을 위해서는
// io.c + alias.c + command4.c 가 필요합니다.
//
// 아래와 같이 수정하였습니다.
// 버그가 없는지 모르겠군요.
// 제가 해본 테스트결과 아무 이상은 없습니다.
// 깔끔하게 잘 됩니다.
// 글자색 15+ 배경색 15색 다 지원합니다.
// 사용법은 {빨,녹,노,파,보,하,흰,흑,홍,연,갈,청,분,푸,회
// 배경색은 [빨,녹,노,파,보,하,흰,흑,홍,연,갈,청,분,푸,회 입니다.
// 이상한부분은 칭호에 안시를 섞어 쓸때 길이가 더 짧습니다?
//
// z9517023@rose0.knu.ac.kr
// http://rose0.knu.ac.kr/~z9517023
/**********************************************************************/
/* printa */
/**********************************************************************/
/* 모든 부분에 안시를 사용하기 위한 부분이다. */
// 아래가 다름
void printa (fd, fmt, i1, i2, i3, i4, i5, i6)
int fd;
unsigned char *fmt;
// 아래가 다름
int i1, i2, i3, i4, i5, i6;
{
char msg[8192];
char *fmt2;
char fmt3[8192], temp[80];
int i = 0, j = 0, k, n, otail, ohead, c, mmm;
int num, loc, ind = -1, len, flags = 0;
int arg[8];
char type;
char *prestr;
char *Josa[6][2] =
{ {"은", "는",}, {"이", "가",}, {"과", "와",}, {"을", "를",}, {"으로", "로",}, };
static char color_buf1[16];
static char color_buf2[16];
if (fd == -1 || fd > Tablesize)
return;
if (!Ply[fd].io)
return;
if (Ply[fd].ply)
{
if (F_ISSET (Ply[fd].ply, PDINVI))
flags |= INV;
if (F_ISSET (Ply[fd].ply, PDMAGI))
flags |= MAG;
if (Ply[fd].ply->class == DM)
flags |= DMF;
}
len = strlen (fmt);
fmt2 = (char *) malloc (len + 1);
if (!fmt2)
merror ("print", FATAL);
// 아래 갯수가 적음.
arg[0] = i1;
arg[1] = i2;
arg[2] = i3;
arg[3] = i4;
arg[4] = i5;
arg[5] = i6;
/* Check for %m, %M, %i and %I and modify arguments as necessary */
do
{
if (fmt[i] == '%')
{
fmt2[j++] = fmt[i];
num = 0;
k = i;
do
{
k++;
if ((fmt[k] >= 'a' && fmt[k] <= 'z') || (fmt[k] >= 'A' && fmt[k] <= 'Z')
|| fmt[k] == '%')
{
loc = k;
type = fmt[k];
break;
}
else if (fmt[k] >= '0' && fmt[k] <= '9')
num = num * 10 + fmt[k] - '0';
}
while (k < len);
if (type == '%')
{
fmt2[j++] = '%';
i++;
i++;
continue;
}
ind++;
// 아래 갯수가 적음. 원소스의 A조건이 없음.
if (type != 'm' && type != 'M' && type != 'j' && type != 'i'
&& type != 'I' && type != 'S' && type != 'D' && type != 'C')
{
i++;
continue;
}
i = loc + 1;
fmt2[j++] = 's';
switch (type)
{
case 'm':
arg[ind] = (int) (prestr = crt_str (arg[ind], num, flags | CAP));
continue;
case 'M':
arg[ind] = (int) (prestr = crt_str (arg[ind], num, flags));
continue;
case 'S':
prestr = (char *) arg[ind];
continue;
case 'j':
switch (*((char *) arg[ind]))
{
case '0':
case '1':
case '2':
case '3':
case '4':
if (under_han (prestr))
arg[ind] = (int) Josa[*((char *) arg[ind]) - '0'][0];
else
arg[ind] = (int) Josa[*((char *) arg[ind]) - '0'][1];
break;
default:
arg[ind] = (int) "";
}
continue;
case 'i':
case 'I':
arg[ind] = (int) (prestr = obj_str (arg[ind], num, flags));
continue;
case 'C':
if (F_ISSET (Ply[fd].ply, PANSIC))
{
// sprintf (color_buf1, "%c[%d;%sm", 27, (F_ISSET (Ply[fd].ply, PBRIGH)
// && atoi ((char *) arg[ind]) != WHITE) ? 1 : 0, (char *) arg[ind]);
// 아래 같이 수정
sprintf (color_buf1, "\x1B[=%sF", (char *) arg[ind]);
arg[ind] = (int) color_buf1;
}
else
arg[ind] = (int) "";
continue;
case 'D':
if (F_ISSET (Ply[fd].ply, PANSIC))
{
// sprintf (color_buf2, "%c[%d;%sm", 27, (F_ISSET (Ply[fd].ply, PBRIGH)
// && atoi ((char *) arg[ind]) != WHITE) ? 1 : 0, (char *) arg[ind]);
// 아래 같이 수정
sprintf (color_buf2, "\x1B[=%sF", (char *) arg[ind]);
arg[ind] = (int) color_buf2;
}
else
arg[ind] = (int) "";
continue;
}
}
fmt2[j++] = fmt[i++];
} while (i < len);
fmt2[j] = 0;
sprintf (msg, fmt2, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]);
free (fmt2);
i = 0; j = 0;
len = strlen (msg);
fmt3[0] = 0;
for(mmm=0; mmm < len; mmm++) {
if(msg[mmm] == '{') {
if((c = color_cmp(msg+mmm+1)) != 0) {
if(F_ISSET(Ply[fd].ply,PANSIC)) {
// sprintf(temp,"%c[%d;%dm",27,
// F_ISSET(Ply[fd].ply,PBRIGH)?1:0, c);
// 아래 같이 수정
sprintf(temp,"\x1B[=%dF", c);
sprintf(fmt3+j, "%s", temp);
j += strlen(temp);
}
mmm += 2;
continue;
}
else {
fmt3[j] = '{';
j++;
}
}
else if(msg[mmm] == '[') {
if((c = color_cmp(msg+mmm+1)) != 0) {
if(F_ISSET(Ply[fd].ply,PANSIC)) {
// sprintf(temp,"%c[%d;%dm",27,
// F_ISSET(Ply[fd].ply,PBRIGH)?1:0, c);
// 아래 같이 수정
sprintf(temp,"\x1B[=%dG", c);
sprintf(fmt3+j, "%s", temp);
j += strlen(temp);
}
mmm += 2;
continue;
}
else {
fmt3[j] = '[';
j++;
}
}
else if(msg[mmm]=='}') {
temp[0] = 0;
if(F_ISSET(Ply[fd].ply,PANSIC))
// sprintf(temp,"%c[0;37m%c[0;0m",27,27);
// 아래 같이 수정
sprintf(temp,"\x1B[=7F%c[37;40m", 27);
sprintf(fmt3+j, "%s", temp);
j += strlen(temp);
}
else {
fmt3[j] = msg[mmm];
j++;
}
}
if(F_ISSET(Ply[fd].ply, PANSIC))
// sprintf(fmt3+j, "%c[0;37m%c[0;0m", 27,27);
// 아래 같이 수정
sprintf(fmt3+j, "\x1B[=7F%c[37;40m", 27);
else
fmt3[j] = 0;
n = strlen (fmt3);
/*
if (n > 78 && title_cut_index[fd] == 0)
{
delimit (fmt3);
n = strlen (fmt3);
}
*/
ohead = Ply[fd].io->ohead;
otail = Ply[fd].io->otail;
for (i = 0; i < n; i++)
{
Ply[fd].io->output[ohead] = fmt3[i];
if (fmt3[i] == '\n')
{
Ply[fd].io->output[ohead] = '\r';
ohead = (ohead + 1) % OBUFSIZE;
if (ohead == otail)
otail = (otail + 1) % OBUFSIZE;
Ply[fd].io->output[ohead] = fmt3[i];
}
ohead = (ohead + 1) % OBUFSIZE;
if (ohead == otail)
otail = (otail + 1) % OBUFSIZE;
}
Ply[fd].io->ohead = ohead;
Ply[fd].io->otail = otail;
}
홈지기 "그륨"
// io.c + alias.c + command4.c 가 필요합니다.
//
// 아래와 같이 수정하였습니다.
// 버그가 없는지 모르겠군요.
// 제가 해본 테스트결과 아무 이상은 없습니다.
// 깔끔하게 잘 됩니다.
// 글자색 15+ 배경색 15색 다 지원합니다.
// 사용법은 {빨,녹,노,파,보,하,흰,흑,홍,연,갈,청,분,푸,회
// 배경색은 [빨,녹,노,파,보,하,흰,흑,홍,연,갈,청,분,푸,회 입니다.
// 이상한부분은 칭호에 안시를 섞어 쓸때 길이가 더 짧습니다?
//
// z9517023@rose0.knu.ac.kr
// http://rose0.knu.ac.kr/~z9517023
/**********************************************************************/
/* printa */
/**********************************************************************/
/* 모든 부분에 안시를 사용하기 위한 부분이다. */
// 아래가 다름
void printa (fd, fmt, i1, i2, i3, i4, i5, i6)
int fd;
unsigned char *fmt;
// 아래가 다름
int i1, i2, i3, i4, i5, i6;
{
char msg[8192];
char *fmt2;
char fmt3[8192], temp[80];
int i = 0, j = 0, k, n, otail, ohead, c, mmm;
int num, loc, ind = -1, len, flags = 0;
int arg[8];
char type;
char *prestr;
char *Josa[6][2] =
{ {"은", "는",}, {"이", "가",}, {"과", "와",}, {"을", "를",}, {"으로", "로",}, };
static char color_buf1[16];
static char color_buf2[16];
if (fd == -1 || fd > Tablesize)
return;
if (!Ply[fd].io)
return;
if (Ply[fd].ply)
{
if (F_ISSET (Ply[fd].ply, PDINVI))
flags |= INV;
if (F_ISSET (Ply[fd].ply, PDMAGI))
flags |= MAG;
if (Ply[fd].ply->class == DM)
flags |= DMF;
}
len = strlen (fmt);
fmt2 = (char *) malloc (len + 1);
if (!fmt2)
merror ("print", FATAL);
// 아래 갯수가 적음.
arg[0] = i1;
arg[1] = i2;
arg[2] = i3;
arg[3] = i4;
arg[4] = i5;
arg[5] = i6;
/* Check for %m, %M, %i and %I and modify arguments as necessary */
do
{
if (fmt[i] == '%')
{
fmt2[j++] = fmt[i];
num = 0;
k = i;
do
{
k++;
if ((fmt[k] >= 'a' && fmt[k] <= 'z') || (fmt[k] >= 'A' && fmt[k] <= 'Z')
|| fmt[k] == '%')
{
loc = k;
type = fmt[k];
break;
}
else if (fmt[k] >= '0' && fmt[k] <= '9')
num = num * 10 + fmt[k] - '0';
}
while (k < len);
if (type == '%')
{
fmt2[j++] = '%';
i++;
i++;
continue;
}
ind++;
// 아래 갯수가 적음. 원소스의 A조건이 없음.
if (type != 'm' && type != 'M' && type != 'j' && type != 'i'
&& type != 'I' && type != 'S' && type != 'D' && type != 'C')
{
i++;
continue;
}
i = loc + 1;
fmt2[j++] = 's';
switch (type)
{
case 'm':
arg[ind] = (int) (prestr = crt_str (arg[ind], num, flags | CAP));
continue;
case 'M':
arg[ind] = (int) (prestr = crt_str (arg[ind], num, flags));
continue;
case 'S':
prestr = (char *) arg[ind];
continue;
case 'j':
switch (*((char *) arg[ind]))
{
case '0':
case '1':
case '2':
case '3':
case '4':
if (under_han (prestr))
arg[ind] = (int) Josa[*((char *) arg[ind]) - '0'][0];
else
arg[ind] = (int) Josa[*((char *) arg[ind]) - '0'][1];
break;
default:
arg[ind] = (int) "";
}
continue;
case 'i':
case 'I':
arg[ind] = (int) (prestr = obj_str (arg[ind], num, flags));
continue;
case 'C':
if (F_ISSET (Ply[fd].ply, PANSIC))
{
// sprintf (color_buf1, "%c[%d;%sm", 27, (F_ISSET (Ply[fd].ply, PBRIGH)
// && atoi ((char *) arg[ind]) != WHITE) ? 1 : 0, (char *) arg[ind]);
// 아래 같이 수정
sprintf (color_buf1, "\x1B[=%sF", (char *) arg[ind]);
arg[ind] = (int) color_buf1;
}
else
arg[ind] = (int) "";
continue;
case 'D':
if (F_ISSET (Ply[fd].ply, PANSIC))
{
// sprintf (color_buf2, "%c[%d;%sm", 27, (F_ISSET (Ply[fd].ply, PBRIGH)
// && atoi ((char *) arg[ind]) != WHITE) ? 1 : 0, (char *) arg[ind]);
// 아래 같이 수정
sprintf (color_buf2, "\x1B[=%sF", (char *) arg[ind]);
arg[ind] = (int) color_buf2;
}
else
arg[ind] = (int) "";
continue;
}
}
fmt2[j++] = fmt[i++];
} while (i < len);
fmt2[j] = 0;
sprintf (msg, fmt2, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]);
free (fmt2);
i = 0; j = 0;
len = strlen (msg);
fmt3[0] = 0;
for(mmm=0; mmm < len; mmm++) {
if(msg[mmm] == '{') {
if((c = color_cmp(msg+mmm+1)) != 0) {
if(F_ISSET(Ply[fd].ply,PANSIC)) {
// sprintf(temp,"%c[%d;%dm",27,
// F_ISSET(Ply[fd].ply,PBRIGH)?1:0, c);
// 아래 같이 수정
sprintf(temp,"\x1B[=%dF", c);
sprintf(fmt3+j, "%s", temp);
j += strlen(temp);
}
mmm += 2;
continue;
}
else {
fmt3[j] = '{';
j++;
}
}
else if(msg[mmm] == '[') {
if((c = color_cmp(msg+mmm+1)) != 0) {
if(F_ISSET(Ply[fd].ply,PANSIC)) {
// sprintf(temp,"%c[%d;%dm",27,
// F_ISSET(Ply[fd].ply,PBRIGH)?1:0, c);
// 아래 같이 수정
sprintf(temp,"\x1B[=%dG", c);
sprintf(fmt3+j, "%s", temp);
j += strlen(temp);
}
mmm += 2;
continue;
}
else {
fmt3[j] = '[';
j++;
}
}
else if(msg[mmm]=='}') {
temp[0] = 0;
if(F_ISSET(Ply[fd].ply,PANSIC))
// sprintf(temp,"%c[0;37m%c[0;0m",27,27);
// 아래 같이 수정
sprintf(temp,"\x1B[=7F%c[37;40m", 27);
sprintf(fmt3+j, "%s", temp);
j += strlen(temp);
}
else {
fmt3[j] = msg[mmm];
j++;
}
}
if(F_ISSET(Ply[fd].ply, PANSIC))
// sprintf(fmt3+j, "%c[0;37m%c[0;0m", 27,27);
// 아래 같이 수정
sprintf(fmt3+j, "\x1B[=7F%c[37;40m", 27);
else
fmt3[j] = 0;
n = strlen (fmt3);
/*
if (n > 78 && title_cut_index[fd] == 0)
{
delimit (fmt3);
n = strlen (fmt3);
}
*/
ohead = Ply[fd].io->ohead;
otail = Ply[fd].io->otail;
for (i = 0; i < n; i++)
{
Ply[fd].io->output[ohead] = fmt3[i];
if (fmt3[i] == '\n')
{
Ply[fd].io->output[ohead] = '\r';
ohead = (ohead + 1) % OBUFSIZE;
if (ohead == otail)
otail = (otail + 1) % OBUFSIZE;
Ply[fd].io->output[ohead] = fmt3[i];
}
ohead = (ohead + 1) % OBUFSIZE;
if (ohead == otail)
otail = (otail + 1) % OBUFSIZE;
}
Ply[fd].io->ohead = ohead;
Ply[fd].io->otail = otail;
}
홈지기 "그륨"
댓글 0
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
57 | 특수 아이템 만들기 | 그리움 | 2007.04.12 | 253 |
56 | 몹과 자신을 "비교" | 그리움 | 2007.04.12 | 219 |
55 | 패거리 전쟁시 적과 아군 구분 | 그리움 | 2007.04.12 | 216 |
54 | 순위 소스 | 그리움 | 2007.04.12 | 215 |
53 | 개량형 우체국 | 그리움 | 2007.04.12 | 228 |
52 | 명성치 도입 | 그리움 | 2007.04.12 | 229 |
51 | 자기 아파트 방설명은 자기가 #2 | 그리움 | 2007.04.12 | 222 |
50 | 이동력 추가하기 | 그리움 | 2007.04.12 | 225 |
49 | 경매 소스 | 그리움 | 2007.04.12 | 217 |
» | 글자색, 배경색 15색 사용하기 | 그리움 | 2007.04.12 | 213 |
47 | Ctrl+Enter 패치하기 | 그리움 | 2007.04.12 | 198 |
46 | 패거리 상점 만들기 | 그리움 | 2007.04.12 | 199 |
45 | 귀환장소 설정 | 그리움 | 2007.04.12 | 228 |
44 | 출구 정렬 | 그리움 | 2007.04.12 | 222 |
43 | 게시판 검색 기능 추가하기 | 그리움 | 2007.04.12 | 207 |
42 | 암호 *****로 보이게 하기 | 그리움 | 2007.04.12 | 215 |
41 | 레벨을 32767까지 가능하게 | 그리움 | 2007.04.12 | 236 |
40 | 잡담 안시 사용하기 | 그리움 | 2007.04.12 | 236 |
39 | 지도 소스 #2 | 그리움 | 2007.04.12 | 230 |
38 | 베팅소스 | 그리움 | 2007.04.12 | 242 |