@@ -113,6 +113,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
113
113
DWORD dwTextFlags = DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS ;
114
114
RECT rcText ;
115
115
DWORD dwCL = 0 ;
116
+ BOOL bTabOrderHit = FALSE;
116
117
117
118
HDC hdcPaint = NULL ;
118
119
BP_PAINTPARAMS params = { sizeof (BP_PAINTPARAMS ) };
@@ -126,7 +127,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
126
127
wchar_t * text = malloc (MAX_LINE_LENGTH * sizeof (wchar_t ));
127
128
wchar_t * name = malloc (MAX_LINE_LENGTH * sizeof (wchar_t ));
128
129
wchar_t * section = malloc (MAX_LINE_LENGTH * sizeof (wchar_t ));
129
- size_t bufsiz = 0 , numChRd = 0 ;
130
+ size_t bufsiz = 0 , numChRd = 0 , tabOrder = 1 ;
130
131
while ((numChRd = getline (& line , & bufsiz , f )) != -1 )
131
132
{
132
133
if (strcmp (line , "Windows Registry Editor Version 5.00\r\n" ) && strcmp (line , "\r\n" ))
@@ -213,6 +214,11 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
213
214
}
214
215
if (hDC )
215
216
{
217
+ if (!strncmp (line , ";u " , 3 ) && tabOrder == _this -> tabOrder )
218
+ {
219
+ bTabOrderHit = TRUE;
220
+ DttOpts .crText = GUI_TEXTCOLOR_SELECTED ;
221
+ }
216
222
DrawThemeTextEx (
217
223
_this -> hTheme ,
218
224
hdcPaint ,
@@ -224,6 +230,10 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
224
230
& rcText ,
225
231
& DttOpts
226
232
);
233
+ if (!strncmp (line , ";u " , 3 ) && tabOrder == _this -> tabOrder )
234
+ {
235
+ DttOpts .crText = GUI_TEXTCOLOR ;
236
+ }
227
237
}
228
238
else
229
239
{
@@ -237,7 +247,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
237
247
DT_CALCRECT
238
248
);
239
249
rcTemp .bottom = rcText .bottom ;
240
- if (!strncmp (line , ";u " , 3 ) && PtInRect (& rcTemp , pt ))
250
+ if (!strncmp (line , ";u " , 3 ) && ( PtInRect (& rcTemp , pt ) || ( pt . x == 0 && pt . y == 0 && tabOrder == _this -> tabOrder ) ))
241
251
{
242
252
numChRd = getline (& line , & bufsiz , f );
243
253
char * p = strchr (line , '\r' );
@@ -414,6 +424,10 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
414
424
}
415
425
}
416
426
dwCL += dwLineHeight * dy ;
427
+ if (!strncmp (line , ";u " , 3 ))
428
+ {
429
+ tabOrder ++ ;
430
+ }
417
431
}
418
432
else if (!strncmp (line , ";l " , 3 ) || !strncmp (line , ";c " , 3 ) || !strncmp (line , ";b " , 3 ) || !strncmp (line , ";i " , 3 ) || !strncmp (line , ";d " , 3 ) || !strncmp (line , ";v " , 3 ))
419
433
{
@@ -609,7 +623,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
609
623
DT_CALCRECT
610
624
);
611
625
rcTemp .bottom = rcText .bottom ;
612
- if (!hDC && PtInRect (& rcTemp , pt ))
626
+ if (!hDC && ( PtInRect (& rcTemp , pt ) || ( pt . x == 0 && pt . y == 0 && tabOrder == _this -> tabOrder ) ))
613
627
{
614
628
if (bJustCheck )
615
629
{
@@ -723,7 +737,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
723
737
);
724
738
rcTemp .bottom = rcText .bottom ;
725
739
//printf("%d %d %d %d %d %d %d %d\n", rcText.left, rcText.top, rcText.right, rcText.bottom, rcTemp.left, rcTemp.top, rcTemp.right, rcTemp.bottom);
726
- if (PtInRect (& rcTemp , pt ))
740
+ if (PtInRect (& rcTemp , pt ) || ( pt . x == 0 && pt . y == 0 && tabOrder == _this -> tabOrder ) )
727
741
{
728
742
numChRd = getline (& line , & bufsiz , f );
729
743
char * p = strchr (line , '\r' );
@@ -742,6 +756,11 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
742
756
}
743
757
if (hDC )
744
758
{
759
+ if (tabOrder == _this -> tabOrder )
760
+ {
761
+ bTabOrderHit = TRUE;
762
+ DttOpts .crText = GUI_TEXTCOLOR_SELECTED ;
763
+ }
745
764
DrawThemeTextEx (
746
765
_this -> hTheme ,
747
766
hdcPaint ,
@@ -753,8 +772,13 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
753
772
& rcText ,
754
773
& DttOpts
755
774
);
775
+ if (tabOrder == _this -> tabOrder )
776
+ {
777
+ DttOpts .crText = GUI_TEXTCOLOR ;
778
+ }
756
779
}
757
780
dwCL += dwLineHeight * dy ;
781
+ tabOrder ++ ;
758
782
}
759
783
}
760
784
}
@@ -767,6 +791,14 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
767
791
DeleteObject (hFontTitle );
768
792
DeleteObject (hFontUnderline );
769
793
DeleteObject (hFontCaption );
794
+ if (_this -> tabOrder == GUI_MAX_TABORDER )
795
+ {
796
+ _this -> tabOrder = tabOrder ;
797
+ }
798
+ else if (!bTabOrderHit )
799
+ {
800
+ _this -> tabOrder = 0 ;
801
+ }
770
802
}
771
803
EndBufferedPaint (hBufferedPaint , TRUE);
772
804
}
@@ -825,6 +857,39 @@ static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
825
857
PostQuitMessage (0 );
826
858
return 0 ;
827
859
}
860
+ else if (uMsg == WM_KEYDOWN )
861
+ {
862
+ if (wParam == VK_ESCAPE )
863
+ {
864
+ PostMessage (hWnd , WM_CLOSE , 0 , 0 );
865
+ return 0 ;
866
+ }
867
+ else if (wParam == VK_TAB )
868
+ {
869
+ if (GetKeyState (VK_SHIFT ) & 0x8000 )
870
+ {
871
+ _this -> tabOrder -- ;
872
+ if (_this -> tabOrder == 0 )
873
+ {
874
+ _this -> tabOrder = GUI_MAX_TABORDER ;
875
+ }
876
+ }
877
+ else
878
+ {
879
+ _this -> tabOrder ++ ;
880
+ }
881
+ InvalidateRect (hWnd , NULL , FALSE);
882
+ return 0 ;
883
+ }
884
+ else if (wParam == VK_SPACE )
885
+ {
886
+ POINT pt ;
887
+ pt .x = 0 ;
888
+ pt .y = 0 ;
889
+ GUI_Build (0 , hWnd , pt );
890
+ return 0 ;
891
+ }
892
+ }
828
893
else if (uMsg == WM_NCHITTEST )
829
894
{
830
895
POINT pt ;
@@ -883,16 +948,40 @@ static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
883
948
884
949
__declspec(dllexport ) int ZZGUI (HWND hWnd , HINSTANCE hInstance , LPSTR lpszCmdLine , int nCmdShow )
885
950
{
886
- /*
887
- FILE* conout;
888
- AllocConsole();
889
- freopen_s(
890
- &conout,
891
- "CONOUT$",
892
- "w",
893
- stdout
951
+ HKEY hKey ;
952
+ DWORD dwDisposition ;
953
+ DWORD dwSize = sizeof (DWORD );
954
+ RegCreateKeyExW (
955
+ HKEY_CURRENT_USER ,
956
+ TEXT (REGPATH ),
957
+ 0 ,
958
+ NULL ,
959
+ REG_OPTION_NON_VOLATILE ,
960
+ KEY_READ ,
961
+ NULL ,
962
+ & hKey ,
963
+ & dwDisposition
894
964
);
895
- */
965
+ DWORD bAllocConsole = FALSE;
966
+ RegQueryValueExW (
967
+ hKey ,
968
+ TEXT ("AllocConsole" ),
969
+ 0 ,
970
+ NULL ,
971
+ & bAllocConsole ,
972
+ & dwSize
973
+ );
974
+ if (bAllocConsole )
975
+ {
976
+ FILE * conout ;
977
+ AllocConsole ();
978
+ freopen_s (
979
+ & conout ,
980
+ "CONOUT$" ,
981
+ "w" ,
982
+ stdout
983
+ );
984
+ }
896
985
897
986
printf ("Started \"GUI\" thread.\n" );
898
987
@@ -909,6 +998,7 @@ __declspec(dllexport) int ZZGUI(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLin
909
998
_this .padding .top = GUI_PADDING_TOP ;
910
999
_this .padding .bottom = GUI_PADDING_BOTTOM ;
911
1000
_this .hTheme = OpenThemeData (NULL , TEXT (GUI_WINDOWSWITCHER_THEME_CLASS ));
1001
+ _this .tabOrder = 0 ;
912
1002
913
1003
WNDCLASS wc = { 0 };
914
1004
ZeroMemory (& wc , sizeof (WNDCLASSW ));
0 commit comments