public bool RecordBatchedLine(LastMacro macroRecorded, string line, int maxLineLength) { if (null == line) { line = ""; } if (maxLineLength > 0 && line.Length >= maxLineLength) { // Reset the state after recording the line, so it will not be appended to further RecordLine(line); // Notify the caller that the this line will not be appended to further return(true); } if (IsLastRecordedMacro(macroRecorded)) { m_VsMacroRecorder.ReplaceLine(line, ref m_GuidEmitter); // m_LastMacroRecorded can stay the same ++m_TimesPreviouslyRecorded; } else { m_VsMacroRecorder.RecordLine(line, ref m_GuidEmitter); m_LastMacroRecorded = macroRecorded; m_TimesPreviouslyRecorded = 1; } return(false); }
public bool RecordBatchedLine(LastMacro macroRecorded, string line) { if (null == line) { line = ""; } return(RecordBatchedLine(macroRecorded, line, 0)); }
/// <summary> /// The record batched line. /// </summary> /// <param name="macroRecorded"> /// The macro recorded. /// </param> /// <param name="line"> /// The line. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool RecordBatchedLine(LastMacro macroRecorded, string line) { if (null == line) { line = string.Empty; } return(this.RecordBatchedLine(macroRecorded, line, 0)); }
public void RecordMove(LastMacro state, string direction, MoveScope scope, bool extend) { string macroString = ""; macroString += "ActiveDocument.Object.Move"; macroString += direction; // Get the number of times this macro type has been recorded already // (if any) and then add one to get the current count macroString += "(" + (int)scope + ", " + (m_Recorder.GetTimesPreviouslyRecorded(state) + 1) + ", " + (int)(extend ? tom.tomConstants.tomExtend : tom.tomConstants.tomMove) + ")"; m_Recorder.RecordBatchedLine(state, macroString); }
/// <summary> /// The record delete. /// </summary> /// <param name="backspace"> /// The backspace. /// </param> /// <param name="word"> /// The word. /// </param> public void RecordDelete(bool backspace, bool word) { // If not backspace then it's a delete // If not word then it's a single character LastMacro macroType = backspace ? (word ? LastMacro.BackspaceWord : LastMacro.BackspaceChar) : (word ? LastMacro.DeleteWord : LastMacro.DeleteChar); // Get the number of times the macro type calculated above has been recorded already // (if any) and then add one to get the current count uint count = this.m_Recorder.GetTimesPreviouslyRecorded(macroType) + 1; string macroString = string.Empty; // if this parameter is negative, it indicates a backspace, rather then a delete macroString += "ActiveDocument.Object.Delete(" + (int)(word ? tomConstants.tomWord : tomConstants.tomCharacter) + ", " + (backspace ? -1 * count : count) + ")"; this.m_Recorder.RecordBatchedLine(macroType, macroString); }
public uint GetTimesPreviouslyRecorded(LastMacro macro) { return IsLastRecordedMacro(macro) ? m_TimesPreviouslyRecorded : 0; }
public VSMacroRecorder(Guid emitter) { this.m_LastMacroRecorded = LastMacro.None; this.m_GuidEmitter = emitter; }
public void RecordMove(LastMacro state, string direction, MoveScope scope, bool extend) { var macroString = string.Empty; macroString += "ActiveDocument.Object.Move"; macroString += direction; // Get the number of times this macro type has been recorded already // (if any) and then add one to get the current count macroString += "(" + (int) scope + ", " + (m_Recorder.GetTimesPreviouslyRecorded(state) + 1) + ", " + (int) (extend ? tom.tomConstants.tomExtend : tom.tomConstants.tomMove) + ")"; m_Recorder.RecordBatchedLine(state, macroString); }
public void RecordNonprintableChar(Keys currentKey) { string macroString = ""; // Obtain the CTRL and SHIFT as they modify a number of the virtual keys. bool shiftDown = System.Windows.Forms.Keys.Shift == (System.Windows.Forms.Control.ModifierKeys & System.Windows.Forms.Keys.Shift); //Keyboard::IsKeyDown(VK_SHIFT); bool controlDown = System.Windows.Forms.Keys.Control == (System.Windows.Forms.Control.ModifierKeys & System.Windows.Forms.Keys.Control); //Keyboard::IsKeyDown(VK_CONTROL); // msg.WParam indicates the virtual key. switch (currentKey) { case Keys.Back: // BackSpace key // Note that SHIFT does not affect this command RecordDelete(true, controlDown); break; case Keys.Delete: // Note that SHIFT completely disables this command if (!shiftDown) { RecordDelete(false, controlDown); } break; case Keys.Left: // Left Arrow // SHIFT indicates selection, CTRL indicates words instead of characters { LastMacro macroType = controlDown ? (shiftDown ? LastMacro.LeftArrowWordSelection : LastMacro.LeftArrowWord) : (shiftDown ? LastMacro.LeftArrowCharSelection : LastMacro.LeftArrowChar); RecordMove(macroType, "Left", controlDown ? MoveScope.Word : MoveScope.Character, shiftDown); } break; case Keys.Right: // Right Arrow // SHIFT indicates selection, CTRL indicates words instead of characters { LastMacro macroType = controlDown ? (shiftDown ? LastMacro.RightArrowWordSelection : LastMacro.RightArrowWord) : (shiftDown ? LastMacro.RightArrowCharSelection : LastMacro.RightArrowChar); RecordMove(macroType, "Right", controlDown ? MoveScope.Word : MoveScope.Character, shiftDown); } break; case Keys.Up: // Up Arrow // SHIFT indicates selection, CTRL indicates paragraphs instead of lines { LastMacro macroType = controlDown ? (shiftDown ? LastMacro.UpArrowParaSelection : LastMacro.UpArrowPara) : (shiftDown ? LastMacro.UpArrowLineSelection : LastMacro.UpArrowLine); RecordMove(macroType, "Up", controlDown ? MoveScope.Paragraph : MoveScope.Line, shiftDown); } break; case Keys.Down: // Down Arrow // SHIFT indicates selection, CTRL indicates paragraphs instead of lines { LastMacro macroType = controlDown ? (shiftDown ? LastMacro.DownArrowParaSelection : LastMacro.DownArrowPara) : (shiftDown ? LastMacro.DownArrowLineSelection : LastMacro.DownArrowLine); RecordMove(macroType, "Down", controlDown ? MoveScope.Paragraph : MoveScope.Line, shiftDown); } break; case Keys.Prior: // Page Up case Keys.Next: // Page Down macroString += "ActiveDocument.Object.Move"; if (System.Windows.Forms.Keys.Prior == currentKey) { macroString += "Up"; } else { macroString += "Down"; } macroString += "(" + (int)(controlDown ? tom.tomConstants.tomWindow : tom.tomConstants.tomScreen) + ", 1, " + (int)(shiftDown ? tom.tomConstants.tomExtend : tom.tomConstants.tomMove) + ")"; m_Recorder.RecordLine(macroString); break; case Keys.End: case Keys.Home: macroString += "ActiveDocument.Object."; if (System.Windows.Forms.Keys.End == currentKey) { macroString += "EndKey"; } else { macroString += "HomeKey"; } macroString += "(" + (int)(controlDown ? tom.tomConstants.tomStory : tom.tomConstants.tomLine) + ", " + (int)(shiftDown ? tom.tomConstants.tomExtend : tom.tomConstants.tomMove) + ")"; m_Recorder.RecordLine(macroString); break; case Keys.Insert: // Note that the CTRL completely disables this command. Also the SHIFT+INSERT // actually generates a WM_PASTE message rather than a WM_KEYDOWN if (!controlDown) { macroString = "ActiveDocument.Object.Flags = ActiveDocument.Object.Flags Xor "; macroString += (int)tom.tomConstants.tomSelOvertype; m_Recorder.RecordLine(macroString); } break; } }
public VsMacroRecorder(Guid guid) { this.m_LastMacroRecorded = LastMacro.None; this.m_GuidEmitter = guid; }
public bool RecordBatchedLine(LastMacro macroRecorded, string line, int maxLineLength) { if (null == line) line = ""; if (maxLineLength > 0 && line.Length >= maxLineLength) { // Reset the state after recording the line, so it will not be appended to further RecordLine(line); // Notify the caller that the this line will not be appended to further return true; } if(IsLastRecordedMacro(macroRecorded)) { m_VsMacroRecorder.ReplaceLine(line, ref m_GuidEmitter); // m_LastMacroRecorded can stay the same ++m_TimesPreviouslyRecorded; } else { m_VsMacroRecorder.RecordLine(line, ref m_GuidEmitter); m_LastMacroRecorded = macroRecorded; m_TimesPreviouslyRecorded = 1; } return false; }
public uint GetTimesPreviouslyRecorded(LastMacro macro) { return(IsLastRecordedMacro(macro) ? m_TimesPreviouslyRecorded : 0); }
public bool IsLastRecordedMacro(LastMacro macro) { return (macro == m_LastMacroRecorded && ObjectIsLastMacroEmitter()) ? true : false; }
public bool RecordBatchedLine(LastMacro macroRecorded, string line) { if (null == line) line = ""; return RecordBatchedLine(macroRecorded, line, 0); }
// Compiler generated destructor is fine public void Reset() { m_LastMacroRecorded = LastMacro.None; m_TimesPreviouslyRecorded = 0; }
public bool IsLastRecordedMacro(LastMacro macro) { return((macro == m_LastMacroRecorded && ObjectIsLastMacroEmitter()) ? true : false); }