Updated to crystal 1.0 json api
Now excludes windows without a name in the list and handles null values for namesmaster
parent
da4f6fd47b
commit
9b5b9b9562
|
@ -3,17 +3,32 @@ require "option_parser"
|
||||||
|
|
||||||
version = "0.1"
|
version = "0.1"
|
||||||
|
|
||||||
|
struct Nil
|
||||||
|
def includes? ( a : String)
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class Window
|
class Window
|
||||||
JSON.mapping({
|
include JSON::Serializable
|
||||||
id: UInt32,
|
|
||||||
name: String,
|
property id : UInt32 = 0
|
||||||
wtype: {type: String, key: "type"},
|
|
||||||
app_id: {type: String, default: ""},
|
@[JSON::Field(emit_null: true)]
|
||||||
wclass: {type: String, key: "class", default: ""},
|
property name : String?
|
||||||
marks: {type: Array(String), default: [] of String},
|
|
||||||
nodes: {type: Array(Window), default: [] of Window},
|
@[JSON::Field(key: "type")]
|
||||||
focused: {type: Bool, default: false}
|
property wtype : String = ""
|
||||||
})
|
|
||||||
|
property app_id : String = ""
|
||||||
|
|
||||||
|
@[JSON::Field(key: "class")]
|
||||||
|
property wclass : String = ""
|
||||||
|
|
||||||
|
property marks : Array(String) = [] of String
|
||||||
|
property nodes : Array(Window) = [] of Window
|
||||||
|
|
||||||
|
property focused : Bool = false
|
||||||
|
|
||||||
def clear_nodes
|
def clear_nodes
|
||||||
@nodes = [] of Window
|
@nodes = [] of Window
|
||||||
|
@ -23,7 +38,7 @@ end
|
||||||
def node_loop (root : Window)
|
def node_loop (root : Window)
|
||||||
list = [] of Window
|
list = [] of Window
|
||||||
root.nodes.each do |node|
|
root.nodes.each do |node|
|
||||||
if node.wtype == "con"
|
if node.wtype == "con" && !node.name.nil?
|
||||||
list << node
|
list << node
|
||||||
elsif !node.nodes.empty?
|
elsif !node.nodes.empty?
|
||||||
list.concat node_loop node
|
list.concat node_loop node
|
||||||
|
|
Loading…
Reference in New Issue