Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semantic linefeed feature #65

Closed
wants to merge 40 commits into from

Conversation

evandrocoan
Copy link

@evandrocoan evandrocoan commented Nov 7, 2017

Fixes #64 Semantic line wrapping support

Posted also on: https://forum.sublimetext.com/t/semantic-linefeed-wrapping-linewrap/33197

(cherry picked from commit 6c12e17)
{
    Tese submetida ao
    Federal de \showfont
}

(cherry picked from commit 2ddcdd0)
\preambulo
{
    \chooselang
    {Tese submetida
    ao Federal de \showfont}
    {Tese submetida ao asdfffffffffffffasd fdaf adsf df asfd asfd asdf sdf asdf adaf df ads fasd f Federal de \showfont}
}

(cherry picked from commit 7af3e3b)
(cherry picked from commit e30c230)
implemented the semantic_line_wrap() call and some Unit Tests.

(cherry picked from commit 9cc9ed4)
semantic linewrap also know as semantic linefeed will be used.

(cherry picked from commit 830c411)
@yrammos
Copy link

yrammos commented Nov 7, 2017

Thanks! I hope this does get merged into @ehuss's great package.

Base File.sublime-settings

(cherry picked from commit 4443a30)
detects the maximum line width and uses it to limite/delimite the
maximum line width. If you line your lines only to be
wrapped by delimiter characters, you can set this to true.

(cherry picked from commit cc3055d)
to balance the text between lines equally when a line wrapped due
reaching the maximum wrap width.

(cherry picked from commit 8a6e77e)
setting balance_characters_between_line_wraps to be disabled.

(cherry picked from commit 27db11f)
occur on the end of the line.

(cherry picked from commit 14573cf)
control the number of words between sequential commas, to be
considered a list of words.

(cherry picked from commit 69e054c)
@ehuss
Copy link
Owner

ehuss commented Nov 9, 2017

Thanks for the PR! I noticed you added some more commits, I'm wondering if you are all finished now?
There are a few changes I'd like to see before merging it. I can work on it if you'd like. In general:

  • Move the tests to a separate "tests" directory and use the Unittesting package to run the tests.
  • Is there a reason to change the name of the command?
  • I'd like to add a config setting that controls the after-wrap behavior. Perhaps something like WrapPlus.after_wrap. This should be a string for the different behaviors. The current behavior would be something like "cursor_below" and this new behavior would be something like "cursor_stay". The reason I haven't added this yet is because the proposed change doesn't completely work correctly (the reformatting will cause the cursor to jump a few characters based on what is added/inserted). But I guess something is better than nothing. A better solution is quite tricky, but perhaps I'll give it another shot soon.
  • Prefix the new settings with semantic_ to make it clear they only work if semantic wrapping is enabled.
  • Is there a particular reason to change the long/hyphen default settings? I don't really care one way or the other, just curious.

setting "WrapPlus.after_wrap" to control the cursor behavior while
wrapping the text. It accepts the following:

"cursor_below", will move the cursor/caret to the end the the
wrapped text.

"cursor_stay", will `attempt` to keep the cursor/caret on its
original position.

(cherry picked from commit c2a2250)
@evandrocoan
Copy link
Author

Is there a particular reason to change the long/hyphen default settings?

They seemed dangerous.

Prefix the new settings with semantic_ to make it clear they only work if semantic wrapping is enabled.

Done on 7e7fa1f

I'd like to add a config setting that controls the after-wrap behavior. Perhaps something like WrapPlus.after_wrap.

Done on 07ac351

Is there a reason to change the name of the command?

I had did it because I did a long time ago because I did not knew how to change the class code to implement the cursor stay feature. Now I removed it and restored it as I implemented the code directly on the main code.

Move the tests to a separate "tests" directory and use the Unittesting package to run the tests.

Done on b5886f6

@evandrocoan
Copy link
Author

I implemented the unit test system by https://github.com/randy3k/UnitTesting, these are the results:

