Ticket #1489 (closed enhancement: fixed)

Opened 7 years ago

Last modified 7 years ago

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.

  1. 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. :)
  1. Backspace/Del? with non-persistent selections is superfluous, because there is F8 for that. With persistent selections.
  1. 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

  1. I removed the persistent selection code (except the Option setting itself, because I'm lazy)
  1. Selections made with F3/Shift-F3 were left alone.
  1. 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).
  1. An "indentable" selection can be operated in the following ways:
  2. 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.
  3. 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).
  4. 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.
  5. 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

mc-4.7.0-pre1.block_tab.patch.gz (3.9 KB) - added by dborca 7 years ago.

Change History

Changed 7 years ago by dborca

comment:1 Changed 7 years ago by dborca

  • Cc dborca@… added

comment:2 follow-up: ↓ 7 Changed 7 years ago by angel_il

  1. 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 7 years ago by angel_il

  1. 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 7 years ago by angel_il

  1. 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 7 years ago by angel_il

  1. BackSpace? will unindent the block.

will be after #212 just re-define BackSpace?

comment:6 follow-up: ↓ 10 Changed 7 years ago by angel_il

  1. 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 7 years ago by dborca

Replying to angel_il:

  1. 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 7 years ago by dborca

Replying to angel_il:

  1. 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 7 years ago by dborca

Replying to angel_il:

  1. 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 7 years ago by dborca

Replying to angel_il:

  1. 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:11 Changed 7 years ago by angel_il

  • Milestone changed from 4.7.0-pre2 to 4.7.0-pre3

comment:12 Changed 7 years ago by angel_il

  • Milestone changed from 4.7.0-pre3 to 4.7.0-pre4

comment:13 Changed 7 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 7 years ago by angel_il

changeset: 18a183fbd41d428ad7eb6d9492c525288925053b (force update)

comment:15 Changed 7 years ago by slavazanko

  • Votes for changeset set to slavazanko

comment:16 Changed 7 years ago by angel_il

comment:17 Changed 7 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 7 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

comment:19 Changed 7 years ago by angel_il

  • Status changed from testing to closed
Note: See TracTickets for help on using tickets.