Skip to content

Commit

Permalink
ダイアログの調整
Browse files Browse the repository at this point in the history
  • Loading branch information
ohtorii committed Oct 30, 2019
1 parent 39a2080 commit 74fce55
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 33 deletions.
71 changes: 55 additions & 16 deletions internal/gui.mac
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/* ソース選択ダイアログ

複数ソースを絞り込み検索したいときに利用します。
# 引数
ソースのディレクトリ
(例) "c:\hidemaru\makuro\unity\sources"


引数 ソースのディレクトリ
(例) "c:\hidemaru\makuro\unity\sources"
# 返値
ソース名1\tソース名2\t...ソース名N\nオプション1\tオプション2\t...オプションN
(例) "file_mru\twindow\n-auto-preview\t-foo-option"

返値 ソース名をタブ区切りで返す
(例) "file_mru\twindow"
*/

//ソースのファイルが格納されているディレクトリ
Expand All @@ -20,6 +21,10 @@ $g_sources_dir=getarg(0);
//配列長は #g_source_names_num
$g_source_checkctrl_names[0]="";

//auto-previewのON/OFF
$g_auto_preview_checkctrl_name="auto_preview";


//ディスクから読み込んだソース名と個数
$g_source_names[0]="";
#g_source_names_num=0;
Expand Down Expand Up @@ -54,9 +59,9 @@ Start:
return "";
}
call MessageLoop;
$$select_sources=$$return;
$$ret=$$return;
call EndDialog;
return $$select_sources;
return $$ret;


CreateDialog:
Expand All @@ -80,16 +85,41 @@ CreateDialog:
##i = ##i + 1;
}

//
//オプション
//
if(dllfunc(#g_dengaku_dll,"NEWCONTROL", "hline", "", "") == 0){
message "hlinkの作成に失敗";
return false;
}
if(dllfunc(#g_dengaku_dll,"NEWCONTROL", "check", $g_auto_preview_checkctrl_name, "auto_preview") == 0){
message "checkの作成に失敗";
return false;
}

if (!dllfunc(#g_dengaku_dll,"SHOWDIALOG",hidemaruhandle(0),1)){
message "SHOWDIALOG に失敗しました";
return false;
}
return true;

#K_CTRL = 0x11;
#K_ENTER = 0x0d;
#K_LEFT = 0x25;
#K_RIGHT = 0x27;
#K_UP = 0x26;
#K_DOWN = 0x28;
#K_SHIFT = 0x10;

MessageLoop:
while(1){
if(iskeydown(#K_UP)){
//フォーカス前移動

}else if(iskeydown(#K_DOWN)){
//フォーカス次へ移動

}
$$notify = dllfuncstr(#g_dengaku_dll,"WAITCTRLNOTIFY",0);
if($$notify == "0"){
//キャンセル
Expand All @@ -103,9 +133,10 @@ MessageLoop:
return "";

GetSelectSources:
/*選択されたソースを取得する
返値 選択されたソースをタブ区切りで返す
(例) "file_mru\tprocess"
/*選択されたソースとオプションを取得する

返値 選択されたソースとオプションを返す
(例) "file_mru\tprocess\n-auto-preview\t-foo-option"
*/
$$select_sources="";
##i=0;
Expand All @@ -121,7 +152,15 @@ GetSelectSources:
}
##i = ##i + 1;
}
return $$select_sources;
$$options="";
$$state = dllfuncstr(#g_dengaku_dll, "GETCTRLSTATE",$g_auto_preview_checkctrl_name);
if($$state=="1"){
$$options="-auto-preview";
}
if($$options==""){
return $$select_sources;
}
return $$select_sources+"\n"+$$options;


EndDialog:
Expand All @@ -132,17 +171,17 @@ EndDialog:
LoadSources:
#g_source_names_num=0;

##objFSO = createobject("Scripting.FileSystemObject");
##objFSO = createobject("Scripting.FileSystemObject");
##objFolder = callmethod_returnobj(##objFSO,"GetFolder",$g_sources_dir);
##objFiles = getpropobj(##objFolder,"Files");
##objFiles = getpropobj(##objFolder,"Files");
while(1){
##objFile = getcollection(##objFiles);
if(##objFile==0){
break;
}
$$name=getpropstr(##objFile,"Name");
$$basename=member( ##objFSO, "GetBaseName", $$name );
$$ext=tolower(member( ##objFSO, "GetExtensionName", $$name ));
$$name =getpropstr(##objFile,"Name");
$$basename =member( ##objFSO, "GetBaseName", $$name );
$$ext =tolower(member( ##objFSO, "GetExtensionName", $$name ));
releaseobject ##objFile;

if($$ext!="mac"){
Expand Down
30 changes: 22 additions & 8 deletions internal/main.mac
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
/* Unite-Vimを秀丸エディタへ移植中(まだ動かない)

usage:
unity.mac root_dir sources
unity.mac root_dir sources options

引数
引数:
root_dir unityマクロのルートディレクトリ

sources タブ区切りのソース名
(例)"file_mru\tprocess"
(例)"file_mru\tprocess"

options タブ区切りのオプション
(例)"-auto-preview\t-foo-option"

===============================================================================
Unite-vimの説明。
https://www.youtube.com/watch?v=Co4Np4SXOOc
*/

#g_tick_prev=tickcount;
Expand Down Expand Up @@ -86,16 +87,17 @@ disablehistory
0x0080 | /*/nオプション,またはopenfileのnoaddhistと同じ扱い*/
0x0100 ; /*今開いているファイル(自分自身)をヒストリに残さないようにする*/


//disableinvert;カーソルキーが表示されなくなるためコメントアウトした。
call main getarg(1);

call main getarg(1), getarg(2);
setsearch $g_old_searchbuffer, #g_old_searchoption;
endmacro;

main:
##old_column=column;
##old_lineno=lineno;

call ParseOptions $$2;
call Start $$1;
##ret = ##return;

Expand All @@ -121,6 +123,18 @@ main:

return ##ret;

ParseOptions:
#g_option_auto_preview=false;//ディフォルト値で初期化
##num=split($$options,$$1,"\t");
##i=0;
while(##i<##num){
if($$options[##i]=="-auto-preview"){
#g_option_auto_preview=true;
}
##i = ##i + 1;
}
return;

/*
return アクションが最後まで実行されたかどうか(bool)
false 実行された
Expand Down
27 changes: 18 additions & 9 deletions unity_dialog.mac
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
/* Unite-Vimを秀丸エディタへ移植中(まだ動かない)

usage:
unity.mac mode

/* ソース選択GUI
*/
//execmacro currentmacrodirectory+"\\internal\\main.mac",currentmacrodirectory,getarg(0);
execmacro currentmacrodirectory+"\\internal\\gui.mac", currentmacrodirectory+"\\sources";
$sources=getresultex(-1);
execmacro currentmacrodirectory+"\\internal\\main.mac",currentmacrodirectory,$sources;
call main;
endmacro $$return;

main:
execmacro currentmacrodirectory+"\\internal\\gui.mac", currentmacrodirectory+"\\sources";
##num=split($$contents,getresultex(-1),"\n");
if(##num==1){
$$sources=$$contents[0];
$$options="";
}else if(##num==2){
$$sources=$$contents[0];
$$options=$$contents[1];
}else{
return "0";
}
execmacro currentmacrodirectory+"\\internal\\main.mac",currentmacrodirectory,$$sources,$$options;
return getresultex(-1);

0 comments on commit 74fce55

Please sign in to comment.