void JTEStyler::AdjustStyle ( const JIndexRange& range, const JFontStyle& style ) { assert( range.last < itsTokenStart ); assert( itsRecalcRange != NULL ); *itsRecalcRange += range; // adjust the styles JFont f = itsStyles->GetElement(range.first); f.SetStyle(style); itsStyles->SetNextElements(range.first, range.GetLength(), f); // update state if (itsTokenStart <= itsStyles->GetElementCount()) { const JBoolean ok = itsStyles->FindRun(itsTokenStart, &itsTokenRunIndex, &itsTokenFirstInRun); assert( ok ); } }
void JTEStyler::AdjustStyle ( const JIndexRange& range, const JFontStyle& style ) { assert( range.last < itsTokenStart ); assert( itsRecalcRange != NULL ); *itsRecalcRange += range; // adjust the styles JTextEditor::Font f = itsStyles->GetElement(range.first); f.size = itsFontSize; f.style = style; if (OnlyColorChanged(style, itsDefFontStyle)) { f.id = itsDefFontID; } else { f.id = itsFontMgr->GetFontID(itsFontName, itsFontSize, style); } itsStyles->SetNextElements(range.first, range.GetLength(), f); // update state if (itsTokenStart <= itsStyles->GetElementCount()) { const JBoolean ok = itsStyles->FindRun(itsTokenStart, &itsTokenRunIndex, &itsTokenFirstInRun); assert( ok ); } }
JBoolean JTEStyler::SetStyle ( const JIndexRange& range, const JFontStyle& style ) { assert( !range.IsEmpty() ); if (itsCheckRange.last < range.first) { // we are beyond the range where anything could have changed return kJFalse; } assert( range.first == itsTokenStart ); if (itsRedoAllFlag) { JFontID fid = itsDefFontID; if (!OnlyColorChanged(style, itsDefFontStyle)) { fid = itsFontMgr->GetFontID(itsFontName, itsFontSize, style); } itsStyles->AppendElements(JTextEditor::Font(fid, itsFontSize, style, itsDefFontAlign), range.GetLength()); } else if (range.last >= itsCheckRange.first) { JIndexRange fontRange; fontRange.SetFirstAndLength(itsTokenFirstInRun, itsStyles->GetRunLength(itsTokenRunIndex)); const JBoolean beyondCurrentRun = JNegate( fontRange.Contains(range) ); JTextEditor::Font f = itsStyles->GetRunData(itsTokenRunIndex); if (beyondCurrentRun || style != f.style) { // extend the check range if we slop over into another style run // (HTML: type '<' after 'x' in "x<!--<br><h3>text</h3>-->") // extend past end of run to insure that we keep going until we // find a correctly styled token if (beyondCurrentRun) { JIndex runIndex = itsTokenRunIndex; JIndex firstInRun = itsTokenFirstInRun; const JBoolean ok = itsStyles->FindRun(itsTokenStart, range.last, &runIndex, &firstInRun); ExtendCheckRange(firstInRun + itsStyles->GetRunLength(runIndex)); } // extend check range to next token since this token was not // correctly styled -- should only stop when find correctly // styled tokens else // style != f.style { ExtendCheckRange(range.last+1); } // update the styles if (!beyondCurrentRun && OnlyColorChanged(style, f.style)) { *itsRedrawRange += range; } else { *itsRecalcRange += range; } f.size = itsFontSize; f.style = style; if (OnlyColorChanged(style, itsDefFontStyle)) { f.id = itsDefFontID; } else { f.id = itsFontMgr->GetFontID(itsFontName, itsFontSize, style); } f.align = itsDefFontAlign; itsStyles->RemoveNextElements(range.first, range.GetLength(), &itsTokenRunIndex, &itsTokenFirstInRun); run_assert(itsStyles, range.first, itsTokenRunIndex, itsTokenFirstInRun); itsStyles->InsertElementsAtIndex(range.first, f, range.GetLength(), &itsTokenRunIndex, &itsTokenFirstInRun); run_assert(itsStyles, range.first, itsTokenRunIndex, itsTokenFirstInRun); } } itsTokenStart = range.last+1; if (!itsRedoAllFlag) { const JBoolean ok = itsStyles->FindRun(range.first, itsTokenStart, &itsTokenRunIndex, &itsTokenFirstInRun); assert( ok || range.last == itsText->GetLength() ); assert( range.last == itsText->GetLength() || check_run(itsStyles, itsTokenStart, itsTokenRunIndex, itsTokenFirstInRun) ); } return JConvertToBoolean( range.last < itsCheckRange.last ); }
void LLDBGetAssembly::HandleSuccess ( const JString& cmdData ) { LLDBLink* link = dynamic_cast<LLDBLink*>(CMGetLink()); if (link == NULL) { return; } lldb::SBCommandInterpreter interp = link->GetDebugger()->GetCommandInterpreter(); if (!interp.IsValid()) { return; } const CMLocation& loc = (GetDirector())->GetDisassemblyLocation(); const JString cmd = "disassemble -n " + JPrepArgForExec(loc.GetFunctionName()); lldb::SBCommandReturnObject result; interp.HandleCommand(cmd, result); JPtrArray<JString> addrList(JPtrArrayT::kDeleteAll); JString instText; if (result.IsValid() && result.Succeeded() && result.HasResult()) { std::istringstream input(result.GetOutput()); JString line, s; JSize maxOffsetLength = 0; while (!input.eof() && !input.fail()) { line = JReadLine(input); JIndex i; if (line.LocateSubstring(":", &i) && i < line.GetLength()) { s = line.GetSubstring(1, i-1); if (s.BeginsWith("->") && s.GetLength() > 2) { s = s.GetSubstring(3, s.GetLength()); } s.TrimWhitespace(); addrList.Append(s); JIndexRange r; if (offsetPattern.Match(s, &r)) { maxOffsetLength = JMax(maxOffsetLength, r.GetLength()); } if (!instText.IsEmpty()) { instText.AppendCharacter('\n'); } s = line.GetSubstring(i+1, line.GetLength()); s.TrimWhitespace(); instText.Append(s); } } const JSize count = addrList.GetElementCount(); for (JIndex i=1; i<count; i++) { JString* s = addrList.NthElement(i); JIndexRange r; if (offsetPattern.Match(*s, &r)) { const JSize pad = maxOffsetLength - r.GetLength(); for (JIndex j=0; j<pad; j++) { s->InsertCharacter('0', r.first+2); } } } } (GetDirector())->DisplayDisassembly(&addrList, instText); }