Permalink
Browse files

ckg-0.8.10-mod by hideden

http://d.hatena.ne.jp/hideden/20071115/1195229532

・設定ファイル ckw.txt → ckw.cfg に変更しました。(個人的な好みです。)
・MakefileからCygwin依存のシェルスクリプトを排除し、batのみで実行できるようにしてVCのみでコンパイルできるようにしました。
・カレントディレクトリを指定する-cd,--chdir を追加しました。
・実行シェルを設定ファイルに記述できるようにしました。
・タイトルを指定するオプション-tl,--titleを追加しました。
・フォントサイズを小さく設定すると、最大化時やWindowリサイズ時に一定以上の大きさにするとウィンドウサイズがおかしくなってしまう不具合を(多分)修正しました。
  • Loading branch information...
1 parent 26840b3 commit 98974d74ee7325431e74dbe786465f02fcda860d @deflis committed Mar 19, 2010
Showing with 186 additions and 41 deletions.
  1. +4 −4 Makefile
  2. +52 −0 ckw-mod_readme.txt
  3. +8 −4 ckw.txt → ckw.cfg
  4. +0 −1 ckw.h
  5. +82 −6 main.cpp
  6. +10 −4 option.cpp
  7. +10 −0 option.h
  8. +15 −0 version.bat
  9. +5 −5 version.h
  10. +0 −17 version.sh
