/// <summary> /// Gets the cursor of this <see cref="Scintilla"/> control. /// </summary> /// <param name="scintilla">The scintilla.</param> /// <returns>The current cursor with this <see cref="Scintilla"/> control.</returns> public static Cursor GetCursor(this Scintilla scintilla) { try { var result = scintilla.DirectMessage(SCI_GETCURSOR, (IntPtr)0, (IntPtr)0); var value = result.ToInt32(); if (value == -1) { value = 0; } var cursor = ScintillaCursorMapping.FirstOrDefault(f => f.Key == value); // Debug.Print(cursor.ToString()); return(cursor.Value); } catch { return(Cursors.Default); } }
/// <summary> /// Sets the cursor of this <see cref="Scintilla"/> control. /// </summary> /// <param name="scintilla">The scintilla.</param> /// <param name="cursor">The cursor to set for this <see cref="Scintilla"/> control.</param> /// <returns><c>true</c> if the operation was successful, <c>false</c> otherwise.</returns> public static bool SetCursor(this Scintilla scintilla, Cursor cursor) { try { var currentCursor = scintilla.GetCursor(); if (cursor == currentCursor) { //Debug.Print("No change in cursors.."); return(false); } // Debug.Print(cursor + " / " + currentCursor); var cursorValue = ScintillaCursorMapping.First(f => f.Value == cursor).Key; scintilla.DirectMessage(SCI_SETCURSOR, (IntPtr)cursorValue, (IntPtr)0); return(true); } catch { return(false); } }