Skip to content

Commit 8cef77c

Browse files
committed
Bugfixes and improvements in FindFile and other areas
1. Correctly show delete indicator if the directory scan before it was cancelled. 2. A few more fullwidth-related improvements. 3. Workaround for a conhost bug in DirectX mode. 4. Properly update Find File status bar. 5. Properly discard previous Find File results in all cases. 6. Speed up Find File by removing a few quadratic algorithms from the listbox / menu implementation.
1 parent afecc83 commit 8cef77c

17 files changed

+314
-172
lines changed

.editorconfig

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,68 @@
11
root = true
22

3-
[*.{c,cpp,h,hpp}]
4-
charset = utf-8-bom
5-
indent_style = tab
6-
end_of_line = lf
3+
[*]
4+
charset = utf-8
75
trim_trailing_whitespace = true
6+
end_of_line = lf
87
insert_final_newline = true
8+
indent_style = tab
9+
10+
[*.{c,cpp,h,hpp}]
11+
charset = utf-8-bom
12+
cpp_indent_braces = false
13+
cpp_indent_multi_line_relative_to = statement_begin
14+
cpp_indent_within_parentheses = indent
15+
cpp_indent_case_contents = true
16+
cpp_indent_case_labels = false
17+
cpp_indent_case_contents_when_block = true
18+
cpp_indent_lambda_braces_when_parameter = true
19+
cpp_indent_preprocessor = leftmost_column
20+
cpp_indent_access_specifiers = false
21+
cpp_indent_namespace_contents = true
22+
cpp_new_line_before_open_brace_namespace = new_line
23+
cpp_new_line_before_open_brace_type = new_line
24+
cpp_new_line_before_open_brace_function = new_line
25+
cpp_new_line_before_open_brace_block = new_line
26+
cpp_new_line_before_open_brace_lambda = new_line
27+
cpp_new_line_scope_braces_on_separate_lines = true
28+
cpp_new_line_close_brace_same_line_empty_type = false
29+
cpp_new_line_close_brace_same_line_empty_function = false
30+
cpp_new_line_before_catch = true
31+
cpp_new_line_before_else = true
32+
cpp_new_line_before_while_in_do_while = true
33+
cpp_space_before_function_open_parenthesis = remove
34+
cpp_space_within_parameter_list_parentheses = false
35+
cpp_space_between_empty_parameter_list_parentheses = false
36+
cpp_space_after_keywords_in_control_flow_statements = true
37+
cpp_space_within_control_flow_statement_parentheses = false
38+
cpp_space_before_lambda_open_parenthesis = false
39+
cpp_space_within_cast_parentheses = false
40+
cpp_space_after_cast_close_parenthesis = false
41+
cpp_space_within_expression_parentheses = false
42+
cpp_space_before_block_open_brace = false
43+
cpp_space_between_empty_braces = false
44+
cpp_space_before_initializer_list_open_brace = false
45+
cpp_space_within_initializer_list_braces = true
46+
cpp_space_preserve_in_initializer_list = false
47+
cpp_space_before_open_square_bracket = false
48+
cpp_space_within_square_brackets = false
49+
cpp_space_before_empty_square_brackets = false
50+
cpp_space_between_empty_square_brackets = false
51+
cpp_space_group_square_brackets = true
52+
cpp_space_within_lambda_brackets = false
53+
cpp_space_between_empty_lambda_brackets = false
54+
cpp_space_before_comma = false
55+
cpp_space_after_comma = true
56+
cpp_space_remove_around_member_operators = true
57+
cpp_space_before_inheritance_colon = false
58+
cpp_space_before_constructor_colon = false
59+
cpp_space_remove_before_semicolon = true
60+
cpp_space_after_semicolon = true
61+
cpp_space_remove_around_unary_operator = true
62+
cpp_space_around_binary_operator = insert
63+
cpp_space_around_assignment_operator = true
64+
cpp_space_pointer_reference_alignment = left
65+
cpp_space_around_ternary_operator = ignore
66+
67+
[*.md]
68+
trim_trailing_whitespace = false