test_balance_characters_between_line_wraps_ending_with_long_word (semantic_linefeed_unit_tests.LineBalancingUnitTests) ... ok
test_balance_characters_between_line_wraps_with_trailing_new_line (semantic_linefeed_unit_tests.LineBalancingUnitTests) ... ok
test_balance_characters_between_line_wraps_without_trailing_new_line (semantic_linefeed_unit_tests.LineBalancingUnitTests) ... ok
test_split_lines_with_trailing_new_line (semantic_linefeed_unit_tests.LineBalancingUnitTests) ... ok
test_split_lines_with_very_long_line_and_word (semantic_linefeed_unit_tests.LineBalancingUnitTests) ... ok
test_split_lines_without_trailing_new_line (semantic_linefeed_unit_tests.LineBalancingUnitTests) ... ok
test_is_command_separated_list (semantic_linefeed_unit_tests.SemanticLineWrapUnitTests) ... ok
test_is_command_separated_list_lowerbound (semantic_linefeed_unit_tests.SemanticLineWrapUnitTests) ... ok
test_is_command_separated_list_upperbound (semantic_linefeed_unit_tests.SemanticLineWrapUnitTests) ... ok
test_semantic_line_wrap_ending_with_comma_list (semantic_linefeed_unit_tests.SemanticLineWrapUnitTests) ... ok
test_semantic_line_wrap_long_word (semantic_linefeed_unit_tests.SemanticLineWrapUnitTests) ... ok
test_semantic_line_wrap_simple_sentences (semantic_linefeed_unit_tests.SemanticLineWrapUnitTests) ... ok
test_semantic_line_wrap_with_79_characters (semantic_linefeed_unit_tests.SemanticLineWrapUnitTests) ... ok
test_semantic_line_wrap_with_80_characters (semantic_linefeed_unit_tests.SemanticLineWrapUnitTests) ... ok
test_semantic_line_wrap_with_81_characters (semantic_linefeed_unit_tests.SemanticLineWrapUnitTests) ... ok
test_semantic_line_wrap_with_81_characters_on_list_flushing (semantic_linefeed_unit_tests.SemanticLineWrapUnitTests) ... ok
test_semantic_line_wrap_with_comma_list_on_the_end (semantic_linefeed_unit_tests.SemanticLineWrapUnitTests) ... ok
test_semantic_line_wrap_with_comma_list_on_the_middle (semantic_linefeed_unit_tests.SemanticLineWrapUnitTests) ... ok
test_semantic_line_wrap_with_initial_indentation (semantic_linefeed_unit_tests.SemanticLineWrapUnitTests) ... ok
test_semantic_line_wrap_with_long_word_at_comma_list_end (semantic_linefeed_unit_tests.SemanticLineWrapUnitTests) ... ok
test_semantic_line_wrap_with_numeric_comma_list_on_the_end (semantic_linefeed_unit_tests.SemanticLineWrapUnitTests) ... ok

----------------------------------------------------------------------
Ran 21 tests in 0.560s

OK

UnitTesting: Done.

But I also kept the caller on plugin_loaded() as a comment because I would like to use it.

I'm wondering if you are all finished now?

Yes, unless some bug emerges.

The reason I haven't added this yet is because the proposed change doesn't completely work correctly (the reformatting will cause the cursor to jump a few characters based on what is added/inserted)

I noticed this sometimes, but the current implementation is already very good as it is, which is much better then sending my cursor to the end of the line (far away from where it is).

This is a problem because I call several times the command Ctrl+Q while I am writing text, then it is really boring to be sending it to the end of the paragraph. If a few time the cursor move a little off, it is not a problem compared to sending it to the end of the line always.

@evandrocoan
Copy link
Author

I just pushed a few things I forgot to remove/add. This should be the end.

@ehuss
Copy link
Owner

ehuss commented Nov 9, 2017

Sweet! I have to head out today, but I will try to test it soon.

@evandrocoan
Copy link
Author

Closing if favor of #66 All my updates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants