• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

TextMate is a graphical text editor for OS X 10.7+


Commit MetaInfo

Revision1477288795fd9d0cf5f7afcad162ed2118cd1567 (tree)
Zeit2012-08-19 04:52:08
AutorAllan Odgaard <git@abet...>
CommiterAllan Odgaard

Log Message

Redefine definition of paragraph

When we need to work on a paragraph (reflow, unwrap, select, etc.) we now extend upward until we see a blank line, and likewise move downward until there is a blank line.

This is related to issue #154.

Ändern Zusammenfassung

Diff

--- a/Frameworks/selection/src/selection.cc
+++ b/Frameworks/selection/src/selection.cc
@@ -379,7 +379,7 @@ namespace ng
379379 case kSelectionMoveToBeginOfDocument: return 0;
380380 case kSelectionMoveToEndOfDocument: return buffer.size();
381381 case kSelectionMoveToBeginOfParagraph: return buffer.begin(line);
382- case kSelectionMoveToEndOfParagraph: return buffer.eol(line); // TODO Better definition of kSelectionMoveToEndOfParagraph.
382+ case kSelectionMoveToEndOfParagraph: return buffer.eol(line);
383383 case kSelectionMoveToBeginOfLine: return buffer.begin(line);
384384 case kSelectionMoveToEndOfLine: return buffer.eol(line);
385385 case kSelectionMoveToBeginOfSoftLine: return layout ? layout->index_at_bol_for(caret) : buffer.begin(line);
@@ -393,6 +393,33 @@ namespace ng
393393 case kSelectionMovePageUp: return layout ? layout->page_up_for(index) : index;
394394 case kSelectionMovePageDown: return layout ? layout->page_down_for(index) : index;
395395
396+ case kSelectionMoveToBeginOfHardParagraph:
397+ {
398+ if(line == 0)
399+ return 0;
400+
401+ for(size_t n = line-1; n > 0; --n)
402+ {
403+ std::string const& line = buffer.substr(buffer.begin(n), buffer.end(n));
404+ if(text::is_blank(line.data(), line.data() + line.size()))
405+ return buffer.begin(n+1);
406+ }
407+ return 0;
408+ }
409+ break;
410+
411+ case kSelectionMoveToEndOfHardParagraph:
412+ {
413+ for(size_t n = line+1; n < buffer.lines(); ++n)
414+ {
415+ std::string const& line = buffer.substr(buffer.begin(n), buffer.end(n));
416+ if(text::is_blank(line.data(), line.data() + line.size()))
417+ return buffer.begin(n);
418+ }
419+ return buffer.size();
420+ }
421+ break;
422+
396423 case kSelectionMoveFreehandedLeft:
397424 {
398425 if(index.carry != 0)
@@ -692,7 +719,7 @@ namespace ng
692719 case kSelectionExtendToSoftLine: return range_t(move(buffer, min, kSelectionMoveToBeginOfSoftLine, layout), min.index != max.index && max.index == move(buffer, max, kSelectionMoveToBeginOfSoftLine, layout).index ? max : move(buffer, move(buffer, max, kSelectionMoveToEndOfSoftLine, layout), kSelectionMoveRight, layout), false, false, true);
693720 case kSelectionExtendToLine: return range_t(move(buffer, min, kSelectionMoveToBeginOfLine, layout), min.index != max.index && buffer.convert(max.index).column == 0 ? max : move(buffer, move(buffer, max, kSelectionMoveToEndOfLine, layout), kSelectionMoveRight, layout), false, false, true);
694721 case kSelectionExtendToLineExclLF: return range_t(move(buffer, min, kSelectionMoveToBeginOfLine, layout), min.index != max.index && buffer.convert(max.index).column == 0 ? max : move(buffer, max, kSelectionMoveToEndOfLine, layout), false, false, true);
695- case kSelectionExtendToParagraph: return range_t(move(buffer, min, kSelectionMoveToBeginOfParagraph, layout), move(buffer, max, kSelectionMoveToEndOfParagraph, layout), false, false, true);
722+ case kSelectionExtendToParagraph: return range_t(move(buffer, min, kSelectionMoveToBeginOfHardParagraph, layout), move(buffer, max, kSelectionMoveToEndOfHardParagraph, layout), false, false, true);
696723 case kSelectionExtendToAll: return range_t(move(buffer, min, kSelectionMoveToBeginOfDocument, layout), move(buffer, max, kSelectionMoveToEndOfDocument, layout), false, false, true);
697724
698725 case kSelectionExtendToWord:
--- a/Frameworks/selection/src/selection.h
+++ b/Frameworks/selection/src/selection.h
@@ -6,7 +6,7 @@
66 #include <text/types.h>
77 #include <oak/misc.h>
88
9-enum move_unit_type { kSelectionMoveLeft, kSelectionMoveRight, kSelectionMoveFreehandedLeft, kSelectionMoveFreehandedRight, kSelectionMoveUp, kSelectionMoveDown, kSelectionMoveToBeginOfSelection, kSelectionMoveToEndOfSelection, kSelectionMoveToBeginOfSubWord, kSelectionMoveToEndOfSubWord, kSelectionMoveToBeginOfWord, kSelectionMoveToEndOfWord, kSelectionMoveToBeginOfSoftLine, kSelectionMoveToEndOfSoftLine, kSelectionMoveToBeginOfLine, kSelectionMoveToEndOfLine, kSelectionMoveToBeginOfParagraph, kSelectionMoveToEndOfParagraph, kSelectionMoveToBeginOfTypingPair, kSelectionMoveToEndOfTypingPair, kSelectionMoveToBeginOfColumn, kSelectionMoveToEndOfColumn, kSelectionMovePageUp, kSelectionMovePageDown, kSelectionMoveToBeginOfDocument, kSelectionMoveToEndOfDocument, kSelectionMoveNowhere };
9+enum move_unit_type { kSelectionMoveLeft, kSelectionMoveRight, kSelectionMoveFreehandedLeft, kSelectionMoveFreehandedRight, kSelectionMoveUp, kSelectionMoveDown, kSelectionMoveToBeginOfSelection, kSelectionMoveToEndOfSelection, kSelectionMoveToBeginOfSubWord, kSelectionMoveToEndOfSubWord, kSelectionMoveToBeginOfWord, kSelectionMoveToEndOfWord, kSelectionMoveToBeginOfSoftLine, kSelectionMoveToEndOfSoftLine, kSelectionMoveToBeginOfLine, kSelectionMoveToEndOfLine, kSelectionMoveToBeginOfParagraph, kSelectionMoveToEndOfParagraph, kSelectionMoveToBeginOfHardParagraph, kSelectionMoveToEndOfHardParagraph, kSelectionMoveToBeginOfTypingPair, kSelectionMoveToEndOfTypingPair, kSelectionMoveToBeginOfColumn, kSelectionMoveToEndOfColumn, kSelectionMovePageUp, kSelectionMovePageDown, kSelectionMoveToBeginOfDocument, kSelectionMoveToEndOfDocument, kSelectionMoveNowhere };
1010 enum select_unit_type { kSelectionExtendLeft, kSelectionExtendRight, kSelectionExtendFreehandedLeft, kSelectionExtendFreehandedRight, kSelectionExtendUp, kSelectionExtendDown, kSelectionExtendToBeginOfSubWord, kSelectionExtendToEndOfSubWord, kSelectionExtendToBeginOfWord, kSelectionExtendToEndOfWord, kSelectionExtendToBeginOfSoftLine, kSelectionExtendToEndOfSoftLine, kSelectionExtendToBeginOfLine, kSelectionExtendToEndOfLine, kSelectionExtendToBeginOfParagraph, kSelectionExtendToEndOfParagraph, kSelectionExtendToBeginOfTypingPair, kSelectionExtendToEndOfTypingPair, kSelectionExtendToBeginOfColumn, kSelectionExtendToEndOfColumn, kSelectionExtendPageUp, kSelectionExtendPageDown, kSelectionExtendToBeginOfDocument, kSelectionExtendToEndOfDocument, kSelectionExtendToWord, kSelectionExtendToScope, kSelectionExtendToSoftLine, kSelectionExtendToLineExclLF, kSelectionExtendToLine, kSelectionExtendToParagraph, kSelectionExtendToTypingPair, kSelectionExtendToAll };
1111
1212 namespace scope { struct context_t; struct selector_t; }