Skip to content

Draft: Add --item-count option

Gordin508 requested to merge Gordin508/screenkey:add_itemcount_option into master

Allow limiting the number of inputs (keys or key combinations) being displayed by providing an --item-count n switch which restricts the display to the last n inputs. For example: --item-count 1 would only show the very last action, whereas --item-count 0 is the current (and now default) behavior which means unlimited (within displayable range).

I originally intended to just add a --single option which only shows the last action (as requested in linked issue), but since the generalization to the last n did not require any additional implementation work, i instead added a parameterized switch.

Display currently looks a bit erratic when long modifier sequences (e. g. Alt+Shift+S) get replaced by single characters and n > 1, but i don't know if that can be helped at all. The most frequent use case should be n=1 anyway.

Closes #79

WIP status: Currently, the compression just gets disabled when an item count is provided, as it interferes with the current implementation of this new feature. I'm not really sure if there is even a use case for combining compression with item count limitation.

One alternative implementation would funnel all calls to self.data.append() in the LabelManager through a new helper method, always discarding the older items. I refrained from that as it would impact quite a few code segments unrelated to this change, whereas the current implementation introduces only local adjustments.

Another alternative implementation would adjust the compression code to only search for characters inside the item-count range, which would introduce additional checks within the compression code.

Edited by Gordin508

Merge request reports