Bug 194816

Summary: Can not delete bytes when not in insert mode
Product: [Applications] okteta Reporter: Thomas Capricelli <kdebugs.20.orzelf>
Component: generalAssignee: Friedrich W. H. Kossebau <kossebau>
Status: CONFIRMED ---    
Severity: wishlist CC: ademko, mi.kde-bugzilla, shlomif
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Unspecified   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Thomas Capricelli 2009-06-01 05:47:23 UTC
Version:            (using KDE 4.2.3)
Installed from:    Gentoo Packages

I have spent quite some times finding out why i couldn't do this very simple operation : suppress some selected bytes. The reason was that i was not in insert mode : once in insert mode i could just use 'del' again.
Comment 1 Friedrich W. H. Kossebau 2009-06-02 12:33:18 UTC
I agree, this behaviour could be improved or at least be more visible.
In text editors you can always remove, both in overwrite or insert mode.
But for a hex editor you also want a no-remove vs. remove mode, which is orthogonal to the two others. I thought it to be just logical to attach the remove mode to the insert mode, and the no-remove mode to the overwrite mode.
Still this suprises some it seems. Hm. Will think about if this should be separated again.
Comment 2 Shlomi Fish 2009-09-23 16:47:25 UTC
Happens for me too here on Mandriva Cooker. I could not delete the junk from the beginning of a text file, and ended up using ghex2 instead, which worked perfectly at first try. Please fix it.
Comment 3 Thomas Capricelli 2010-08-15 01:50:56 UTC
Confirmed with the KDE 4.5 release. The about box says Okteta version 0.5.0 RC2 with KDE platform 4.5.00, but this is really okteta from the 4.5 source.
Comment 4 Aleksander Demko 2016-11-06 18:08:02 UTC
Confirmed for me too. I couldn't figure how to delete a few bytes, googled "okteta delete bytes" and ended up here. I had to install ghex instead.
Comment 5 Christoph Feck 2016-11-06 22:33:17 UTC
You do not have to install a different program, when you could change Okteta from Overwrite mode (which aims to preserve file size) to Insert mode (which allows to change file size).
Comment 6 Aleksander Demko 2016-11-07 02:05:25 UTC
I guess that this is a UI bug? It's really not intuitive that you need to go into insert mode, or even that there are modes.

(and I'm a vim user :)
Comment 7 Friedrich W. H. Kossebau 2017-11-12 21:39:28 UTC
Update: still a valid unsolved report.

Needs some ideas how this seemingly surprising-to-some behaviour in overwrite mode could be better presented. Perhaps some inline infobox could be shown (with a checkbox "Now I know, no further reminder needed").

No plans to change the behaviour, given many file/data formats rely on relative positions, so the overwrite mode should strictly be about only overriding existing data.

For changing the size of the edited data, there is still the insert mode, which by name hints that data is added (and usually also be removed). Perhaps it should be renamed Insert/Remove mode?

The Overwrite/Insert mode is both shown in the status bar, as well as by the size of the editing cursor. Which should be following some conventions, so ideally good enough.
Comment 8 mi 2021-03-06 23:12:35 UTC
Yes, please fix this. I had to go to Google to find out why I could not cut selected bytes.

I get the logic why you need to be in Insert mode for cutting, and that is fine. But it must be visible!

1. The Cut entry in the Edit menu should be greyed out when not in Insert mode

2. The cut icon in the menu bar also must be greyed out when it is disabled

2b. The tooltip when hovering over the cut icon should show something like "Cut is not available in Overwrite mode" or similar, instead of the wrong "Cut selection to clipboard".

3. Pressing the Delete or Backspace key while in Overwrite mode should show an error message.
Comment 9 Friedrich W. H. Kossebau 2021-03-11 22:00:18 UTC
(In reply to mi from comment #8)
> Yes, please fix this. I had to go to Google to find out why I could not cut
> selected bytes.
> 
> I get the logic why you need to be in Insert mode for cutting, and that is
> fine. But it must be visible!
> 
> 1. The Cut entry in the Edit menu should be greyed out when not in Insert
> mode
> 
> 2. The cut icon in the menu bar also must be greyed out when it is disabled
> 
> 2b. The tooltip when hovering over the cut icon should show something like
> "Cut is not available in Overwrite mode" or similar, instead of the wrong
> "Cut selection to clipboard".
> 
> 3. Pressing the Delete or Backspace key while in Overwrite mode should show
> an error message.

Good ideas, thanks for sharing. Actually I would have thought the cut action menu
item is already disabled in that case, but nope, not in the current stable version
of Okteta. And instead I only found an old TODO note in the code from 2009 #(
Sadly the logic for this goes via some public stable APIs of the libraries that Okteta
is composed internally, so doing at least the action disabling as you proposed isn't just
a simple change.

Still pondering some ideas how to achieve this as cleanly without too much effort in the
next days to come, but only a 50% chance I will not instead delay further to the next
stable API version, which though does not even have a ETA yet.
Comment 10 Friedrich W. H. Kossebau 2021-03-20 22:20:07 UTC
Git commit 32d3eafcea789b12ac5f3041ea131addd56a89e8 by Friedrich W. H. Kossebau.
Committed on 14/03/2021 at 00:51.
Pushed by kossebau into branch '0.26'.

Disable Cut action in menu & toolbar when in overwrite mode

M  +42   -0    kasten/gui/view/bytearrayview.cpp
M  +1    -1    libs/kasten/CMakeLists.txt
M  +31   -3    libs/kasten/controllers/io/clipboard/clipboardcontroller.cpp
M  +3    -0    libs/kasten/controllers/io/clipboard/clipboardcontroller.hpp
M  +20   -0    libs/kasten/gui/view/selecteddatawriteable.hpp

https://invent.kde.org/utilities/okteta/commit/32d3eafcea789b12ac5f3041ea131addd56a89e8