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); } }
int BookViewPreview::GetSelectionOffset(const QMap<int, QString> &node_offsets, Searchable::Direction search_direction) { QList<ViewEditor::ElementIndex> cl = GetCaretLocation(); // remove final #text node if it exists if (cl.at(cl.count()-1).name == "#text") { cl.removeLast(); } QString caret_node = ConvertHierarchyToQWebPath(cl); bool searching_down = search_direction == Searchable::Direction_Down ? true : false; int local_offset = GetLocalSelectionOffset(!searching_down); int search_start = node_offsets.key(caret_node) + local_offset; return search_start; }
int BookViewPreview::GetSelectionOffset(const QMap<int, QString> &node_offsets, Searchable::Direction search_direction) { QList<ViewEditor::ElementIndex> cl = GetCaretLocation(); // remove final #text node if it exists // Some BookView tabs with only SVG images report a cl.count of 0 // meaning there is no cursor, so test for that case if ((cl.count() > 0) && (cl.at(cl.count()-1).name == "#text")) { cl.removeLast(); } QString caret_node = ConvertHierarchyToQWebPath(cl); bool searching_down = search_direction == Searchable::Direction_Down ? true : false; int local_offset = GetLocalSelectionOffset(!searching_down); int search_start = node_offsets.key(caret_node) + local_offset; return search_start; }
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 JXInputField::HandleKeyPress ( const int key, const JXKeyModifiers& modifiers ) { if (itsTable != NULL && itsTable->WantsInputFieldKey(key, modifiers)) { itsTable->HandleKeyPress(key, modifiers); return; } else if (itsTable != NULL) { JPoint cell; const JBoolean ok = itsTable->GetEditedCell(&cell); assert( ok ); itsTable->TableScrollToCell(cell); } if (key == JXCtrl('K') && modifiers.control() && HasSelection()) { Cut(); } else if (key == JXCtrl('K') && modifiers.control()) { JIndex i; const JBoolean ok = GetCaretLocation(&i); assert( ok ); SetSelection(i, GetTextLength()); Cut(); } else { JXTEBase::HandleKeyPress(key, modifiers); } }
QString BookViewPreview::GetCaretLocationUpdate() { StoreCaretLocationUpdate(GetCaretLocation()); return m_CaretLocationUpdate; }
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(); } }