View
@@ -1,8 +1,8 @@
TARGET = ckw.exe
OBJ = main.obj selection.obj misc.obj option.obj ime_wrap.obj rsrc.res
-#CFLAGS = -nologo -MLd -Od -W3 -Wp64 -GX -D_DEBUG
-CFLAGS = -nologo -MT -O2 -W3 -Wp64 -GX -DNDEBUG
+#CFLAGS = -nologo -MLd -Od -W3 -GX -D_DEBUG
+CFLAGS = -nologo -MT -O2 -W3 -EHsc -DNDEBUG
LDFLAGS = -nologo
UINC =
@@ -13,7 +13,7 @@ ULIB = user32.lib gdi32.lib shell32.lib
all: ver $(TARGET)
ver:
- ./version.sh > version.h
+ version.bat > version.h
$(TARGET): $(OBJ)
link $(LDFLAGS) -out:$@ $(OBJ) $(ULIB)
@@ -23,4 +23,4 @@ $(TARGET): $(OBJ)
.rc.res:
rc -l 0x409 -fo $@ $<
clean:
- rm -f $(OBJ) $(TARGET) *~
+ del $(OBJ) $(TARGET)
View
@@ -0,0 +1,52 @@
+ckw-mod�ύX�_
+
+�E�ݒ�t�@�C�� ckw.txt �� ckw.cfg �ɕύX���܂����B(�l�I�ȍD�݂ł��B)
+�EMakefile����Cygwin�ˑ��̃V�F���X�N���v�g��r�����Abat�݂̂Ŏ�s�ł���悤�ɂ���
+ VC�݂̂ŃR���p�C���ł���悤�ɂ��܂����B
+�E�J�����g�f�B���N�g����w�肷��-cd,--chdir ��lj���܂����B
+�E��s�V�F����ݒ�t�@�C���ɋL�q�ł���悤�ɂ��܂����B
+�E�^�C�g����w�肷��I�v�V����-tl,--title��lj���܂����B
+�E�t�H���g�T�C�Y������ݒ肷��ƁA�ő剻����Window���T�C�Y���Ɉ��ȏ�̑傫���ɂ����
+ �E�B���h�E�T�C�Y�����������Ȃ�Ă��܂��s���(����)�C�����܂����B
+
+����m�F�͓�{���WindowsXP Pro SP2�ł݂̂����Ȃ�Ă���܂��B
+�܂��A�o�C�i����VC8(VS2005)�ŃR���p�C�����Ă���܂��B
+
+
+�ݒ�t�@�C������
+
+Ckw*chdir: c:\
+
+�Ƃ����ƁA�J�����g�f�B���N�g����ړ����ăV�F����N�����܂��B�܂��A�R�}���h���C���Ŏw�肷��ꍇ��
+
+ckw -cd c:\
+ �܂���
+ckw --chdir c:\
+
+�Ƃ��Ă��������B
+
+
+
+�ݒ�t�@�C������
+
+Ckw*title: �R���\�[��
+
+�Ƃ���ƁA�^�C�g����ύX�ł��܂��B�f�t�H���g��"ckw"�ł��B
+�ݒ�t�@�C����SJIS�ŕۑ����Ă��������B
+
+
+
+Ckw*exec: C:\shell\nyacus.exe
+
+���Ƃ���ƋN������V�F����ݒ�t�@�C���Œ�`�ł��܂��B-e���l�A�N���I�v�V������L�q�ł��܂��B
+
+Ckw*exec: cmd.exe /K DATE
+
+
+
+�܂��A���X�̎d�l�Ƃ��Đݒ�t�@�C���͎�s�t�@�C�����̊g���q��.cfg�ɂ�����̂�ɍs���܂��̂ŁA
+�����̃V�F����g��������ꍇ�͎�s�t�@�C����ckw2.exe���ƃ��l�[�����Ackw2.cfg�ɕʐݒ��L�q����
+���������B
+
+
+2007/11/15 hideden <mail@hideden.net>
View
@@ -8,18 +8,22 @@
!Ckw*cursorImeColor: red
!Ckw*backgroundBitmap: ckw_background.bmp
+Ckw*title: ckw[cmd]
+Ckw*exec: cmd.exe
+Ckw*chdir: c:\
+
Ckw*scrollHide: no
Ckw*scrollRight: yes
Ckw*internalBorder: 1
Ckw*lineSpace: 0
Ckw*topmost: no
-!Ckw*transp: 255
+!Ckw*transp: 220
!Ckw*transpColor: #000000
-Ckw*font: �l�r �S�V�b�N
-Ckw*fontSize: 14
+Ckw*font: MS Gothic
+Ckw*fontSize: 12
-Ckw*geometry: 80x24
+Ckw*geometry: 80x26
Ckw*saveLines: 500
Ckw*color0: #000000
View
1 ckw.h
@@ -20,7 +20,6 @@
#define CSI_WndCols(csi) ((csi)->srWindow.Right - (csi)->srWindow.Left +1)
#define CSI_WndRows(csi) ((csi)->srWindow.Bottom - (csi)->srWindow.Top +1)
-
/* main.cpp */
extern HANDLE gStdIn;
extern HANDLE gStdOut;
View
@@ -53,6 +53,22 @@ CONSOLE_SCREEN_BUFFER_INFO* gCSI = NULL;
CHAR_INFO* gScreen = NULL;
wchar_t* gTitle = NULL;
+/* setConsoleFont */
+#define MAX_FONTS 128
+
+typedef struct _CONSOLE_FONT {
+ DWORD index;
+ COORD dim;
+} CONSOLE_FONT, *PCONSOLE_FONT;
+
+typedef BOOL (WINAPI *GetConsoleFontInfoT)( HANDLE,BOOL,DWORD,PCONSOLE_FONT );
+typedef DWORD (WINAPI *GetNumberOfConsoleFontsT)( VOID );
+typedef BOOL (WINAPI *SetConsoleFontT)( HANDLE, DWORD );
+
+GetConsoleFontInfoT GetConsoleFontInfo;
+GetNumberOfConsoleFontsT GetNumberOfConsoleFonts;
+SetConsoleFontT SetConsoleFont;
+
/* index color */
enum {
kColor0 = 0,
@@ -652,6 +668,8 @@ static BOOL create_window(ckOpt& opt)
HINSTANCE hInstance = GetModuleHandle(NULL);
LPWSTR className = L"CkwWindowClass";
+ const char* conf_title;
+ LPWSTR title;
WNDCLASSEX wc;
DWORD style = WS_OVERLAPPEDWINDOW;
DWORD exstyle = WS_EX_ACCEPTFILES;
@@ -678,6 +696,15 @@ static BOOL create_window(ckOpt& opt)
if(opt.isIconic())
style |= WS_MINIMIZE;
+ conf_title = opt.getTitle();
+ if(!conf_title || !conf_title[0]){
+ title = L"ckw";
+ }else{
+ title = new wchar_t[ strlen(conf_title)+1 ];
+ ZeroMemory(title, sizeof(wchar_t) * (strlen(conf_title)+1));
+ MultiByteToWideChar(CP_ACP, 0, conf_title, strlen(conf_title), title, sizeof(wchar_t) * (strlen(conf_title)+1));
+ }
+
/* calc window size */
CONSOLE_SCREEN_BUFFER_INFO csi;
GetConsoleScreenBufferInfo(gStdOut, &csi);
@@ -731,11 +758,13 @@ static BOOL create_window(ckOpt& opt)
if(! RegisterClassEx(&wc))
return(FALSE);
- HWND hWnd = CreateWindowEx(exstyle, className, L"ckw", style,
+ HWND hWnd = CreateWindowEx(exstyle, className, title, style,
posx, posy, width, height,
NULL, NULL, hInstance, NULL);
- if(!hWnd)
+ if(!hWnd){
+ delete [] title;
return(FALSE);
+ }
sysmenu_init(hWnd);
@@ -749,7 +778,7 @@ static BOOL create_window(ckOpt& opt)
}
/*----------*/
-static BOOL create_child_process(const char* cmd)
+static BOOL create_child_process(const char* cmd, const char* curdir)
{
trace("create_child_process\n");
@@ -776,7 +805,7 @@ static BOOL create_child_process(const char* cmd)
si.hStdError = gStdErr;
if(! CreateProcessA(NULL, buf, NULL, NULL, TRUE,
- 0, NULL, NULL, &si, &pi)) {
+ 0, NULL, curdir, &si, &pi)) {
delete [] buf;
return(FALSE);
}
@@ -871,6 +900,18 @@ BOOL WINAPI sig_handler(DWORD n)
static BOOL create_console(ckOpt& opt)
{
+ const char* conf_title;
+ LPWSTR title;
+
+ conf_title = opt.getTitle();
+ if(!conf_title || !conf_title[0]){
+ title = L"ckw";
+ }else{
+ title = new wchar_t[ strlen(conf_title)+1 ];
+ ZeroMemory(title, sizeof(wchar_t) * (strlen(conf_title)+1));
+ MultiByteToWideChar(CP_ACP, 0, conf_title, strlen(conf_title), title, sizeof(wchar_t) * (strlen(conf_title)+1));
+ }
+
__hide_alloc_console();
while((gConWnd = GetConsoleWindow()) == NULL) {
@@ -880,7 +921,7 @@ static BOOL create_console(ckOpt& opt)
ShowWindow(gConWnd, SW_HIDE);
Sleep(10);
}
- SetConsoleTitle(L"ckw");
+ SetConsoleTitle(title);
SetConsoleCtrlHandler(sig_handler, TRUE);
@@ -902,6 +943,41 @@ static BOOL create_console(ckOpt& opt)
if(!gConWnd || !gStdIn || !gStdOut || !gStdErr)
return(FALSE);
+ HINSTANCE hLib;
+ hLib = LoadLibraryW( L"KERNEL32.DLL" );
+ if (hLib == NULL)
+ goto done;
+
+ #define GetProc( proc ) \
+ do { \
+ proc = (proc##T)GetProcAddress( hLib, #proc ); \
+ if (proc == NULL) \
+ goto freelib; \
+ } while (0)
+ GetProc( GetConsoleFontInfo );
+ GetProc( GetNumberOfConsoleFonts );
+ GetProc( SetConsoleFont );
+ #undef GetProc
+
+ {
+ CONSOLE_FONT font[MAX_FONTS];
+ DWORD fonts;
+ fonts = GetNumberOfConsoleFonts();
+ if (fonts > MAX_FONTS)
+ fonts = MAX_FONTS;
+
+ GetConsoleFontInfo(gStdOut, 0, fonts, font);
+ CONSOLE_FONT minimalFont = { 0, {0, 0}};
+ for(DWORD i=0;i<fonts;i++){
+ if(minimalFont.dim.X < font[i].dim.X && minimalFont.dim.Y < font[i].dim.Y)
+ minimalFont = font[i];
+ }
+ SetConsoleFont(gStdOut, minimalFont.index);
+ }
+ freelib:
+ FreeLibrary( hLib );
+ done:
+
/* set buffer & window size */
COORD size;
SMALL_RECT sr = {0,0,0,0};
@@ -989,7 +1065,7 @@ static BOOL initialize()
trace("create_font failed\n");
return(FALSE);
}
- if(! create_child_process(opt.getCmd())) {
+ if(! create_child_process(opt.getCmd(), opt.getCurDir())) {
trace("create_child_process failed\n");
return(FALSE);
}
View
@@ -822,9 +822,9 @@ static void extract(char *str, std::string& app, std::string& name, std::string&
app = str;
name = c1;
c4 = c2 + strlen(c2)-1;
- for( ; c2 < c4 && *c2<=' ' ; c2++);
- for(c3 = c4 ; c3 > c2 && *c3<=' ' ; c3--);
- if(*++c3 <= ' ') *c3 = 0;
+ for( ; c2 < c4 && *c2<=' ' && *c2>0 ; c2++);
+ for(c3 = c4 ; c3 > c2 && *c3<=' ' && *c2>0 ; c3--);
+ if(*++c3 <= ' ' && *c3 > 0) *c3 = 0;
value = c2;
}
@@ -1027,6 +1027,9 @@ int ckOpt::setOption(const char *name, const char *value, bool rsrc)
CHK_MISC("transp", "tr", m_transp = atoi(value));
CHK_MISC("transpColor", "trc", m_isTranspColor = lookupColor(value,m_transpColor));
CHK_BOOL("topmost", "top", m_isTopMost);
+ CHK_MISC("chdir", "cd", m_curDir = value);
+ CHK_MISC("exec", "x", m_cmd = value);
+ CHK_MISC("title", "tl", m_title = value);
unsigned int i;
if(sscanf(name, "color%u", &i)==1 && 0<=i && i<=15) {
@@ -1073,6 +1076,9 @@ static void usage(bool isLong)
"transp", "tr", "number", "alpha 0 ~ 255",
"transpColor", "trc", "color", "color key",
"topmost", "top", "boolean", "always on top",
+ "chdir", "cd", "string", "set current dir",
+ "exec", "x", "string", "exec shell",
+ "title", "tl", "string", "window title",
};
unsigned int i;
@@ -1131,7 +1137,7 @@ void ckOpt::loadXdefaults()
GetModuleFileNameA(NULL, path, MAX_PATH);
c = strrchr(path, '.');
if(c) *c = 0;
- strcat(path, ".txt");
+ strcat(path, ".cfg");
_loadXdefaults(path);
if(GetEnvironmentVariableA("HOME", path, MAX_PATH)) {
View
@@ -51,6 +51,14 @@ class ckOpt {
{
return((m_bgBmp.size()) ? m_bgBmp.c_str() : NULL);
}
+ const char* getCurDir()
+ {
+ return((m_curDir.size()) ? m_curDir.c_str() : NULL);
+ }
+ const char* getTitle()
+ {
+ return((m_title.size()) ? m_title.c_str() : NULL);
+ }
protected:
@@ -84,6 +92,8 @@ class ckOpt {
bool m_isTranspColor;
COLORREF m_transpColor;
bool m_isTopMost;
+ std::string m_curDir;
+ std::string m_title;
};
#endif /* __CK_OPT_H__ */
View
@@ -0,0 +1,15 @@
+@echo off
+set VERSION_MAJOR=0
+set VERSION_MINOR=8
+set VERSION_BGFIX=10
+set VERSION_NUM=008101
+set DATE=%date% %time:~0,8% UTC+9
+
+echo #define VERSION_MAJOR %VERSION_MAJOR%
+echo #define VERSION_MINOR %VERSION_MINOR%
+echo #define VERSION_BUGFIX %VERSION_BGFIX%
+echo #define VERSION_STRING "%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_BGFIX%-mod"
+echo #define VERSION_NUMSTRING "%VERSION_NUM%"
+echo #define BUILDDATE_STRING "%DATE%"
+echo #define COPYRIGHT_STRING "Copyright (C) 2005 Kazuo Ishii <k-ishii@wb4.so-net.ne.jp>"
+echo #define ABOUT_DLG_STRING "ckw version %VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_BGFIX%-mod , build %DATE%\r\nCopyright (C) 2005 Kazuo Ishii <k-ishii@wb4.so-net.ne.jp>"
View
@@ -1,8 +1,8 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 8
#define VERSION_BUGFIX 10
-#define VERSION_STRING "0.8.10"
-#define VERSION_NUMSTRING "00810"
-#define BUILDDATE_STRING "2005/10/27 23:08:14 UTC+9"
-#define COPYRIGHT_STRING "Copyright (C) 2005 Kazuo Ishii <k-ishii@wb4.so-net.ne.jp>"
-#define ABOUT_DLG_STRING "ckw version 0.8.10 , build 2005/10/27 23:08:14 UTC+9\r\nCopyright (C) 2005 Kazuo Ishii <k-ishii@wb4.so-net.ne.jp>"
+#define VERSION_STRING "0.8.10-mod"
+#define VERSION_NUMSTRING "008101"
+#define BUILDDATE_STRING "2007/11/15 2:47:03 UTC+9"
+#define COPYRIGHT_STRING "Copyright (C) 2005 Kazuo Ishii <k-ishii@wb4.so-net.ne.jp>"
+#define ABOUT_DLG_STRING "ckw version 0.8.10-mod , build 2007/11/15 2:47:03 UTC+9\r\nCopyright (C) 2005 Kazuo Ishii <k-ishii@wb4.so-net.ne.jp>"
View
@@ -1,17 +0,0 @@
-#!/bin/sh
-
-VERSION_MAJOR=0
-VERSION_MINOR=8
-VERSION_BGFIX=10
-VERSION_NUM=00810
-DATE=`date "+%Y/%m/%d %H:%M:%S UTC+9"`
-
-echo \#define VERSION_MAJOR $VERSION_MAJOR
-echo \#define VERSION_MINOR $VERSION_MINOR
-echo \#define VERSION_BUGFIX $VERSION_BGFIX
-echo \#define VERSION_STRING \"$VERSION_MAJOR.$VERSION_MINOR.$VERSION_BGFIX\"
-echo \#define VERSION_NUMSTRING \"$VERSION_NUM\"
-echo \#define BUILDDATE_STRING \"$DATE\"
-echo \#define COPYRIGHT_STRING \"Copyright \(C\) 2005 Kazuo Ishii \<k-ishii@wb4.so-net.ne.jp\>\"
-
-echo \#define ABOUT_DLG_STRING \"ckw version $VERSION_MAJOR.$VERSION_MINOR.$VERSION_BGFIX , build $DATE\\r\\nCopyright \(C\) 2005 Kazuo Ishii \<k-ishii@wb4.so-net.ne.jp\>\"

0 comments on commit 98974d7

Please sign in to comment.