public static LogEdit ( string etype, int start, int stop, string text ) : void | ||
etype | string | |
start | int | |
stop | int | |
text | string | |
return | void |
void logKeyboardActivity() { if (GUI.changed && GUI.GetNameOfFocusedControl() == "EditableCode") { clipboard = (string)typeof(GUIUtility).GetProperty("systemCopyBuffer", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null, null); Event e = Event.current; if (((int)e.character) != 0 && String.Equals("None", e.keyCode + "")) //type a character { if (selStart == selStop) { ProgramLogger.LogEdit("insert", stateObj.pos - 1, stateObj.pos, e.character + ""); } else { ProgramLogger.LogEdit("remove", selStart, selStop, selected); ProgramLogger.LogEdit("insert", stateObj.pos - 1, stateObj.pos, e.character + ""); } } else if ((e.functionKey && String.Equals(e.keyCode + "", "Backspace")) || (String.Equals("" + e.keyCode, "X") && (e.command || e.control))) //delete or cut { if (selStart == selStop) { ProgramLogger.LogEdit("remove", stateObj.pos, selStart, ""); } else { ProgramLogger.LogEdit("remove", selStart, selStop, selected); } } else if ((e.command || e.control) && String.Equals("" + e.keyCode, "V")) //paste { if (selStart == selStop) { ProgramLogger.LogEdit("insert", stateObj.pos - clipboard.Length, stateObj.pos, clipboard); } else { ProgramLogger.LogEdit("remove", selStart, selStop, selected); ProgramLogger.LogEdit("insert", stateObj.pos - clipboard.Length, stateObj.pos, clipboard); } } } selected = stateObj.SelectedText + ""; selStart = Math.Min(stateObj.pos, stateObj.selectPos); selStop = Math.Max(stateObj.pos, stateObj.selectPos); }
void insertTab(int tab_width) { string spaces = ""; for (int i = 0; i < tab_width; i++) { spaces += " "; } current_code = current_code.Substring(0, GetCursorPosition()) + spaces + current_code.Substring(GetCursorPosition()); ProgramLogger.LogEdit("insert", GetCursorPosition(), GetCursorPosition() + tab_width, spaces); for (int i = 0; i < tab_width; i++) { stateObj.MoveRight(); } }