Permalink
Browse files

Update dyn.caret/selection scopes

If there is one or more selections:

    dyn.selection

If there is a single zero-width selection:

    dyn.caret.mixed.columnar

If there are multiple carets and/or selections:

    dyn.caret.mixed

When there is only a single caret or a single continuous selection the left scope may contain:

    dyn.caret.begin.line
    dyn.caret.begin.document

Likewise the right scope may contain:

    dyn.caret.end.line
    dyn.caret.end.document
  • Loading branch information...
1 parent cba6b32 commit fa6659db2821d45fd03d9641d20cd4156482004d @sorbits sorbits committed Sep 30, 2012
Showing with 28 additions and 11 deletions.
  1. +28 −11 Frameworks/selection/src/selection.cc
@@ -968,19 +968,36 @@ namespace ng
}
}
- if(selection.size() > 1 || selection.size() == 1 && !selection.last().empty())
+ if(selection.size() > 1)
{
- std::string scopeAtom = "dyn.selection";
-
- if(selection.size() > 1)
- scopeAtom += ".discontinuous";
- else if(selection.last().columnar)
- scopeAtom += ".columnar";
- else
- scopeAtom += ".continuous";
+ res.left = res.left.append("dyn.caret.mixed");
+ res.right = res.right.append("dyn.caret.mixed");
+ }
+ else if(selection.last().columnar)
+ {
+ res.left = res.left.append("dyn.caret.mixed.columnar");
+ res.right = res.right.append("dyn.caret.mixed.columnar");
+ }
+ else
+ {
+ size_t const leftCaret = selection.last().min().index;
+ size_t const rightCaret = selection.last().max().index;
+
+ if(leftCaret == 0)
+ res.left = res.left.append("dyn.caret.begin.document");
+ else if(leftCaret == buffer.begin(buffer.convert(leftCaret).line))
+ res.left = res.left.append("dyn.caret.begin.line");
+
+ if(rightCaret == buffer.size())
+ res.right = res.right.append("dyn.caret.end.document");
+ else if(rightCaret == buffer.eol(buffer.convert(rightCaret).line))
+ res.right = res.right.append("dyn.caret.end.line");
+ }
- res.left = res.left.append(scopeAtom);
- res.right = res.right.append(scopeAtom);
+ if(not_empty(buffer, selection))
+ {
+ res.left = res.left.append("dyn.selection");
+ res.right = res.right.append("dyn.selection");
}
return res;

0 comments on commit fa6659d

Please sign in to comment.