void CBShellEditor::InsertText ( const JString& text ) { JIndex index; const JBoolean hadCaret = GetCaretLocation(&index); SetCaretLocation(itsInsertIndex); SetCurrentFont(itsInsertFont); const JSize count = PasteUNIXTerminalOutput(text); SetCurrentFont(GetDefaultFont()); ClearUndo(); itsInsertIndex += count; if (hadCaret) { index += count; SetCaretLocation(index); } const JIndex i = itsInsertIndex-1; if (GetFontStyle(i).bold) { SetFontBold(i, i, kJFalse, kJTrue); } }
void CMHistoryText::PlaceCursorAtEnd() { if (!IsEmpty()) { SetCaretLocation(GetTextLength()+1); if (GetText().GetLastCharacter() != '\n') { Paste("\n"); } } }
void JXPathInput::ApertureResized ( const JCoordinate dw, const JCoordinate dh ) { JXInputField::ApertureResized(dw,dh); if (!HasFocus()) { SetCaretLocation(GetTextLength() + 1); } }
void JXSaveFileInput::HandleFocusEvent() { JXInputField::HandleFocusEvent(); JString root, suffix; if (JSplitRootAndSuffix(GetText(), &root, &suffix)) { if (root.IsEmpty()) { SetCaretLocation(1); } else { SetSelection(1, root.GetLength()); } } }
void JXPathInput::Receive ( JBroadcaster* sender, const Message& message ) { if (sender == this && message.Is(JTextEditor::kTextSet)) { SetCaretLocation(GetTextLength() + 1); } else if (sender == this && message.Is(JTextEditor::kCaretLocationChanged)) { JIndex i; WantInput(kJTrue, JI2B(GetCaretLocation(&i) && i == GetTextLength()+1), WantsModifiedTab()); } JXInputField::Receive(sender, message); }
void JXPathInput::HandleUnfocusEvent() { JXInputField::HandleUnfocusEvent(); SetCaretLocation(GetTextLength() + 1); }
void CBShellEditor::HandleKeyPress ( const int key, const JXKeyModifiers& modifiers ) { const JBoolean controlOn = modifiers.control(); const JBoolean metaOn = modifiers.meta(); const JBoolean shiftOn = modifiers.shift(); if ((key == kJLeftArrow && metaOn && !controlOn && !shiftOn) || (key == JXCtrl('A') && controlOn && !metaOn && !shiftOn)) { const JIndex index = GetInsertionIndex(); const JRunArray<Font>& styles = GetStyles(); if (index > 1 && styles.GetElement(index-1) == GetDefaultFont()) { JIndex runIndex, firstIndexInRun; const JBoolean ok = styles.FindRun(index-1, &runIndex, &firstIndexInRun); SetCaretLocation(firstIndexInRun); return; } } if (key == kJReturnKey) { SetCurrentFont(itsInsertFont); } else { SetCurrentFont(GetDefaultFont()); } JBoolean sentCmd = kJFalse; if (key == kJReturnKey && !modifiers.shift() && !HasSelection()) { JIndex index; JBoolean ok = GetCaretLocation(&index); assert( ok ); JString cmd; const JRunArray<Font>& styles = GetStyles(); if (index > 1 && styles.GetElement(index-1) == GetDefaultFont()) { JIndex runIndex, firstIndexInRun; ok = styles.FindRun(index-1, &runIndex, &firstIndexInRun); const JIndex endIndex = firstIndexInRun + styles.GetRunLength(runIndex); cmd = (GetText()).GetSubstring(firstIndexInRun, endIndex - 1); SetCaretLocation(endIndex); if (cmd.BeginsWith("man ")) { cmd.ReplaceSubstring(1, 4, "jcc --man "); } else if (cmd.BeginsWith("apropos ")) { cmd.ReplaceSubstring(1, 8, "jcc --apropos "); } else if (cmd.BeginsWith("vi ")) { cmd.ReplaceSubstring(1, 3, "jcc "); } else if (cmd.BeginsWith("less ") || cmd.BeginsWith("more ")) { cmd.ReplaceSubstring(1, 5, "jcc "); } else if (cmd == "more" || cmd == "less" || cmd == "vi") { cmd = "jcc"; } } cmd += "\n"; itsShellDoc->SendCommand(cmd); sentCmd = kJTrue; } CBTextEditor::HandleKeyPress(key, modifiers); if (sentCmd) { itsInsertIndex = GetInsertionIndex(); } }