diff options
| author | nyamatongwe <unknown> | 2010-01-20 23:53:59 +0000 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2010-01-20 23:53:59 +0000 | 
| commit | 19823f881f3e5af9f2353fe6be1a2190ae071357 (patch) | |
| tree | 57dd7368f3f734e04c41ea648d3483ecc0b4189e /cocoa/ScintillaView.mm | |
| parent | 757ad60c6b0a074c2240945e99e3d07c89acf89d (diff) | |
| download | scintilla-mirror-19823f881f3e5af9f2353fe6be1a2190ae071357.tar.gz | |
Updated to current version (28) of Scintilla Cocoa.
Diffstat (limited to 'cocoa/ScintillaView.mm')
| -rw-r--r-- | cocoa/ScintillaView.mm | 65 | 
1 files changed, 56 insertions, 9 deletions
| diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm index 5ff3de720..1f428c017 100644 --- a/cocoa/ScintillaView.mm +++ b/cocoa/ScintillaView.mm @@ -19,6 +19,8 @@ static NSCursor* waitCursor;  // The scintilla indicator used for keyboard input.  #define INPUT_INDICATOR INDIC_MAX - 1 +NSString *SCIUpdateUINotification = @"SCIUpdateUI"; +  @implementation InnerView  @synthesize owner = mOwner; @@ -638,35 +640,42 @@ static void notification(intptr_t windowid, unsigned int iMessage, uintptr_t wPa        switch (scn->nmhdr.code)        {          case SCN_MARGINCLICK: +        {            if (scn->margin == 2)            {              // Click on the folder margin. Toggle the current line if possible.              int line = [editor getGeneralProperty: SCI_LINEFROMPOSITION parameter: scn->position];              [editor setGeneralProperty: SCI_TOGGLEFOLD parameter: line value: 0]; -          }; +          }            break; +          };          case SCN_MODIFIED: +        {            // Decide depending on the modification type what to do.            // There can be more than one modification carried by one notification.            if (scn->modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT))              [editor sendNotification: NSTextDidChangeNotification];            break; +        }          case SCN_ZOOM: -		  { +        {            // A zoom change happend. Notify info bar if there is one.            float zoom = [editor getGeneralProperty: SCI_GETZOOM parameter: 0];            int fontSize = [editor getGeneralProperty: SCI_STYLEGETSIZE parameter: STYLE_DEFAULT];            float factor = (zoom / fontSize) + 1;            [editor->mInfoBar notify: IBNZoomChanged message: nil location: NSZeroPoint value: factor]; -          } -		  break; +          break; +        }          case SCN_UPDATEUI: +        {            // Triggered whenever changes in the UI state need to be reflected.            // These can be: caret changes, selection changes etc.            NSPoint caretPosition = editor->mBackend->GetCaretPosition();            [editor->mInfoBar notify: IBNCaretChanged message: nil location: caretPosition value: 0]; +          [editor sendNotification: SCIUpdateUINotification];            break;        } +      }        break;      }      case WM_COMMAND: @@ -979,19 +988,20 @@ static void notification(intptr_t windowid, unsigned int iMessage, uintptr_t wPa  /**   * Getter for the current text in raw form (no formatting information included). + * If there is no text available an empty string is returned.   */ -- (NSString*) string +- (NSString*) selectedString  {    NSString *result = nil;    char *buffer(0); -  const int length = mBackend->WndProc(SCI_GETLENGTH, 0, 0); +  const int length = mBackend->WndProc(SCI_GETSELTEXT, 0, 0);    if (length > 0)    {      buffer = new char[length + 1];      try      { -      mBackend->WndProc(SCI_GETTEXT, length + 1, (sptr_t) buffer); +      mBackend->WndProc(SCI_GETSELTEXT, length + 1, (sptr_t) buffer);        mBackend->WndProc(SCI_SETSAVEPOINT, 0, 0);        result = [NSString stringWithUTF8String: buffer]; @@ -1003,15 +1013,45 @@ static void notification(intptr_t windowid, unsigned int iMessage, uintptr_t wPa        buffer = 0;      }    } +  else +    result = [NSString stringWithUTF8String: ""];    return result;  }  //-------------------------------------------------------------------------------------------------- -- (void) setEditable: (BOOL) editable +/** + * Getter for the current text in raw form (no formatting information included). + * If there is no text available an empty string is returned. + */ +- (NSString*) string  { -  mBackend->WndProc(SCI_SETREADONLY, editable ? 0 : 1, 0); +  NSString *result = nil; +   +  char *buffer(0); +  const int length = mBackend->WndProc(SCI_GETLENGTH, 0, 0); +  if (length > 0) +  { +    buffer = new char[length + 1]; +    try +    { +      mBackend->WndProc(SCI_GETTEXT, length + 1, (sptr_t) buffer); +      mBackend->WndProc(SCI_SETSAVEPOINT, 0, 0); +       +      result = [NSString stringWithUTF8String: buffer]; +      delete[] buffer; +    } +    catch (...) +    { +      delete[] buffer; +      buffer = 0; +    } +  } +  else +    result = [NSString stringWithUTF8String: ""]; +   +  return result;  }  //-------------------------------------------------------------------------------------------------- @@ -1027,6 +1067,13 @@ static void notification(intptr_t windowid, unsigned int iMessage, uintptr_t wPa  //-------------------------------------------------------------------------------------------------- +- (void) setEditable: (BOOL) editable +{ +  mBackend->WndProc(SCI_SETREADONLY, editable ? 0 : 1, 0); +} + +//-------------------------------------------------------------------------------------------------- +  - (InnerView*) content  {    return mContent; | 
