📄 transkey.c
字号:
// $Id: transkey.c,v 1.5 2000/11/10 03:18:35 ymwei Exp $//// transkey.c: The Key Messages Translator//// Author: KANG Xiaoning// Copyright (C) 1999, Kang Xiaoning.//// Modified by WEI Yongming.// Copyright (C) 1999, Wei Yongming.//// Current maintainer: Wei Yongming./*** This library is free software; you can redistribute it and/or** modify it under the terms of the GNU Library General Public** License as published by the Free Software Foundation; either** version 2 of the License, or (at your option) any later version.**** This library is distributed in the hope that it will be useful,** but WITHOUT ANY WARRANTY; without even the implied warranty of** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU** Library General Public License for more details.**** You should have received a copy of the GNU Library General Public** License along with this library; if not, write to the Free** Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,** MA 02111-1307, USA*/// Create date: 1999.05//// Used abbreviations:// ime: input method//// Modify records://// Who When Where For What//-----------------------------------------------------------------------------// WEI Yongming 1999/6/14 Tsinghua Message dispatching// WEI Yongming 2000/7/05 BluePoint KS_CTRL flag//// TODO:// #include <pthread.h>#include <semaphore.h>#include <ctype.h>#include "common.h"#include "gdi.h"#include "window.h"#ifndef lintstatic char fileid[] = "$Id: transkey.c,v 1.5 2000/11/10 03:18:35 ymwei Exp $";#endif//table1, translating depends on capslock & shiftstatic short keymap11[] = { 0,27,'1','2','3','4','5','6','7','8','9','0', //11'-','=','\b','\t', //4'q','w','e','r','t','y','u','i','o','p','[',']','\n',0, //14 'a','s','d','f','g','h','j','k','l',';','\'','`',0,'\\', //14'z','x','c','v','b','n','m',',','.','/',0,'*',0,' ',0, //15};static short keymap12[] = { 0,27,'!','@','#','$','%','^','&','*','(',')','_','+','\b','\t','Q','W','E','R','T','Y','U','I','O','P','{','}','\n',0,'A','S','D','F','G','H','J','K','L',':','"','~',0,'|','Z','X','C','V','B','N','M','<','>','?',0,'*',0,' ',0,};#define TABLE_SPLIT_VAL 58//table2 translating depends on numlock & shiftstatic short keymap21[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0, // f1-f10 numlock & scrolllock0,0,0,'-',0,0,0,'+',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'\n',0,'/'};static short keymap22[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0, // f1-f10 numlock & scrolllock'7','8','9','-','4','5','6','+','1','2','3','0','.',0,0,0,0,0,0,0,0,0,0,0,0,'\n',0,'/'};#define TABLE_SPLIT_VAL2 98unsigned char transToChars(PMSG pMsg){ short caplock = 0, numlock = 0, shift = 0; if (pMsg->lParam & KS_CTRL) return 0; if (pMsg->wParam <= TABLE_SPLIT_VAL2) { if (pMsg->lParam & KS_CAPSLOCK) caplock=1; if (pMsg->lParam & KS_NUMLOCK) numlock=1; if (pMsg->lParam & KS_SHIFT) shift=1; if (pMsg->wParam <= TABLE_SPLIT_VAL) // translate using table1 { // alpha chars, capslock affects if (isalpha(keymap11[pMsg ->wParam])) { // caps lock not on or shift & caps lock both on if (! (caplock ^ shift)) return keymap11 [pMsg -> wParam]; else return keymap12 [pMsg -> wParam]; } // non-alpha, capslock doesn't matter else if (shift) return keymap12 [pMsg -> wParam]; else return keymap11 [pMsg -> wParam]; } else { // caps lock not on or shift & caps lock both on if (!(numlock ^ shift)) return keymap21 [pMsg -> wParam - TABLE_SPLIT_VAL]; else return keymap22 [pMsg -> wParam - TABLE_SPLIT_VAL]; } } else return 0;}int GUIAPI TranslateMessage (PMSG pMsg){ unsigned char iChar; if ( (pMsg->hwnd != HWND_INVALID) && (pMsg->message == MSG_KEYDOWN || pMsg->message == MSG_SYSKEYDOWN) ) { // can be transed to WM_CHAR if ((iChar = (unsigned char) transToChars(pMsg))) { if (pMsg->message == MSG_SYSKEYDOWN) SendMessage (pMsg->hwnd, MSG_SYSCHAR, iChar, pMsg->lParam); else SendMessage (pMsg->hwnd, MSG_CHAR, iChar, pMsg->lParam); return TRUE; } } return FALSE; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -