aboutsummaryrefslogtreecommitdiffhomepage
path: root/cocoa
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2009-07-12 11:03:11 +0000
committernyamatongwe <devnull@localhost>2009-07-12 11:03:11 +0000
commita58e5dec980fa5d9e7b8149c6479fda460b96d9f (patch)
treeb7ae52e7f989685cd75d54ad6a0d917425813b2b /cocoa
parentbaa50ad103ecc10beae248982a3a37f4a9f51ec9 (diff)
downloadscintilla-mirror-a58e5dec980fa5d9e7b8149c6479fda460b96d9f.tar.gz
Changes needed to make new selection class work on Cocoa.
Diffstat (limited to 'cocoa')
-rw-r--r--cocoa/ScintillaCocoa.h1
-rw-r--r--cocoa/ScintillaCocoa.mm26
-rw-r--r--cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj8
3 files changed, 22 insertions, 13 deletions
diff --git a/cocoa/ScintillaCocoa.h b/cocoa/ScintillaCocoa.h
index 383952304..0896dab81 100644
--- a/cocoa/ScintillaCocoa.h
+++ b/cocoa/ScintillaCocoa.h
@@ -43,6 +43,7 @@
#include "CharClassify.h"
#include "Decoration.h"
#include "Document.h"
+#include "Selection.h"
#include "PositionCache.h"
#include "Editor.h"
#include "SString.h"
diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm
index 13c214207..322e7c679 100644
--- a/cocoa/ScintillaCocoa.mm
+++ b/cocoa/ScintillaCocoa.mm
@@ -445,7 +445,7 @@ void ScintillaCocoa::CopyToClipboard(const SelectionText &selectedText)
void ScintillaCocoa::Copy()
{
- if (currentPos != anchor)
+ if (!sel.Empty())
{
SelectionText selectedText;
CopySelectionRange(&selectedText);
@@ -491,12 +491,12 @@ void ScintillaCocoa::Paste(bool forceRectangular)
ClearSelection();
if (selectedText.rectangular)
{
- int selStart = SelectionStart();
+ SelectionPosition selStart = sel.RangeMain().Start();
PasteRectangular(selStart, selectedText.s, selectedText.len);
}
else
- if (pdoc->InsertString(currentPos, selectedText.s, selectedText.len))
- SetEmptySelection(currentPos + selectedText.len);
+ if (pdoc->InsertString(sel.RangeMain().caret.Position(), selectedText.s, selectedText.len))
+ SetEmptySelection(sel.RangeMain().caret.Position() + selectedText.len);
pdoc->EndUndoAction();
@@ -646,8 +646,8 @@ NSPoint ScintillaCocoa::GetCaretPosition()
{
NSPoint result;
- result.y = pdoc->LineFromPosition(currentPos);
- result.x = currentPos - pdoc->LineStart(result.y);
+ result.y = pdoc->LineFromPosition(sel.RangeMain().caret.Position());
+ result.x = sel.RangeMain().caret.Position() - pdoc->LineStart(result.y);
return result;
}
@@ -660,7 +660,7 @@ NSPoint ScintillaCocoa::GetCaretPosition()
*/
void ScintillaCocoa::DragScroll()
{
- if (posDrag == invalidPosition)
+ if (!posDrag.IsValid())
{
scrollSpeed = 1;
scrollTicks = 2000;
@@ -668,7 +668,7 @@ void ScintillaCocoa::DragScroll()
}
// TODO: does not work for wrapped lines, fix it.
- int line = pdoc->LineFromPosition(posDrag);
+ int line = pdoc->LineFromPosition(posDrag.Position());
int currentVisibleLine = cs.DisplayFromDoc(line);
int lastVisibleLine = Platform::Minimum(topLine + LinesOnScreen(), cs.LinesDisplayed()) - 2;
@@ -705,7 +705,7 @@ void ScintillaCocoa::DragScroll()
*/
void ScintillaCocoa::StartDrag()
{
- if (currentPos == anchor)
+ if (sel.Empty())
return;
// Put the data to be dragged on the drag pasteboard.
@@ -715,7 +715,7 @@ void ScintillaCocoa::StartDrag()
SetPasteboardData(pasteboard, selectedText);
// Prepare drag image.
- PRectangle localRectangle = RectangleFromRange(SelectionStart(), SelectionEnd());
+ PRectangle localRectangle = RectangleFromRange(sel.RangeMain().Start().Position(), sel.RangeMain().End().Position());
NSRect selectionRectangle = PRectangleToNSRect(localRectangle);
NSView* content = ContentView();
@@ -820,7 +820,7 @@ NSDragOperation ScintillaCocoa::DraggingUpdated(id <NSDraggingInfo> info)
// Convert the drag location from window coordinates to view coordinates and
// from there to a text position to finally set the drag position.
Point location = ConvertPoint([info draggingLocation]);
- SetDragPosition(PositionFromLocation(location));
+ SetDragPosition(SPositionFromLocation(location));
NSDragOperation sourceDragMask = [info draggingSourceOperationMask];
if (sourceDragMask == NSDragOperationNone)
@@ -845,7 +845,7 @@ NSDragOperation ScintillaCocoa::DraggingUpdated(id <NSDraggingInfo> info)
*/
void ScintillaCocoa::DraggingExited(id <NSDraggingInfo> info)
{
- SetDragPosition(invalidPosition);
+ SetDragPosition(SelectionPosition(invalidPosition));
inDragDrop = ddNone;
}
@@ -1187,7 +1187,7 @@ void ScintillaCocoa::NotifyURIDropped(const char *uri)
bool ScintillaCocoa::HasSelection()
{
- return (SelectionEnd() - SelectionStart()) > 0;
+ return !sel.Empty();
}
//--------------------------------------------------------------------------------------------------
diff --git a/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj b/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj
index 8b0108022..4845821cc 100644
--- a/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj
+++ b/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj
@@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
+ 11AF56931009F8180033F27F /* Selection.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 11AF56911009F8180033F27F /* Selection.cxx */; };
+ 11AF56941009F8180033F27F /* Selection.h in Headers */ = {isa = PBXBuildFile; fileRef = 11AF56921009F8180033F27F /* Selection.h */; };
2744E4DC0FC1682C00E85C33 /* AutoComplete.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 2744E4CF0FC1682C00E85C33 /* AutoComplete.cxx */; };
2744E4DD0FC1682C00E85C33 /* CallTip.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 2744E4D00FC1682C00E85C33 /* CallTip.cxx */; };
2744E4DE0FC1682C00E85C33 /* CellBuffer.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 2744E4D10FC1682C00E85C33 /* CellBuffer.cxx */; };
@@ -169,6 +171,8 @@
0867D6A5FE840307C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
089C1667FE841158C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
+ 11AF56911009F8180033F27F /* Selection.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Selection.cxx; path = ../../src/Selection.cxx; sourceTree = SOURCE_ROOT; };
+ 11AF56921009F8180033F27F /* Selection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Selection.h; path = ../../src/Selection.h; sourceTree = SOURCE_ROOT; };
2744E4830FC1678600E85C33 /* Accessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Accessor.h; path = ../../include/Accessor.h; sourceTree = SOURCE_ROOT; };
2744E4840FC1678600E85C33 /* KeyWords.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KeyWords.h; path = ../../include/KeyWords.h; sourceTree = SOURCE_ROOT; };
2744E4850FC1678600E85C33 /* Platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Platform.h; path = ../../include/Platform.h; sourceTree = SOURCE_ROOT; };
@@ -504,6 +508,8 @@
2744E47E0FC1675800E85C33 /* Header Files */ = {
isa = PBXGroup;
children = (
+ 11AF56911009F8180033F27F /* Selection.cxx */,
+ 11AF56921009F8180033F27F /* Selection.h */,
2744E4990FC1681200E85C33 /* AutoComplete.h */,
2744E49A0FC1681200E85C33 /* CallTip.h */,
2744E49B0FC1681200E85C33 /* CellBuffer.h */,
@@ -671,6 +677,7 @@
2791F3E80FC1A3AE009DBCF9 /* ScintillaWidget.h in Headers */,
2791F3E90FC1A3AE009DBCF9 /* SString.h in Headers */,
2791F3EA0FC1A3AE009DBCF9 /* WindowAccessor.h in Headers */,
+ 11AF56941009F8180033F27F /* Selection.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -840,6 +847,7 @@
2744E5B30FC168C500E85C33 /* PlatCocoa.mm in Sources */,
2744E5B50FC168C500E85C33 /* ScintillaCocoa.mm in Sources */,
2744E5B60FC168C500E85C33 /* ScintillaView.mm in Sources */,
+ 11AF56931009F8180033F27F /* Selection.cxx in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};