Ticket #1489 (closed enhancement: fixed)
Block (aka multi-line) indent
Reported by: | dborca | Owned by: | angel_il |
---|---|---|---|
Priority: | major | Milestone: | 4.7.0-pre4 |
Component: | mcedit | Version: | 4.7.0-pre1 |
Keywords: | Cc: | dborca@… | |
Blocked By: | Blocking: | ||
Branch state: | Votes for changeset: | committed-master |
Description
I really liked the new feature of multi-line indent with non-persistent selections. BUT, as it is, it's cumbersome.
- Usually, I just need to quickly indent a block of code, and going into Options to turn Persistent selections off takes a lot of keypresses. So I'd rather manually indent the block of code, than changing persistent selections off and on. And I need selections. And it is easy to forget which is which. :)
- Backspace/Del? with non-persistent selections is superfluous, because there is F8 for that. With persistent selections.
- Indenting should behave EXACTLY like Tab/Backspace? will behave when used on a single, non-selected line.
Ok, so I came up with an idea, inspired from slackware-12.2/source/ap/mc/mc-4.6.1_20070623_utf8_mls_r2008-08-28.diff.gz
- I removed the persistent selection code (except the Option setting itself, because I'm lazy)
- Selections made with F3/Shift-F3 were left alone.
- Selections made with Shift + movement keys are considered "indentable", until a key other than Tab, Ctrl-Tab, Backspace, M-i or Undo is pressed. This is indicated in the status bar with an 'S' (as opposed to a 'B' for a regular selection).
- An "indentable" selection can be operated in the following ways:
- Tab will indent the block, honoring tabs, halftabs and tabs vs spaces stuff. It behaves like Tab would behave on a single, non-selected line. It maintains an "indent depth", so Undo works. Empty lines are left alone.
- BackSpace? will unindent the block. If "indent depth" (from a sequence of Tab keys) is available, it tries to unindent the block using backspace commands (behaving exacly like Tab would behave on a single, non-selected line). Otherwise it tries to unindent the block using delete commands, applied at the beginning of each line (that is, it works like implemented in 4.7.0-pre1).
- Ctrl-Tab will indent the block, always inserting (half)tabs at the beginning of the line. It works like implemented in 4.7.0-pre1 and does not honor tabs vs spaces stuff. Empty lines are left alone. Note: if used after Tab, it will reset its "indent depth" and Tab will start over at the beginning of the line.
- M-i wil indent the block, always inserting (half)tabs at the beginning of text, if any. Mostly useful when indenting code which has a mix of spaces and tabs. Empty lines are left alone. Note: if used after Tab, it will reset its "indent depth" and Tab will start over at the beginning of the line.
It's the best I could come up with to make things painless. Ideas and suggestions are welcomed. Anyway, here's the patch (against 4.7.0-pre1).
Attachments
Change History
comment:2 follow-up: ↓ 7 Changed 15 years ago by angel_il
- Usually, I just need to quickly indent a block of code, and going into Options to turn Persistent selections off takes a lot of keypresses.
just turn Persistent selections off :) and newer turn on :)
comment:3 follow-up: ↓ 8 Changed 15 years ago by angel_il
- Backspace/Del? with non-persistent selections is superfluous, because there is F8 for that. With persistent selections.
its (BS/Del - delete selected text) the actual standard for many editors.
comment:4 follow-up: ↓ 9 Changed 15 years ago by angel_il
- Indenting should behave EXACTLY like Tab/Backspace? will behave when used on a single, non-selected line.
but Tab/Backspace? on a single, non-selected line work as tab / backspace
tab - insert <tab>, backspace - delete 1 char.
Or what do you mean?
comment:5 Changed 15 years ago by angel_il
- BackSpace? will unindent the block.
will be after #212 just re-define BackSpace?
comment:6 follow-up: ↓ 10 Changed 15 years ago by angel_il
- Ctrl-Tab will indent the block
we can not use Ctrl-Tab, many terminals not sent esc-seq on this hotkey.
comment:7 in reply to: ↑ 2 Changed 15 years ago by dborca
Replying to angel_il:
- Usually, I just need to quickly indent a block of code, and going into Options to turn Persistent selections off takes a lot of keypresses.
just turn Persistent selections off :) and newer turn on :)
And then do what with them? Besides indenting, they're useless.
comment:8 in reply to: ↑ 3 Changed 15 years ago by dborca
Replying to angel_il:
- Backspace/Del? with non-persistent selections is superfluous, because there is F8 for that. With persistent selections.
its (BS/Del - delete selected text) the actual standard for many editors.
Well, for mcedit, F8 is the de facto standard, for many, many, many years now. Users of mc won't complain about that.
About BackSpace?, you are right. I was under the wrong impression. Sorry.
But let's take an example: Visual Studio 2008... no wait! that's evil... SciTe/Scintilla? uses Alt-Backspace for block unindenting. Hmm... that key is taken for Kill Back Word.
comment:9 in reply to: ↑ 4 Changed 15 years ago by dborca
Replying to angel_il:
- Indenting should behave EXACTLY like Tab/Backspace? will behave when used on a single, non-selected line.
but Tab/Backspace? on a single, non-selected line work as tab / backspace
tab - insert <tab>, backspace - delete 1 char.
Or what do you mean?
Not if you have the default configuration:
[x] Fake half tabs
[ ] Backspace through tabs
[ ] Fill tabs with spaces
Tab spacing: 8
Step0:
text
Step1: hit Tab
text
Step2: hit Tab
<------>text
Step3: hit Tab
<------> text
Step4: hit Backspace
<------>text
Step5: hit Backspace
text
I think you get the idea.
comment:10 in reply to: ↑ 6 Changed 15 years ago by dborca
Replying to angel_il:
- Ctrl-Tab will indent the block
we can not use Ctrl-Tab, many terminals not sent esc-seq on this hotkey.
Ok, then we have to find another suggestive hotkey. They become increasincly scarce :(
Ctrl-Tab/Ctrl?-I and Shift-Tab is replaced by src/key.c#correct_key_code() to KEY_BTAB
Does Ctrl-I/Shift-Tab work on the aforementioned terminals?
PS: sorry about the previous post. I should've used monospace.
comment:13 Changed 15 years ago by angel_il
- Owner set to angel_il
- Status changed from new to accepted
- severity changed from no branch to on review
branch: 1489_block_indent (parent: master)
changeset: 3de45b9b85a43215d5331276fa5e4628d9427009
comment:14 Changed 15 years ago by angel_il
changeset: 18a183fbd41d428ad7eb6d9492c525288925053b (force update)
comment:16 Changed 15 years ago by angel_il
118ee1487a7cb01c35a83255f7ce46f07050e27c (force update)
comment:17 Changed 15 years ago by andrew_b
- Votes for changeset changed from slavazanko to slavazanko andrew_b
- severity changed from on review to approved
comment:18 Changed 15 years ago by angel_il
- Status changed from accepted to testing
- Votes for changeset changed from slavazanko andrew_b to commited-master
- Resolution set to fixed
- severity changed from approved to merged