?? setonkey.c
字號:
/* CXL - Copyright (c) 1987-1989 by Mike Smedley - All Rights Reserved */
/* SETONKEY.C - attaches/detaches a key to a function */
#include <stdlib.h>
#include "cxldef.h"
#include "cxlkey.h"
int setonkey(unsigned keycode,void (*func) (void),unsigned pass)
{
struct _onkey_t *onkey,*prev,*next;
/* search for a keycode that is already defined */
onkey=_kbinfo.onkey;
while(onkey!=NULL) {
if( onkey->keycode == keycode ) break;
onkey=onkey->prev;
}
/* check to see if a key detachment is being requested */
if(func==NULL) {
/* if no defined onkey was found, then error */
if(onkey==NULL) return(2);
/* delete record from linked list */
prev=onkey->prev;
next=onkey->next;
if(prev!=NULL) prev->next=next;
if(next!=NULL) next->prev=prev;
if(onkey==_kbinfo.onkey) _kbinfo.onkey=prev;
/* free memory allocated for deleted record */
free(onkey);
}
else {
/* if key was found, change func pointer */
/* otherwise create a new onkey record */
if(onkey!=NULL)
onkey->func=func;
else {
/* allocate memory for new record */
onkey=malloc(sizeof(struct _onkey_t));
if(onkey==NULL) return(1);
/* add new record to linked list */
if(_kbinfo.onkey!=NULL) _kbinfo.onkey->next=onkey;
onkey->prev=_kbinfo.onkey;
onkey->next=NULL;
_kbinfo.onkey=onkey;
/* save info in onkey record */
_kbinfo.onkey->keycode=keycode;
_kbinfo.onkey->func=func;
_kbinfo.onkey->pass=pass;
}
}
/* return normally */
return(0);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -