Class: Qt::PlainTextEdit
  
  
  
  
    
      Constant Summary
      collapse
    
    
      
        - BLANK =
          
        
 
        ''.freeze
 
      
        - BREAK =
          
        
 
        '<br/>'.freeze
 
      
        - AMP =
          
        
 
        '&'.freeze
 
      
        - NBSP =
          
        
 
        ' '.freeze
 
      
        - GT =
          
        
 
        '>'.freeze
 
      
        - LT =
          
        
 
        '<'.freeze
 
      
        - @@color_cache =
          
        
 
        {} 
      
        - @@mapping =
          
        
 
        {'&'=>AMP,"\n"=>BLANK,"\s"=>NBSP,'>'=>GT,'<'=>LT} 
      
        - @@regex =
          
        
 
        Regexp.union(@@mapping.keys)
 
      
    
  
  
    
      Instance Method Summary
      collapse
    
    
  
  
    Instance Method Details
    
      
  
  
    #add_formatted_text(text, color = nil)  ⇒ Object 
  
  
  
  
    
      
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492 
     | 
    
      # File 'lib/cosmos/gui/qt.rb', line 475
def add_formatted_text(text, color = nil)
  if text =~ /[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F-\xFF]/
    text.chomp!
    text = text.inspect.remove_quotes
    text << "\n"
  end
  if text =~ /<G>/ or color == Cosmos::GREEN
    addText(text.gsub(/<G>/, BLANK), Cosmos::GREEN)
  elsif text =~ /<Y>/ or color == Cosmos::YELLOW
    addText(text.gsub(/<Y>/, BLANK), Cosmos::YELLOW)
  elsif text =~ /<R>/ or color == Cosmos::RED
    addText(text.gsub(/<R>/, BLANK), Cosmos::RED)
  elsif text =~ /<B>/ or color == Cosmos::BLUE
    addText(text.gsub(/<B>/, BLANK), Cosmos::BLUE)
  else
    addText(text)   end
end
     | 
  
 
    
      
  
  
    #addText(text, color = Cosmos::BLACK)  ⇒ Object 
  
  
  
  
    
      
494
495
496
497 
     | 
    
      # File 'lib/cosmos/gui/qt.rb', line 494
def addText(text, color = Cosmos::BLACK)
  @current_text ||= ''
  @current_text << escape_text(text.chomp, color) << BREAK
end 
     | 
  
 
    
      
  
  
    #appendText(text, color = Cosmos::BLACK)  ⇒ Object 
  
  
  
  
    
      
504
505
506 
     | 
    
      # File 'lib/cosmos/gui/qt.rb', line 504
def appendText(text, color = Cosmos::BLACK)
  appendHtml(escape_text(text.chomp, color))
end 
     | 
  
 
    
      
  
  
    
      
499
500
501
502 
     | 
    
      # File 'lib/cosmos/gui/qt.rb', line 499
def flush
  appendHtml(@current_text)
  @current_text.clear
end 
     | 
  
 
    
      
  
  
    #selected_lines  ⇒ Object 
  
  
  
  
    
Return the selected lines. If a partial line is selected the entire line will be returned. If there is no selection the line with the cursor will be returned
   
 
  
  
    
      
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537 
     | 
    
      # File 'lib/cosmos/gui/qt.rb', line 510
def selected_lines
  cursor = textCursor
  selection_end = cursor.selectionEnd
      cursor.setPosition(textCursor.selectionStart)
  cursor.movePosition(Qt::TextCursor::StartOfLine)
    cursor.setPosition(selection_end, Qt::TextCursor::KeepAnchor)
            unless (cursor.atBlockStart and textCursor.hasSelection)
    cursor.movePosition(Qt::TextCursor::EndOfLine, Qt::TextCursor::KeepAnchor)
  end
    return nil if cursor.selectedText.nil?
  cursor.selection.toPlainText
          end
     | 
  
 
    
      
  
  
    #selection_end_line  ⇒ Object 
  
  
  
  
    
Return the line number (0 based) of the selection end
   
 
  
  
    
      
547
548
549
550
551 
     | 
    
      # File 'lib/cosmos/gui/qt.rb', line 547
def selection_end_line
  cursor = textCursor
  cursor.setPosition(textCursor.selectionEnd)
  cursor.blockNumber
end 
     | 
  
 
    
      
  
  
    #selection_start_line  ⇒ Object 
  
  
  
  
    
Return the line number (0 based) of the selection start
   
 
  
  
    
      
540
541
542
543
544 
     | 
    
      # File 'lib/cosmos/gui/qt.rb', line 540
def selection_start_line
  cursor = textCursor
  cursor.setPosition(textCursor.selectionStart)
  cursor.blockNumber
end 
     |