diff options
Diffstat (limited to 'cocoa/ScintillaCocoa.mm')
| -rw-r--r-- | cocoa/ScintillaCocoa.mm | 62 | 
1 files changed, 43 insertions, 19 deletions
diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index f91183aa2..6d3296a51 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -255,6 +255,31 @@ void ScintillaCocoa::Finalise()  //--------------------------------------------------------------------------------------------------  /** + * Case-fold the given string depending on the specified case mapping type. + * Note: ScintillaCocoa exclusively works with Unicode. We don't even think about adding support for + *       obsolete code page stuff.     + */ +std::string ScintillaCocoa::CaseMapString(const std::string &s, int caseMapping) +{ +  NSString* textToConvert = [NSString stringWithUTF8String: s.c_str()]; +  std::string result; +  switch (caseMapping) +  { +    case cmUpper: +      result = [[textToConvert uppercaseString] UTF8String]; +      break; +    case cmLower: +      result = [[textToConvert lowercaseString] UTF8String]; +      break; +    default: +      result = s; +  } +  return result; +} + +//-------------------------------------------------------------------------------------------------- + +/**   * Helper function to get the outer container which represents the Scintilla editor on application side.   */  ScintillaView* ScintillaCocoa::TopContainer() @@ -501,14 +526,15 @@ void ScintillaCocoa::Paste(bool forceRectangular)    pdoc->BeginUndoAction();    ClearSelection(); +  int length = selectedText.len - 1; // One less to avoid inserting the terminating 0 character.    if (selectedText.rectangular)    {      SelectionPosition selStart = sel.RangeMain().Start(); -    PasteRectangular(selStart, selectedText.s, selectedText.len); +    PasteRectangular(selStart, selectedText.s, length);    }    else  -    if (pdoc->InsertString(sel.RangeMain().caret.Position(), selectedText.s, selectedText.len)) -      SetEmptySelection(sel.RangeMain().caret.Position() + selectedText.len); +    if (pdoc->InsertString(sel.RangeMain().caret.Position(), selectedText.s, length)) +      SetEmptySelection(sel.RangeMain().caret.Position() + length);    pdoc->EndUndoAction(); @@ -1373,34 +1399,32 @@ void ScintillaCocoa::MouseUp(NSEvent* event)  void ScintillaCocoa::MouseWheel(NSEvent* event)  {    bool command = ([event modifierFlags] & NSCommandKeyMask) != 0; -  bool shift = ([event modifierFlags] & NSShiftKeyMask) != 0; -  int delta; -  if (shift) -    delta = 10 * [event deltaX]; // Arbitrary scale factor. -  else -  { +  int dX = 0; +  int dY = 0; + +  dX = 10 * [event deltaX]; // Arbitrary scale factor. +      // In order to make scrolling with larger offset smoother we scroll less lines the larger the       // delta value is.      if ([event deltaY] < 0) -      delta = -(int) sqrt(-10.0 * [event deltaY]); +    dY = -(int) sqrt(-10.0 * [event deltaY]);      else -      delta = (int) sqrt(10.0 * [event deltaY]); -  } +    dY = (int) sqrt(10.0 * [event deltaY]);    if (command)    {      // Zoom! We play with the font sizes in the styles.      // Number of steps/line is ignored, we just care if sizing up or down. -    if (delta > 0) +    if (dY > 0.5)        KeyCommand(SCI_ZOOMIN); -    else +    else if (dY < -0.5)        KeyCommand(SCI_ZOOMOUT);    }    else -    if (shift) -      HorizontalScrollTo(xOffset - delta); -    else -      ScrollTo(topLine - delta, true); +  { +    HorizontalScrollTo(xOffset - dX); +    ScrollTo(topLine - dY, true); +  }  }  //-------------------------------------------------------------------------------------------------- @@ -1429,7 +1453,7 @@ void ScintillaCocoa::Undo()  void ScintillaCocoa::Redo()  { -  Editor::Undo(); +  Editor::Redo();  }  //--------------------------------------------------------------------------------------------------  | 
