Class: SciTE::Window

Inherits:
KDE::Window show all
Defined in:
lib/scite/window.rb

Overview

SciTE-specific operations over windows in KDE.

Instance Attribute Summary collapse

Attributes inherited from KDE::Window

#pid, #position, #title

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from KDE::Window

find, #wait, #wid

Constructor Details

#initialize(title: nil, pid: nil, wid: nil, session: nil, move_to: nil) ⇒ Window

Returns a new instance of Window.



81
82
83
84
# File 'lib/scite/window.rb', line 81

def initialize(title: nil, pid: nil, wid: nil, session: nil, move_to: nil)
  @session, @move_to = session, move_to
  super title: title, pid: pid, wid: wid
end

Instance Attribute Details

#move_toObject (readonly)

Returns the value of attribute move_to.



69
70
71
# File 'lib/scite/window.rb', line 69

def move_to
  @move_to
end

#sessionObject

Returns the value of attribute session.



69
70
71
# File 'lib/scite/window.rb', line 69

def session
  @session
end

Class Method Details

.find_all(title: '.+ [-*] SciTE') ⇒ Object

@ title : String : regexp-ish of title of windows you want to select



73
74
75
76
77
78
79
# File 'lib/scite/window.rb', line 73

def self.find_all(title: '.+ [-*] SciTE')
  `wmctrl -l -p`.split("\n").map {|line|
    if line[/^(0x\w+) +-?\d+ (\d+) +\S+ +(#{title})$/]
      new(title: $3, pid: $2.to_i, wid: $1)
    end
  }.compact
end

Instance Method Details

#create(&oncreate) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/scite/window.rb', line 86

def create(&oncreate)
  @pid ||= SciTE.run loadsession: "#{SciTE::Session.home}/#@session"
  @threads << Thread.new {
    sleep 0.2
    self.position = {w: 50, h: 20, x: 2550, y: -40}
    sleep 3 # let tabs to be rendered
    move if @move_to
    set_title if @title
    yield self if block_given?
  }
  self
end

#move(frames: 20, duration: 400.0, **coords) ⇒ Object



99
100
101
102
# File 'lib/scite/window.rb', line 99

def move(frames: 20, duration: 400.0, **coords)
  coords.reverse_merge! @move_to if @move_to
  super
end

#set_titleObject



104
105
106
# File 'lib/scite/window.rb', line 104

def set_title
  SciTE.set_title wid, @title
end