far/changelog

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
--------------------------------------------------------------------------------
2+
drkns 10.07.2021 15:55:20 +0100 - build 5845
3+
4+
1. Correctly show delete indicator if the directory scan before it was cancelled.
5+
6+
2. A few more fullwidth-related improvements.
7+
8+
3. Workaround for a conhost bug in DirectX mode.
9+
10+
4. Properly update Find File status bar.
11+
12+
5. Properly discard previous Find File results in all cases.
13+
14+
6. Speed up Find File by removing a few quadratic algorithms from the listbox / menu implementation.
15+
116
--------------------------------------------------------------------------------
217
drkns 06.07.2021 17:17:17 +0100 - build 5844
318

far/char_width.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,12 @@ namespace
408408
return codepoint_width::narrow;
409409
}
410410

411+
[[nodiscard]]
412+
static auto is_bmp(char_width::codepoint const Codepoint)
413+
{
414+
return Codepoint <= std::numeric_limits<wchar_t>::max();
415+
}
416+
411417
[[nodiscard]]
412418
static auto device_width(char_width::codepoint const Codepoint, bool const ClearCacheOnly = false)
413419
{
@@ -423,7 +429,7 @@ namespace
423429
return codepoint_width::ambiguous;
424430
}
425431

426-
const auto IsBMP = Codepoint <= std::numeric_limits<wchar_t>::max();
432+
const auto IsBMP = is_bmp(Codepoint);
427433

428434
if (IsBMP)
429435
{
@@ -478,7 +484,7 @@ namespace char_width
478484
{
479485
default:
480486
case full_width::off:
481-
return false;
487+
return !is_bmp(Codepoint);
482488

483489
case full_width::automatic:
484490
if (!is_fullwidth_needed())

far/config.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3452,7 +3452,7 @@ int GetFarIniInt(string_view const AppName, string_view const KeyName, int Defau
34523452
return GetPrivateProfileInt(null_terminated(AppName).c_str(), null_terminated(KeyName).c_str(), Default, Global->g_strFarINI.c_str());
34533453
}
34543454

3455-
std::chrono::steady_clock::duration GetRedrawTimeout() noexcept
3455+
std::chrono::milliseconds GetRedrawTimeout() noexcept
34563456
{
34573457
return std::chrono::milliseconds(Global->Opt->RedrawTimeout);
34583458
}

far/config.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,6 @@ class Options: noncopyable
10861086
string GetFarIniString(string_view AppName, string_view KeyName, string_view Default);
10871087
int GetFarIniInt(string_view AppName, string_view KeyName, int Default);
10881088

1089-
std::chrono::steady_clock::duration GetRedrawTimeout() noexcept;
1089+
std::chrono::milliseconds GetRedrawTimeout() noexcept;
10901090

10911091
#endif // CONFIG_HPP_E468759B_688C_4D45_A5BA_CF1D4FCC9A08

far/console.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,8 @@ namespace console_detail
557557

558558
// in XP FontInfo.dwFontSize contains something else than the size in pixels.
559559
FontInfo.dwFontSize = GetConsoleFontSize(OutputHandle, FontInfo.nFont);
560-
return true;
560+
561+
return FontInfo.dwFontSize.X && FontInfo.dwFontSize.Y;
561562
}
562563

563564
// Workaround for a bug in the classic console: mouse position is screen-based

far/delete.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,14 +476,13 @@ static void show_confirmation(
476476
cancel_operation();
477477
}
478478

479-
static auto calculate_total(panel_ptr const SrcPanel)
479+
static total_items calculate_total(panel_ptr const SrcPanel)
480480
{
481-
total_items Total;
482-
483481
if (!Global->Opt->DelOpt.ShowTotal)
484-
return Total;
482+
return {};
485483

486484
const time_check TimeCheck;
485+
total_items Total;
487486

488487
const auto DirInfoCallback = [&](string_view const Name, unsigned long long const ItemsCount, unsigned long long const Size)
489488
{
@@ -501,7 +500,7 @@ static auto calculate_total(panel_ptr const SrcPanel)
501500
DirInfoData Data = {};
502501

503502
if (GetDirInfo(i.FileName, Data, nullptr, DirInfoCallback, 0) <= 0)
504-
continue;
503+
return {};
505504

506505
Total.Items += Data.FileCount + Data.DirCount;
507506
Total.Size += Data.FileSize;

far/dialog.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,14 @@ static string_view ItemString(const DialogItemEx *Data)
197197
return Str;
198198
}
199199

200-
static size_t ConvertItemEx2(const DialogItemEx *ItemEx, FarGetDialogItem *Item)
200+
static size_t ConvertItemEx2(const DialogItemEx *ItemEx, FarGetDialogItem *Item, bool const ConvertListbox)
201201
{
202202
auto size = aligned_sizeof<FarDialogItem>();
203203
const auto offsetList = size;
204204
auto offsetListItems = size;
205205
vmenu_ptr ListBox;
206206
size_t ListBoxSize = 0;
207-
if (ItemEx->Type==DI_LISTBOX || ItemEx->Type==DI_COMBOBOX)
207+
if (ConvertListbox && (ItemEx->Type==DI_LISTBOX || ItemEx->Type==DI_COMBOBOX))
208208
{
209209
ListBox=ItemEx->ListPtr;
210210
if (ListBox)
@@ -1115,7 +1115,7 @@ bool Dialog::GetItemRect(size_t I, SMALL_RECT& Rect)
11151115
case DI_MEMOEDIT:
11161116
break;
11171117
default:
1118-
Len = static_cast<int>((Item.Flags & DIF_SHOWAMPERSAND)? Item.strData.size() : HiStrlen(Item.strData));
1118+
Len = static_cast<int>((Item.Flags & DIF_SHOWAMPERSAND)? visual_string_length(Item.strData) : HiStrlen(Item.strData));
11191119
break;
11201120
}
11211121

@@ -1708,9 +1708,9 @@ void Dialog::ShowDialog(size_t ID)
17081708
GotoXY(X, m_Where.top + CY1);
17091709

17101710
if (Item.Flags & DIF_SHOWAMPERSAND)
1711-
Text(strStr);
1711+
Text(strStr, LenText);
17121712
else
1713-
HiText(strStr,ItemColor[1]);
1713+
HiText(strStr,ItemColor[1], LenText);
17141714
}
17151715

17161716
break;
@@ -1835,9 +1835,9 @@ void Dialog::ShowDialog(size_t ID)
18351835
SetColor(ItemColor[0]);
18361836

18371837
if (Item.Flags & DIF_SHOWAMPERSAND)
1838-
Text(strResult);
1838+
Text(strResult, LenText);
18391839
else
1840-
HiText(strResult,ItemColor[1]);
1840+
HiText(strResult,ItemColor[1], LenText);
18411841

18421842
if (++CountLine >= static_cast<DWORD>(CH))
18431843
break;
@@ -2130,12 +2130,12 @@ int Dialog::LenStrItem(size_t ID)
21302130

21312131
int Dialog::LenStrItem(size_t ID, string_view const Str) const
21322132
{
2133-
return static_cast<int>((Items[ID].Flags & DIF_SHOWAMPERSAND)? Str.size() : HiStrlen(Str));
2133+
return static_cast<int>((Items[ID].Flags & DIF_SHOWAMPERSAND)? visual_string_length(Str) : HiStrlen(Str));
21342134
}
21352135

21362136
int Dialog::LenStrItem(const DialogItemEx& Item)
21372137
{
2138-
return static_cast<int>((Item.Flags & DIF_SHOWAMPERSAND)? Item.strData.size() : HiStrlen(Item.strData));
2138+
return static_cast<int>((Item.Flags & DIF_SHOWAMPERSAND)? visual_string_length(Item.strData) : HiStrlen(Item.strData));
21392139
}
21402140

21412141
bool Dialog::ProcessMoveDialog(DWORD Key)
@@ -5303,11 +5303,11 @@ intptr_t Dialog::SendMessage(intptr_t Msg,intptr_t Param1,void* Param2)
53035303
case DN_EDITCHANGE:
53045304
{
53055305
FarGetDialogItem Item={sizeof(FarGetDialogItem),0,nullptr};
5306-
Item.Size=ConvertItemEx2(CurItem,nullptr);
5306+
Item.Size = ConvertItemEx2(CurItem, nullptr, false);
53075307
block_ptr<FarDialogItem> Buffer(Item.Size);
53085308
Item.Item = Buffer.data();
53095309
intptr_t I=FALSE;
5310-
if(ConvertItemEx2(CurItem,&Item)<=Item.Size)
5310+
if (ConvertItemEx2(CurItem, &Item, false) <= Item.Size)
53115311
{
53125312
if(CurItem->Type==DI_EDIT||CurItem->Type==DI_COMBOBOX||CurItem->Type==DI_FIXEDIT||CurItem->Type==DI_PSWEDIT)
53135313
{
@@ -5424,11 +5424,11 @@ intptr_t Dialog::SendMessage(intptr_t Msg,intptr_t Param1,void* Param2)
54245424
case DN_DRAWDLGITEM:
54255425
{
54265426
FarGetDialogItem Item={sizeof(FarGetDialogItem),0,nullptr};
5427-
Item.Size=ConvertItemEx2(CurItem,nullptr);
5427+
Item.Size = ConvertItemEx2(CurItem, nullptr, false);
54285428
block_ptr<FarDialogItem> Buffer(Item.Size);
54295429
Item.Item = Buffer.data();
54305430
intptr_t I=FALSE;
5431-
if(ConvertItemEx2(CurItem,&Item)<=Item.Size)
5431+
if (ConvertItemEx2(CurItem, &Item, false) <= Item.Size)
54325432
{
54335433
I=DlgProc(Msg,Param1,Item.Item);
54345434

@@ -5751,7 +5751,7 @@ intptr_t Dialog::SendMessage(intptr_t Msg,intptr_t Param1,void* Param2)
57515751
case DM_GETDLGITEM:
57525752
{
57535753
const auto Item = static_cast<FarGetDialogItem*>(Param2);
5754-
return (CheckNullOrStructSize(Item)) ? static_cast<intptr_t>(ConvertItemEx2(CurItem, Item)) : 0;
5754+
return (CheckNullOrStructSize(Item))? static_cast<intptr_t>(ConvertItemEx2(CurItem, Item, true)) : 0;
57555755
}
57565756
/*****************************************************************/
57575757
case DM_GETDLGITEMSHORT:

far/diskmenu.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -857,12 +857,12 @@ static int ChangeDiskMenu(panel_ptr Owner, int Pos, bool FirstCall)
857857
}
858858
}
859859

860-
TypeWidth = std::max(TypeWidth, NewItem.Type.size());
861-
LabelWidth = std::max(LabelWidth, NewItem.Label.size());
862-
FsWidth = std::max(FsWidth, NewItem.Fs.size());
863-
TotalSizeWidth = std::max(TotalSizeWidth, NewItem.TotalSize.size());
864-
FreeSizeWidth = std::max(FreeSizeWidth, NewItem.FreeSize.size());
865-
PathWidth = std::max(PathWidth, NewItem.AssociatedPath.size());
860+
TypeWidth = std::max(TypeWidth, visual_string_length(NewItem.Type));
861+
LabelWidth = std::max(LabelWidth, visual_string_length(NewItem.Label));
862+
FsWidth = std::max(FsWidth, visual_string_length(NewItem.Fs));
863+
TotalSizeWidth = std::max(TotalSizeWidth, visual_string_length(NewItem.TotalSize));
864+
FreeSizeWidth = std::max(FreeSizeWidth, visual_string_length(NewItem.FreeSize));
865+
PathWidth = std::max(PathWidth, visual_string_length(NewItem.AssociatedPath));
866866

867867
Items.emplace_back(NewItem);
868868
};

far/far.natvis

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@
156156
<DisplayString Condition="is_f_index(0xd)">fuchsia</DisplayString>
157157
<DisplayString Condition="is_f_index(0xe)">yellow</DisplayString>
158158
<DisplayString Condition="is_f_index(0xf)">white</DisplayString>
159+
<Expand>
160+
<Item Name="alpha">short(ForegroundRGBA.a)</Item>
161+
</Expand>
159162
</Synthetic>
160163
<Synthetic Name="Background">
161164
<DisplayString Condition="is_b_rgb()">{BackgroundRGBA}</DisplayString>
@@ -175,6 +178,9 @@
175178
<DisplayString Condition="is_b_index(0xd)">fuchsia</DisplayString>
176179
<DisplayString Condition="is_b_index(0xe)">yellow</DisplayString>
177180
<DisplayString Condition="is_b_index(0xf)">white</DisplayString>
181+
<Expand>
182+
<Item Name="alpha">short(BackgroundRGBA.a)</Item>
183+
</Expand>
178184
</Synthetic>
179185
<Synthetic Name="Flags">
180186
<DisplayString>{Flags,h}</DisplayString>

0 commit comments

Comments
 (0)