From d3cd6a63a0fff7cc77f26b319d61ba256aae680c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sun, 7 Aug 2022 22:22:38 +0200 Subject: Add showtodo script. --- Makefile | 10 +++++++++- c/main.cpp | 18 ++++++------------ showtodo | 27 +++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 13 deletions(-) create mode 100644 showtodo diff --git a/Makefile b/Makefile index 444b9ea..8ed6fed 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,9 @@ CLFLAGS += -Wall -Wextra -Wpedantic -Wno-missing-field-initializers -Wno-parenth CLFLAGS += -ld-options,-mwindows,-static-libstdc++ -lcomctl32 #CLFLAGS += -ld-options,-mconsole +WINI = C:/Perl/c/x86_64-w64-mingw32/include +WINH = $(WINI)/win*.h $(WINI)/basetsd.h + all: showdeps b/$(EXE) cp b/$(EXE) "C:\Users\John\Desktop\Delat" @@ -17,7 +20,7 @@ clean: rm -fr b/$(EXE) b/*.obj TAGS: c/*.cpp c/*.h pl/*.pl - etags c/*.cpp c/*.h -lprolog pl/*.pl + etags c/*.cpp c/*.h $(WINH) -lprolog pl/*.pl b/$(EXE): Makefile c/main.cpp $(OBJ) $(PL) $(CL) $(CLFLAGS) -goal true -o $@ c/main.cpp $(OBJ) $(PL) @@ -38,6 +41,11 @@ s/%.s: c/%.cpp showdeps: @perl showdeps +# showdeps prints all TODO comments in the C++ source files. +.PHONY: showtodo +showtodo: + @perl showtodo + # deps.mk includes additional, dynamically generated dependencies for # b/*.obj and b/EpisodeBrowser.exe. Because it is included below, GNU # make should build deps.mk automatically. diff --git a/c/main.cpp b/c/main.cpp index 5a7ec27..758889f 100644 --- a/c/main.cpp +++ b/c/main.cpp @@ -258,20 +258,12 @@ LRESULT CALLBACK WndProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam, break; case 0x02E0: /* WM_DPICHANGED */ { - const RECT* const r = reinterpret_cast(lParam); - - /* Update DPI and cached metrics. */ - g_dpi = HIWORD(wParam); - Metric = GetSystemMetrics(SM_CXVSCROLL); - Metric = GetSystemMetrics(SM_CXDOUBLECLK); - Metric = GetSystemMetrics(SM_CYDOUBLECLK); - /* TODO: What does GetSystemMetrics return depending - * on the DPI? The documentation says it is not - * DPI-aware. Does that mean that Dpi( - * GetSystemMetrics(...)) will give the correct value? - * If so, the cached values need not be updated. */ + * on the DPI? Do the cached values need to be updated + * when the DPI changes? */ + g_dpi = HIWORD(wParam); + const RECT* const r = reinterpret_cast(lParam); Prefer(SetWindowPos(hWnd, nullptr, r->left, r->top, r->right-r->left, @@ -410,6 +402,8 @@ void HandleMainMenu(const HWND hWnd, const WORD command) Pl("cfg","set_view_watched",g_bViewWatched); g_elv->Update(); g_elv->EnsureFocusVisible(); + /* TODO: Remember last valid focus. In case of + * non-existing focus, use the last valid focus. */ break; case IDM_VIEW_TV_ORIGINAL: CheckMenuItem(GetMenu(hWnd), IDM_VIEW_TV_ORIGINAL, g_bViewTVOriginal? MF_UNCHECKED: MF_CHECKED); diff --git a/showtodo b/showtodo new file mode 100644 index 0000000..475e492 --- /dev/null +++ b/showtodo @@ -0,0 +1,27 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +# Note that this script only supports /* C-style */ comments. + +while (my $f = glob("c/*.*")) { + open my $fh, "<", $f; + my $line; + while (<$fh>) { + $line++; + next if not m{TODO:}; # Skip fast. + + next if not m{^\s*/?\*.*\s(TODO:.*)\s*(\*/)?}; + print "$f:$line: $1\n"; + next if $2; + + # Continue text if comment is not finished. + my $pad = " " x length("$f:$line: "); + while (<$fh>) { + (my $text = $_) =~ s{^\s*\*?\s*|\s*\*/}{}g; + print "$pad$text"; + last if m{\*/}; + } + } +} -- cgit v1.2.3