📄 wtitle.c
字号:
/* CXL - Copyright (c) 1987-1989 by Mike Smedley - All Rights Reserved */
/* WTITLE.C - gives active window a title */
#include <stdlib.h>
#include <string.h>
#include "cxldef.h"
#include "cxlstr.h"
#include "cxlvid.h"
#include "cxlwin.h"
int wtitle(char *str,int tpos,int tattr)
{
int left,right,start,len,width,offs;
char *p;
/* check for active window */
if(!_winfo.total) return(_winfo.errno=W_NOACTIVE);
/* check for monochrome adapter, adjust title attribute */
tattr=mapattr(tattr);
/* redraw box if deleting or moving title */
if(str==NULL||_winfo.active->title!=NULL) {
if(_winfo.active->border)
box_(_winfo.active->srow,_winfo.active->scol,_winfo.active->erow,
_winfo.active->ecol,_winfo.active->btype,
_winfo.active->battr);
}
/* if not deleting the title, calculate position and display it */
if(str!=NULL) {
left=_winfo.active->scol+1;
right=_winfo.active->ecol-1;
width=right-left+1;
len=strlen(str);
/* don't display title if window is borderless */
if(_winfo.active->border) {
switch(tpos) {
case TLEFT:
start=(len>(width-3))?left:(left+1);
break;
case TCENTER:
start=(len>(width-2))?left:(((width/2)+left)-(len/2));
break;
default: /* default is TRIGHT */
offs=width-len;
if(offs>2) offs--;
start=(len>width)?left:(left+offs);
}
/* allocate space for window title string, and copy it there */
if((p=malloc(((width>len)?width:len)+1))==NULL)
return(_winfo.errno=W_ALLOCERR);
strcpy(p,str);
*(p+width)='\0';
/* display title string */
prints(_winfo.active->srow,start,tattr,p);
/* free allocated space */
free(p);
}
}
/* update window's record */
_winfo.active->title=str;
_winfo.active->tpos=tpos;
_winfo.active->tattr=tattr;
/* return normally */
return(_winfo.errno=W_NOERROR);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -