tty-link 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -0
- data/LICENSE.txt +1 -1
- data/README.md +278 -27
- data/lib/tty/link/ansi_link.rb +105 -0
- data/lib/tty/link/errors.rb +77 -0
- data/lib/tty/link/hyperlink_parameter.rb +95 -0
- data/lib/tty/link/plain_link.rb +52 -0
- data/lib/tty/link/semantic_version.rb +204 -0
- data/lib/tty/link/terminals/abstract.rb +189 -0
- data/lib/tty/link/terminals/alacritty.rb +50 -0
- data/lib/tty/link/terminals/contour.rb +96 -0
- data/lib/tty/link/terminals/domterm.rb +107 -0
- data/lib/tty/link/terminals/foot.rb +50 -0
- data/lib/tty/link/terminals/hyper.rb +54 -0
- data/lib/tty/link/terminals/iterm.rb +54 -0
- data/lib/tty/link/terminals/jediterm.rb +71 -0
- data/lib/tty/link/terminals/kitty.rb +48 -0
- data/lib/tty/link/terminals/konsole.rb +65 -0
- data/lib/tty/link/terminals/mintty.rb +54 -0
- data/lib/tty/link/terminals/rio.rb +54 -0
- data/lib/tty/link/terminals/tabby.rb +50 -0
- data/lib/tty/link/terminals/terminology.rb +54 -0
- data/lib/tty/link/terminals/vscode.rb +54 -0
- data/lib/tty/link/terminals/vte.rb +65 -0
- data/lib/tty/link/terminals/wezterm.rb +71 -0
- data/lib/tty/link/terminals/wt.rb +63 -0
- data/lib/tty/link/terminals.rb +71 -0
- data/lib/tty/link/version.rb +2 -2
- data/lib/tty/link.rb +279 -40
- data/lib/tty-link.rb +2 -0
- metadata +44 -44
- data/.gitignore +0 -12
- data/.rspec +0 -3
- data/.travis.yml +0 -23
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -12
- data/ISSUE_TEMPLATE.md +0 -23
- data/PULL_REQUEST_TEMPLATE.md +0 -18
- data/Rakefile +0 -8
- data/appveyor.yml +0 -28
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/tasks/console.rake +0 -11
- data/tasks/coverage.rake +0 -11
- data/tasks/spec.rake +0 -29
- data/tty-link.gemspec +0 -36
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "abstract"
|
4
|
+
|
5
|
+
module TTY
|
6
|
+
class Link
|
7
|
+
module Terminals
|
8
|
+
# Responsible for detecting hyperlink support in the Foot terminal
|
9
|
+
#
|
10
|
+
# @api private
|
11
|
+
class Foot < Abstract
|
12
|
+
# The Foot terminal name pattern
|
13
|
+
#
|
14
|
+
# @return [Regexp]
|
15
|
+
#
|
16
|
+
# @api private
|
17
|
+
FOOT = /foot/i.freeze
|
18
|
+
private_constant :FOOT
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# Detect Foot terminal
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# foot.name?
|
26
|
+
# # => true
|
27
|
+
#
|
28
|
+
# @return [Boolean]
|
29
|
+
#
|
30
|
+
# @api private
|
31
|
+
def name?
|
32
|
+
!(term =~ FOOT).nil?
|
33
|
+
end
|
34
|
+
|
35
|
+
# Detect any Foot version to support terminal hyperlinks
|
36
|
+
#
|
37
|
+
# @example
|
38
|
+
# foot.version?
|
39
|
+
# # => true
|
40
|
+
#
|
41
|
+
# @return [Boolean]
|
42
|
+
#
|
43
|
+
# @api private
|
44
|
+
def version?
|
45
|
+
true
|
46
|
+
end
|
47
|
+
end # Foot
|
48
|
+
end # Terminals
|
49
|
+
end # Link
|
50
|
+
end # TTY
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "abstract"
|
4
|
+
|
5
|
+
module TTY
|
6
|
+
class Link
|
7
|
+
module Terminals
|
8
|
+
# Responsible for detecting hyperlink support in the Hyper terminal
|
9
|
+
#
|
10
|
+
# @api private
|
11
|
+
class Hyper < Abstract
|
12
|
+
# The Hyper terminal name pattern
|
13
|
+
#
|
14
|
+
# @return [Regexp]
|
15
|
+
#
|
16
|
+
# @api private
|
17
|
+
HYPER = /Hyper/i.freeze
|
18
|
+
private_constant :HYPER
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# Detect Hyper terminal
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# hyper.name?
|
26
|
+
# # => true
|
27
|
+
#
|
28
|
+
# @return [Boolean]
|
29
|
+
#
|
30
|
+
# @api private
|
31
|
+
def name?
|
32
|
+
!(term_program =~ HYPER).nil?
|
33
|
+
end
|
34
|
+
|
35
|
+
# Detect whether the Hyper version supports terminal hyperlinks
|
36
|
+
#
|
37
|
+
# @example
|
38
|
+
# hyper.version?
|
39
|
+
# # => true
|
40
|
+
#
|
41
|
+
# @return [Boolean]
|
42
|
+
#
|
43
|
+
# @api private
|
44
|
+
def version?
|
45
|
+
return false unless term_program_version
|
46
|
+
|
47
|
+
current_semantic_version = semantic_version(term_program_version)
|
48
|
+
|
49
|
+
current_semantic_version >= semantic_version(2, 0, 0)
|
50
|
+
end
|
51
|
+
end # Hyper
|
52
|
+
end # Terminals
|
53
|
+
end # Link
|
54
|
+
end # TTY
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "abstract"
|
4
|
+
|
5
|
+
module TTY
|
6
|
+
class Link
|
7
|
+
module Terminals
|
8
|
+
# Responsible for detecting hyperlink support in the iTerm terminal
|
9
|
+
#
|
10
|
+
# @api private
|
11
|
+
class Iterm < Abstract
|
12
|
+
# The iTerm terminal name pattern
|
13
|
+
#
|
14
|
+
# @return [Regexp]
|
15
|
+
#
|
16
|
+
# @api private
|
17
|
+
ITERM = /iTerm(\s*\d+){0,1}.app/x.freeze
|
18
|
+
private_constant :ITERM
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# Detect iTerm terminal
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# iterm.name?
|
26
|
+
# # => true
|
27
|
+
#
|
28
|
+
# @return [Boolean]
|
29
|
+
#
|
30
|
+
# @api private
|
31
|
+
def name?
|
32
|
+
!(term_program =~ ITERM).nil?
|
33
|
+
end
|
34
|
+
|
35
|
+
# Detect whether the iTerm version supports terminal hyperlinks
|
36
|
+
#
|
37
|
+
# @example
|
38
|
+
# iterm.version?
|
39
|
+
# # => true
|
40
|
+
#
|
41
|
+
# @return [Boolean]
|
42
|
+
#
|
43
|
+
# @api private
|
44
|
+
def version?
|
45
|
+
return false unless term_program_version
|
46
|
+
|
47
|
+
current_semantic_version = semantic_version(term_program_version)
|
48
|
+
|
49
|
+
current_semantic_version >= semantic_version(3, 1, 0)
|
50
|
+
end
|
51
|
+
end # Iterm
|
52
|
+
end # Terminals
|
53
|
+
end # Link
|
54
|
+
end # TTY
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "abstract"
|
4
|
+
|
5
|
+
module TTY
|
6
|
+
class Link
|
7
|
+
module Terminals
|
8
|
+
# Responsible for detecting hyperlink support in the JediTerm terminal
|
9
|
+
#
|
10
|
+
# @api private
|
11
|
+
class Jediterm < Abstract
|
12
|
+
# The JediTerm terminal name pattern
|
13
|
+
#
|
14
|
+
# @return [Regexp]
|
15
|
+
#
|
16
|
+
# @api private
|
17
|
+
JEDITERM = /JediTerm/i.freeze
|
18
|
+
private_constant :JEDITERM
|
19
|
+
|
20
|
+
# The terminal emulator environment variable name
|
21
|
+
#
|
22
|
+
# @return [String]
|
23
|
+
#
|
24
|
+
# @api private
|
25
|
+
TERMINAL_EMULATOR = "TERMINAL_EMULATOR"
|
26
|
+
private_constant :TERMINAL_EMULATOR
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
# Detect JediTerm terminal
|
31
|
+
#
|
32
|
+
# @example
|
33
|
+
# jediterm.name?
|
34
|
+
# # => true
|
35
|
+
#
|
36
|
+
# @return [Boolean]
|
37
|
+
#
|
38
|
+
# @api private
|
39
|
+
def name?
|
40
|
+
!(terminal_emulator =~ JEDITERM).nil?
|
41
|
+
end
|
42
|
+
|
43
|
+
# Detect any JediTerm version to support terminal hyperlinks
|
44
|
+
#
|
45
|
+
# @example
|
46
|
+
# jediterm.version?
|
47
|
+
# # => true
|
48
|
+
#
|
49
|
+
# @return [Boolean]
|
50
|
+
#
|
51
|
+
# @api private
|
52
|
+
def version?
|
53
|
+
true
|
54
|
+
end
|
55
|
+
|
56
|
+
# Read the terminal emulator environment variable
|
57
|
+
#
|
58
|
+
# @example
|
59
|
+
# jediterm.terminal_emulator
|
60
|
+
# # => "JetBrains-JediTerm"
|
61
|
+
#
|
62
|
+
# @return [String, nil]
|
63
|
+
#
|
64
|
+
# @api private
|
65
|
+
def terminal_emulator
|
66
|
+
env[TERMINAL_EMULATOR]
|
67
|
+
end
|
68
|
+
end # Jediterm
|
69
|
+
end # Terminals
|
70
|
+
end # Link
|
71
|
+
end # TTY
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TTY
|
4
|
+
class Link
|
5
|
+
module Terminals
|
6
|
+
# Responsible for detecting hyperlink support in the kitty terminal
|
7
|
+
#
|
8
|
+
# @api private
|
9
|
+
class Kitty < Abstract
|
10
|
+
# The kitty terminal name pattern
|
11
|
+
#
|
12
|
+
# @return [Regexp]
|
13
|
+
#
|
14
|
+
# @api private
|
15
|
+
KITTY = /kitty/i.freeze
|
16
|
+
private_constant :KITTY
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# Detect kitty terminal
|
21
|
+
#
|
22
|
+
# @example
|
23
|
+
# kitty.name?
|
24
|
+
# # => true
|
25
|
+
#
|
26
|
+
# @return [Boolean]
|
27
|
+
#
|
28
|
+
# @api private
|
29
|
+
def name?
|
30
|
+
!(term =~ KITTY).nil?
|
31
|
+
end
|
32
|
+
|
33
|
+
# Detect any kitty version to support terminal hyperlinks
|
34
|
+
#
|
35
|
+
# @example
|
36
|
+
# kitty.version?
|
37
|
+
# # => true
|
38
|
+
#
|
39
|
+
# @return [Boolean]
|
40
|
+
#
|
41
|
+
# @api private
|
42
|
+
def version?
|
43
|
+
true
|
44
|
+
end
|
45
|
+
end # Kitty
|
46
|
+
end # Terminals
|
47
|
+
end # Link
|
48
|
+
end # TTY
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "abstract"
|
4
|
+
|
5
|
+
module TTY
|
6
|
+
class Link
|
7
|
+
module Terminals
|
8
|
+
# Responsible for detecting hyperlink support in the Konsole terminal
|
9
|
+
#
|
10
|
+
# @api private
|
11
|
+
class Konsole < Abstract
|
12
|
+
# The Konsole version environment variable name
|
13
|
+
#
|
14
|
+
# @return [String]
|
15
|
+
#
|
16
|
+
# @api private
|
17
|
+
KONSOLE_VERSION = "KONSOLE_VERSION"
|
18
|
+
private_constant :KONSOLE_VERSION
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# Detect Konsole terminal
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# konsole.name?
|
26
|
+
# # => true
|
27
|
+
#
|
28
|
+
# @return [Boolean]
|
29
|
+
#
|
30
|
+
# @api private
|
31
|
+
def name?
|
32
|
+
!konsole_version.nil?
|
33
|
+
end
|
34
|
+
|
35
|
+
# Detect whether the Konsole version supports terminal hyperlinks
|
36
|
+
#
|
37
|
+
# @example
|
38
|
+
# konsole.version?
|
39
|
+
# # => true
|
40
|
+
#
|
41
|
+
# @return [Boolean]
|
42
|
+
#
|
43
|
+
# @api private
|
44
|
+
def version?
|
45
|
+
current_semantic_version = semantic_version(konsole_version)
|
46
|
+
|
47
|
+
current_semantic_version >= semantic_version(20, 12, 0)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Read the Konsole version environment variable
|
51
|
+
#
|
52
|
+
# @example
|
53
|
+
# konsole.konsole_version
|
54
|
+
# # => "1.2.3"
|
55
|
+
#
|
56
|
+
# @return [String, nil]
|
57
|
+
#
|
58
|
+
# @api private
|
59
|
+
def konsole_version
|
60
|
+
env[KONSOLE_VERSION]
|
61
|
+
end
|
62
|
+
end # Konsole
|
63
|
+
end # Terminals
|
64
|
+
end # Link
|
65
|
+
end # TTY
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "abstract"
|
4
|
+
|
5
|
+
module TTY
|
6
|
+
class Link
|
7
|
+
module Terminals
|
8
|
+
# Responsible for detecting hyperlink support in the mintty terminal
|
9
|
+
#
|
10
|
+
# @api private
|
11
|
+
class Mintty < Abstract
|
12
|
+
# The mintty terminal name pattern
|
13
|
+
#
|
14
|
+
# @return [Regexp]
|
15
|
+
#
|
16
|
+
# @api private
|
17
|
+
MINTTY = /mintty/i.freeze
|
18
|
+
private_constant :MINTTY
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# Detect mintty terminal
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# mintty.name?
|
26
|
+
# # => true
|
27
|
+
#
|
28
|
+
# @return [Boolean]
|
29
|
+
#
|
30
|
+
# @api private
|
31
|
+
def name?
|
32
|
+
!(term_program =~ MINTTY).nil?
|
33
|
+
end
|
34
|
+
|
35
|
+
# Detect whether the mintty version supports terminal hyperlinks
|
36
|
+
#
|
37
|
+
# @example
|
38
|
+
# mintty.version?
|
39
|
+
# # => true
|
40
|
+
#
|
41
|
+
# @return [Boolean]
|
42
|
+
#
|
43
|
+
# @api private
|
44
|
+
def version?
|
45
|
+
return false unless term_program_version
|
46
|
+
|
47
|
+
current_semantic_version = semantic_version(term_program_version)
|
48
|
+
|
49
|
+
current_semantic_version >= semantic_version(2, 9, 7)
|
50
|
+
end
|
51
|
+
end # Mintty
|
52
|
+
end # Terminals
|
53
|
+
end # Link
|
54
|
+
end # TTY
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "abstract"
|
4
|
+
|
5
|
+
module TTY
|
6
|
+
class Link
|
7
|
+
module Terminals
|
8
|
+
# Responsible for detecting hyperlink support in the Rio terminal
|
9
|
+
#
|
10
|
+
# @api private
|
11
|
+
class Rio < Abstract
|
12
|
+
# The Rio terminal name pattern
|
13
|
+
#
|
14
|
+
# @return [Regexp]
|
15
|
+
#
|
16
|
+
# @api private
|
17
|
+
RIO = /rio/i.freeze
|
18
|
+
private_constant :RIO
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# Detect Rio terminal
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# rio.name?
|
26
|
+
# # => true
|
27
|
+
#
|
28
|
+
# @return [Boolean]
|
29
|
+
#
|
30
|
+
# @api private
|
31
|
+
def name?
|
32
|
+
!(term_program =~ RIO).nil?
|
33
|
+
end
|
34
|
+
|
35
|
+
# Detect whether the Rio version supports terminal hyperlinks
|
36
|
+
#
|
37
|
+
# @example
|
38
|
+
# rio.version?
|
39
|
+
# # => true
|
40
|
+
#
|
41
|
+
# @return [Boolean]
|
42
|
+
#
|
43
|
+
# @api private
|
44
|
+
def version?
|
45
|
+
return false unless term_program_version
|
46
|
+
|
47
|
+
current_semantic_version = semantic_version(term_program_version)
|
48
|
+
|
49
|
+
current_semantic_version >= semantic_version(0, 0, 28)
|
50
|
+
end
|
51
|
+
end # Rio
|
52
|
+
end # Terminals
|
53
|
+
end # Link
|
54
|
+
end # TTY
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "abstract"
|
4
|
+
|
5
|
+
module TTY
|
6
|
+
class Link
|
7
|
+
module Terminals
|
8
|
+
# Responsible for detecting hyperlink support in the Tabby terminal
|
9
|
+
#
|
10
|
+
# @api private
|
11
|
+
class Tabby < Abstract
|
12
|
+
# The Tabby terminal name pattern
|
13
|
+
#
|
14
|
+
# @return [Regexp]
|
15
|
+
#
|
16
|
+
# @api private
|
17
|
+
TABBY = /Tabby/i.freeze
|
18
|
+
private_constant :TABBY
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# Detect Tabby terminal
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# tabby.name?
|
26
|
+
# # => true
|
27
|
+
#
|
28
|
+
# @return [Boolean]
|
29
|
+
#
|
30
|
+
# @api private
|
31
|
+
def name?
|
32
|
+
!(term_program =~ TABBY).nil?
|
33
|
+
end
|
34
|
+
|
35
|
+
# Detect any Tabby version to support terminal hyperlinks
|
36
|
+
#
|
37
|
+
# @example
|
38
|
+
# tabby.version?
|
39
|
+
# # => true
|
40
|
+
#
|
41
|
+
# @return [Boolean]
|
42
|
+
#
|
43
|
+
# @api private
|
44
|
+
def version?
|
45
|
+
true
|
46
|
+
end
|
47
|
+
end # Tabby
|
48
|
+
end # Terminals
|
49
|
+
end # Link
|
50
|
+
end # TTY
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "abstract"
|
4
|
+
|
5
|
+
module TTY
|
6
|
+
class Link
|
7
|
+
module Terminals
|
8
|
+
# Responsible for detecting hyperlink support in the Terminology terminal
|
9
|
+
#
|
10
|
+
# @api private
|
11
|
+
class Terminology < Abstract
|
12
|
+
# The Terminology terminal name pattern
|
13
|
+
#
|
14
|
+
# @return [Regexp]
|
15
|
+
#
|
16
|
+
# @api private
|
17
|
+
TERMINOLOGY = /terminology/i.freeze
|
18
|
+
private_constant :TERMINOLOGY
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# Detect Terminology terminal
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# terminology.name?
|
26
|
+
# # => true
|
27
|
+
#
|
28
|
+
# @return [Boolean]
|
29
|
+
#
|
30
|
+
# @api private
|
31
|
+
def name?
|
32
|
+
!(term_program =~ TERMINOLOGY).nil?
|
33
|
+
end
|
34
|
+
|
35
|
+
# Detect whether the Terminology version supports terminal hyperlinks
|
36
|
+
#
|
37
|
+
# @example
|
38
|
+
# terminology.version?
|
39
|
+
# # => true
|
40
|
+
#
|
41
|
+
# @return [Boolean]
|
42
|
+
#
|
43
|
+
# @api private
|
44
|
+
def version?
|
45
|
+
return false unless term_program_version
|
46
|
+
|
47
|
+
current_semantic_version = semantic_version(term_program_version)
|
48
|
+
|
49
|
+
current_semantic_version >= semantic_version(1, 3, 0)
|
50
|
+
end
|
51
|
+
end # Terminology
|
52
|
+
end # Terminals
|
53
|
+
end # Link
|
54
|
+
end # TTY
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "abstract"
|
4
|
+
|
5
|
+
module TTY
|
6
|
+
class Link
|
7
|
+
module Terminals
|
8
|
+
# Responsible for detecting hyperlink support in the VSCode terminal
|
9
|
+
#
|
10
|
+
# @api private
|
11
|
+
class Vscode < Abstract
|
12
|
+
# The VSCode terminal name pattern
|
13
|
+
#
|
14
|
+
# @return [Regexp]
|
15
|
+
#
|
16
|
+
# @api private
|
17
|
+
VSCODE = /vscode/i.freeze
|
18
|
+
private_constant :VSCODE
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# Detect VSCode terminal
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# vscode.name?
|
26
|
+
# # => true
|
27
|
+
#
|
28
|
+
# @return [Boolean]
|
29
|
+
#
|
30
|
+
# @api private
|
31
|
+
def name?
|
32
|
+
!(term_program =~ VSCODE).nil?
|
33
|
+
end
|
34
|
+
|
35
|
+
# Detect whether the VSCode version supports terminal hyperlinks
|
36
|
+
#
|
37
|
+
# @example
|
38
|
+
# vscode.version?
|
39
|
+
# # => true
|
40
|
+
#
|
41
|
+
# @return [Boolean]
|
42
|
+
#
|
43
|
+
# @api private
|
44
|
+
def version?
|
45
|
+
return false unless term_program_version
|
46
|
+
|
47
|
+
current_semantic_version = semantic_version(term_program_version)
|
48
|
+
|
49
|
+
current_semantic_version >= semantic_version(1, 72, 0)
|
50
|
+
end
|
51
|
+
end # Vscode
|
52
|
+
end # Terminals
|
53
|
+
end # Link
|
54
|
+
end # TTY
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "abstract"
|
4
|
+
|
5
|
+
module TTY
|
6
|
+
class Link
|
7
|
+
module Terminals
|
8
|
+
# Responsible for detecting hyperlink support in the VTE-based terminal
|
9
|
+
#
|
10
|
+
# @api private
|
11
|
+
class Vte < Abstract
|
12
|
+
# The VTE version environment variable name
|
13
|
+
#
|
14
|
+
# @return [String]
|
15
|
+
#
|
16
|
+
# @api private
|
17
|
+
VTE_VERSION = "VTE_VERSION"
|
18
|
+
private_constant :VTE_VERSION
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# Detect VTE terminal
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# vte.name?
|
26
|
+
# # => true
|
27
|
+
#
|
28
|
+
# @return [Boolean]
|
29
|
+
#
|
30
|
+
# @api private
|
31
|
+
def name?
|
32
|
+
!vte_version.nil?
|
33
|
+
end
|
34
|
+
|
35
|
+
# Detect whether the VTE version supports terminal hyperlinks
|
36
|
+
#
|
37
|
+
# @example
|
38
|
+
# vte.version?
|
39
|
+
# # => true
|
40
|
+
#
|
41
|
+
# @return [Boolean]
|
42
|
+
#
|
43
|
+
# @api private
|
44
|
+
def version?
|
45
|
+
current_semantic_version = semantic_version(vte_version)
|
46
|
+
|
47
|
+
current_semantic_version >= semantic_version(0, 50, 1)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Read the VTE version environment variable
|
51
|
+
#
|
52
|
+
# @example
|
53
|
+
# vte.vte_version
|
54
|
+
# # => "5100"
|
55
|
+
#
|
56
|
+
# @return [String, nil]
|
57
|
+
#
|
58
|
+
# @api private
|
59
|
+
def vte_version
|
60
|
+
env[VTE_VERSION]
|
61
|
+
end
|
62
|
+
end # Vte
|
63
|
+
end # Terminals
|
64
|
+
end # Link
|
65
|
+
end # TTY
|