diakonos 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -4,6 +4,21 @@ Diakonos Changelog
4
4
  0.8.5
5
5
 
6
6
  - Added 256 colour support.
7
+ - Added support for opening files with "filepath:linenumber" syntax.
8
+ - Added ability to put %_ in a code closer as the place to position the cursor.
9
+ - Code closers can now contain newlines.
10
+ - Now closer text is parsed-indented by default.
11
+ - Added copy_selection_to_klipper.
12
+ - Added cut_selection_to_klipper.
13
+ - Added paste_from_klipper.
14
+ - Added delete_and_store_line_to_klipper.
15
+ - Added delete_to_EOL_to_klipper.
16
+ - Added delete_line_to_klipper.
17
+ - Added support for regexp match placeholders (\1, \2, etc.) in findAndReplace.
18
+ - Added $k shell command variable for klipper contents.
19
+ - Added eol_behaviour setting.
20
+ - Various minor bug fixes.
21
+ - Changed to MIT licence.
7
22
 
8
23
  0.8.4
9
24
 
data/LICENCE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT Licence
2
+
3
+ Copyright (c) 2004-2008 Pistos
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
File without changes
@@ -0,0 +1,93 @@
1
+ colour 32 253 39 # selection; light grey on light blue
2
+ colour 33 255 69 # comments; white on blue
3
+ colour 34 45 black # Ruby symbols; light blue on black
4
+ colour 35 123 black # Ruby instance variables; light blue on black
5
+ colour 36 177 54 # regular expressions; purple on dark purple
6
+ colour 37 111 17 # single-quoted strings; light blue on dark blue
7
+ colour 38 117 18 # double-quoted strings; light blue on dark blue
8
+ colour 39 213 90 # shell-quoted strings; light purple on purple
9
+ colour 40 15 234 # constants; white on light black
10
+
11
+ colour 41 15 233 # XML nodes; white on light black
12
+ colour 42 45 233 # XML attributes; light blue on black
13
+ colour 43 123 233 # XML namespaces; light blue on black
14
+
15
+ # Ruby
16
+
17
+ lang.ruby.format.default white bold
18
+ lang.ruby.format.selection 32
19
+ lang.ruby.format.found yellow inverse
20
+ lang.ruby.tokens.reserved_words.format white
21
+ lang.ruby.tokens.constants.format 40
22
+ lang.ruby.tokens.non_alphanum.format white
23
+ lang.ruby.tokens.symbols.format 34
24
+ lang.ruby.tokens.instance_variables.format 35
25
+ lang.ruby.tokens.comments.format 33
26
+ lang.ruby.tokens.regular_expressions.format 36
27
+ lang.ruby.tokens.regular_expressions2.format 36
28
+ lang.ruby.tokens.singlequoted_strings.format 37
29
+ lang.ruby.tokens.doublequoted_strings.format 38
30
+ lang.ruby.tokens.interpolated_string.format 38
31
+ lang.interpolated_ruby.format.default 38
32
+ lang.interpolated_ruby.tokens.interpolation.format 12 bold
33
+ lang.ruby.tokens.backquoted_strings.format 39
34
+ lang.ruby.tokens.interpolated_exec_string.format 39
35
+ lang.interpolated_exec_ruby.format.default 39
36
+ lang.interpolated_exec_ruby.tokens.interpolation.format 9 bold
37
+ lang.ruby.tokens.character_codes.format magenta bold
38
+ lang.ruby.tokens.long_comments.format 8 bold
39
+ lang.ruby.tokens.sql_string.format 1
40
+
41
+ # Perl
42
+
43
+ lang.perl.format.default white bold
44
+ lang.perl.format.selection 32
45
+ lang.perl.format.found yellow inverse
46
+ lang.perl.tokens.comments.format 33
47
+ lang.perl.tokens.constants.format 40
48
+ lang.perl.tokens.non_alphanum.format white
49
+ lang.perl.tokens.regular_expressions.format 36
50
+ lang.perl.tokens.singlequoted_strings.format 37
51
+ lang.perl.tokens.doublequoted_strings.format 38
52
+ lang.perl.tokens.backquoted_strings.format 39
53
+ lang.perl.tokens.reserved_words.format white
54
+ lang.perl.tokens.builtins.format cyan bold
55
+ lang.perl.tokens.array_variables.format red bold
56
+ lang.perl.tokens.hash_variables.format magenta bold
57
+
58
+ # Java
59
+
60
+ lang.java.format.default white bold
61
+ lang.java.format.selection 32
62
+ lang.java.format.found yellow inverse
63
+ lang.java.tokens.singlequoted_strings.format 37
64
+ lang.java.tokens.doublequoted_strings.format 38
65
+ lang.java.tokens.reserved_words.format white
66
+ lang.java.tokens.constants.format 40
67
+ lang.java.tokens.comments.format 33
68
+ lang.java.tokens.long_comments.format 33
69
+ lang.java.tokens.non_alphanum.format white
70
+ lang.java.tokens.regular_expressions.format 36
71
+
72
+ # XML
73
+
74
+ lang.xml.format.default white
75
+ lang.xml.format.selection 32
76
+ lang.xml.format.found yellow inverse
77
+ lang.xml.tokens.entities.format magenta bold
78
+ lang.xml.tokens.code.format white bold
79
+ lang.xml.tokens.comments.format 33
80
+ lang.xml.tokens.template.format brown
81
+ lang.xml_tag.format.default 41
82
+ lang.xml_tag.format.selection 32
83
+ lang.xml_tag.format.found yellow inverse
84
+ lang.xml_tag.tokens.doublequoted_strings.format 38
85
+ lang.xml_tag.tokens.singlequoted_strings.format 38
86
+ lang.xml_tag.tokens.non_alphanum.format white
87
+ lang.xml_tag.tokens.namespaces.format 43
88
+ lang.xml_comment.format.default 33
89
+ lang.xml_comment.format.selection 32
90
+ lang.xml_comment.format.found yellow inverse
91
+ lang.xml_tag.tokens.attributes ([a-zA-Z_-]+?)=
92
+ lang.xml_tag.tokens.attributes.format 42
93
+
@@ -27,6 +27,17 @@ view.wrap.visual true
27
27
  # bol_behavior is a synonym for bol_behaviour.
28
28
  bol_behaviour alternating-first-char
29
29
 
30
+ # eol_behaviour: This specifies where the cursor should go when the
31
+ # end-of-line key (the default is the End key) is pressed.
32
+ # end: Always move to the right-most column of the line
33
+ # last-char: Always move to the right-most non-whitespace character
34
+ # alternating-end: As with 'end', unless the cursor is
35
+ # already there, in which case, as with 'last-char'.
36
+ # alternating-last-char: As with 'last-char', unless the cursor is
37
+ # already there, in which case, as with 'end'.
38
+ # eol_behavior is a synonym for eol_behaviour.
39
+ eol_behaviour alternating-end
40
+
30
41
  # Ensures saved files end with a newline character by adding it if necessary.
31
42
  eof_newline false
32
43
 
@@ -111,6 +122,7 @@ interaction.choice_delay 3
111
122
  # $F all current buffer filepaths, space-separated
112
123
  # $i get a string from user input
113
124
  # $c temp file containing current clipboard text
125
+ # $k temp file containing current klipper (KDE clipboard) text
114
126
  # $s temp file containing currently selected text
115
127
 
116
128
  key left;cursorLeft
@@ -149,10 +161,12 @@ key esc up;scrollUp
149
161
  key esc [ 1 ; 3 A scrollUp
150
162
  key esc [ 1 ; 5 A scrollUp
151
163
  key keycode520 scrollUp
164
+ key keycode521 scrollUp
152
165
  key esc down;scrollDown
153
166
  key esc [ 1 ; 3 B scrollDown
154
167
  key esc [ 1 ; 5 B scrollDown
155
168
  key keycode513 scrollDown
169
+ key keycode514 scrollDown
156
170
  key esc right;seek /(?:^|\W)(\w)|\w(\W|$)/
157
171
  key esc [ 1 ; 3 C seek /\w(\W|$)|(?:^|\W)(\w)/
158
172
  key esc [ 1 ; 5 C seek /\w(\W|$)|(?:^|\W)(\w)/
@@ -250,6 +264,15 @@ key ctrl+space;anchorSelection
250
264
  key ctrl+c;copySelection
251
265
  key ctrl+x;cutSelection
252
266
  key alt+u;removeSelection
267
+
268
+ # If you are using KDE, you can uncomment these lines to synchronize
269
+ # the Diakonos clipboard with the KDE clipboard
270
+ #key ctrl+c copy_selection_to_klipper
271
+ #key ctrl+x cut_selection_to_klipper
272
+ #key ctrl+v paste_from_klipper
273
+ #key ctrl+k delete_and_store_line_to_klipper
274
+ #key ctrl+alt+k delete_to_eol_to_klipper
275
+
253
276
  key ctrl+b select_block
254
277
  # Select file diff in a patch
255
278
  key ctrl+alt+d f select_block /^Index: /, /^(Index: |$)/, false
@@ -544,7 +567,7 @@ lang.ruby.tokens.reserved_words \b(__FILE__|and|def|end|in|or|self|unless|__LINE
544
567
  lang.ruby.tokens.reserved_words.format white
545
568
  lang.ruby.tokens.constants \b([A-Z_]+|[A-Z_][A-Z0-9_]+)\b
546
569
  lang.ruby.tokens.constants.format yellow bold
547
- lang.ruby.tokens.symbols (:[a-z_][a-z_0-9]*)
570
+ lang.ruby.tokens.symbols [^:](:[a-zA-Z_][a-zA-Z_0-9]*)
548
571
  lang.ruby.tokens.symbols.format white bold
549
572
  lang.ruby.tokens.non_alphanum [@!#$%^&*()\[\]{}/?=+\-\\|,<.>;~]
550
573
  lang.ruby.tokens.non_alphanum.format white
@@ -746,6 +769,8 @@ lang.java.indent.unindenters (\})
746
769
  lang.java.indent.preventers (\".+?[^\\]\")|('.+?[^\\]')|(\/\/.*)
747
770
  lang.java.indent.ignore ^(.+:|\s*?)$
748
771
  lang.java.context.ignore ^(.+:|\s*\{?)$
772
+ lang.java.closers.for.regexp for$
773
+ lang.java.closers.for.closer { |m| "( $i = 0; $i < limit; $i++ ) {\n%_\n}" }
749
774
 
750
775
  # C
751
776
 
@@ -907,7 +932,7 @@ lang.tcl.indent.indenters (\{)
907
932
  lang.tcl.indent.unindenters (\})
908
933
  lang.tcl.indent.preventers (\".+?[^\\]\")|('.+?[^\\]')|(\/\/.*)
909
934
 
910
- lang.diff.filemask (?:\.(?:diff|patch))$
935
+ lang.diff.filemask (?:\.(?:diff|patch)|COMMIT_EDITMSG)$
911
936
  lang.diff.format.default white
912
937
  lang.diff.format.selection inverse
913
938
  lang.diff.format.found yellow inverse
@@ -7,20 +7,12 @@
7
7
  #
8
8
  # Author:: Pistos (irc.freenode.net)
9
9
  # http://purepistos.net/diakonos
10
+ # Copyright (c) 2004-2008 Pistos
10
11
  #
11
- # This software is released under the GNU General Public License.
12
- # http://www.gnu.org/copyleft/gpl.html
12
+ # This software is released under the MIT licence.
13
+ # See the LICENCE file included with this program, or
14
+ # http://www.opensource.org/licenses/mit-license.php
13
15
  #
14
- # This program is free software; you can redistribute it and/or
15
- # modify it under the terms of the GNU General Public License
16
- # as published by the Free Software Foundation; either version 2
17
- # of the License, or (at your option) any later version.
18
-
19
- # This program is distributed in the hope that it will be useful,
20
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
- # GNU General Public License for more details.
23
-
24
16
  require 'curses'
25
17
  require 'open3'
26
18
  require 'thread'
@@ -55,8 +47,8 @@ require 'diakonos/readline'
55
47
 
56
48
  module Diakonos
57
49
 
58
- VERSION = '0.8.4'
59
- LAST_MODIFIED = 'May 23, 2008'
50
+ VERSION = '0.8.5'
51
+ LAST_MODIFIED = 'August 27, 2008'
60
52
 
61
53
  DONT_ADJUST_ROW = false
62
54
  ADJUST_ROW = true
@@ -101,6 +93,11 @@ module Diakonos
101
93
  BOL_ALT_ZERO = 2
102
94
  BOL_ALT_FIRST_CHAR = 3
103
95
 
96
+ EOL_END = 0
97
+ EOL_LAST_CHAR = 1
98
+ EOL_ALT_END = 2
99
+ EOL_ALT_LAST_CHAR = 3
100
+
104
101
  FORCE_REVERT = true
105
102
  ASK_REVERT = false
106
103
 
@@ -117,25 +114,30 @@ module Diakonos
117
114
  'changeSessionSetting',
118
115
  'clearMatches',
119
116
  'closeFile',
120
- 'collapseWhitespace',
121
117
  'close_code',
118
+ 'collapseWhitespace',
122
119
  'copySelection',
120
+ 'copy_selection_to_klipper',
123
121
  'cursorBOF',
124
122
  'cursorBOL',
123
+ 'cursorBOV',
125
124
  'cursorDown',
126
125
  'cursorEOF',
127
126
  'cursorEOL',
128
- 'cursorBOV',
129
- 'cursorTOV',
130
127
  'cursorLeft',
131
128
  'cursorReturn',
132
129
  'cursorRight',
130
+ 'cursorTOV',
133
131
  'cursorUp',
134
132
  'cutSelection',
133
+ 'cut_selection_to_klipper',
135
134
  'delete',
136
135
  'deleteAndStoreLine',
137
136
  'deleteLine',
138
137
  'deleteToEOL',
138
+ 'delete_and_store_line_to_klipper',
139
+ 'delete_line_to_klipper',
140
+ 'delete_to_EOL_to_klipper',
139
141
  'evaluate',
140
142
  'execute',
141
143
  'find',
@@ -167,6 +169,7 @@ module Diakonos
167
169
  'parsedIndent',
168
170
  'paste',
169
171
  'pasteShellResult',
172
+ 'paste_from_klipper',
170
173
  'playMacro',
171
174
  'popTag',
172
175
  'printKeychain',
@@ -178,11 +181,11 @@ module Diakonos
178
181
  'revert',
179
182
  'saveFile',
180
183
  'saveFileAs',
181
- 'select_block',
182
184
  'scrollDown',
183
185
  'scrollUp',
184
186
  'searchAndReplace',
185
187
  'seek',
188
+ 'select_block',
186
189
  'setBufferType',
187
190
  'setReadOnly',
188
191
  'shell',
@@ -599,7 +602,7 @@ class Diakonos
599
602
  end
600
603
  end
601
604
  when "context.visible", "context.combined", "eof_newline", "view.nonfilelines.visible",
602
- /^lang\.(.+?)\.indent\.(?:auto|roundup|using_tabs)$/,
605
+ /^lang\.(.+?)\.indent\.(?:auto|roundup|using_tabs|closers)$/,
603
606
  "found_cursor_start", "convert_tabs", 'delete_newline_on_delete_to_eol'
604
607
  @settings[ command ] = arg.to_b
605
608
  when "context.format", "context.separator.format", "status.format"
@@ -636,6 +639,17 @@ class Diakonos
636
639
  else # default
637
640
  @settings[ "bol_behaviour" ] = BOL_ALT_FIRST_CHAR
638
641
  end
642
+ when "eol_behaviour", "eol_behavior"
643
+ case arg.downcase
644
+ when "end"
645
+ @settings[ "eol_behaviour" ] = EOL_END
646
+ when "last-char"
647
+ @settings[ "eol_behaviour" ] = EOL_LAST_CHAR
648
+ when "alternating-last-char"
649
+ @settings[ "eol_behaviour" ] = EOL_ALT_FIRST_CHAR
650
+ else # default
651
+ @settings[ "eol_behaviour" ] = EOL_ALT_END
652
+ end
639
653
  when "context.delay", 'interaction.blink_duration', 'interaction.choice_delay'
640
654
  @settings[ command ] = arg.to_f
641
655
  end
@@ -870,9 +884,11 @@ class Diakonos
870
884
 
871
885
  def switchTo( buffer )
872
886
  switched = false
873
- if buffer != nil
887
+ if buffer
874
888
  @buffer_stack -= [ @current_buffer ]
875
- @buffer_stack.push @current_buffer if @current_buffer != nil
889
+ if @current_buffer
890
+ @buffer_stack.push @current_buffer
891
+ end
876
892
  @current_buffer = buffer
877
893
  updateStatusLine
878
894
  updateContextLine
@@ -880,7 +896,7 @@ class Diakonos
880
896
  switched = true
881
897
  end
882
898
 
883
- return switched
899
+ switched
884
900
  end
885
901
  protected :switchTo
886
902
 
@@ -1126,7 +1142,7 @@ class Diakonos
1126
1142
  end
1127
1143
  number += 1
1128
1144
  end
1129
- return buffer_number
1145
+ buffer_number
1130
1146
  end
1131
1147
 
1132
1148
  def subShellVariables( string )
@@ -1162,6 +1178,15 @@ class Diakonos
1162
1178
  retval.gsub!( /\$c/, clip_filename )
1163
1179
  end
1164
1180
 
1181
+ # Current klipper (KDE clipboard) text
1182
+ if retval =~ /\$k/
1183
+ clip_filename = @diakonos_home + "/clip.txt"
1184
+ File.open( clip_filename, "w" ) do |clipfile|
1185
+ clipfile.puts( `dcop klipper klipper getClipboardContents` )
1186
+ end
1187
+ retval.gsub!( /\$k/, clip_filename )
1188
+ end
1189
+
1165
1190
  # Currently selected text
1166
1191
  if retval =~ /\$s/
1167
1192
  text_filename = @diakonos_home + "/selected.txt"
@@ -1550,6 +1575,31 @@ class Diakonos
1550
1575
  removeSelection
1551
1576
  end
1552
1577
 
1578
+ def copy_selection_to_klipper
1579
+ if send_to_klipper( @current_buffer.selected_text )
1580
+ removeSelection
1581
+ end
1582
+ end
1583
+
1584
+ def write_to_clip_file( text )
1585
+ clip_filename = @diakonos_home + "/clip.txt"
1586
+ File.open( clip_filename, "w" ) do |f|
1587
+ f.print text
1588
+ end
1589
+ clip_filename
1590
+ end
1591
+
1592
+ # Returns true iff some text was copied to klipper.
1593
+ def send_to_klipper( text )
1594
+ return false if text.nil?
1595
+
1596
+ clip_filename = write_to_clip_file( text.join( "\n" ) )
1597
+ # A little shell sorcery to ensure the shell doesn't strip off trailing newlines.
1598
+ # Thank you to pgas from irc.freenode.net#bash for help with this.
1599
+ `clipping=$(cat #{clip_filename};printf "_"); dcop klipper klipper setClipboardContents "${clipping%_}"`
1600
+ true
1601
+ end
1602
+
1553
1603
  # Returns true iff the cursor changed positions
1554
1604
  def cursorDown
1555
1605
  return @current_buffer.cursorTo( @current_buffer.last_row + 1, @current_buffer.last_col, Buffer::DO_DISPLAY, Buffer::STOPPED_TYPING, DONT_ADJUST_ROW )
@@ -1578,8 +1628,7 @@ class Diakonos
1578
1628
  end
1579
1629
 
1580
1630
  def cursorEOL
1581
- y = @win_main.cury
1582
- @current_buffer.cursorTo( @current_buffer.last_row, @current_buffer.lineAt( y ).length, Buffer::DO_DISPLAY )
1631
+ @current_buffer.cursorToEOL
1583
1632
  end
1584
1633
 
1585
1634
  def cursorEOF
@@ -1604,27 +1653,60 @@ class Diakonos
1604
1653
  def cutSelection
1605
1654
  delete if @clipboard.addClip( @current_buffer.copySelection )
1606
1655
  end
1656
+
1657
+ def cut_selection_to_klipper
1658
+ if send_to_klipper( @current_buffer.selected_text )
1659
+ delete
1660
+ end
1661
+ end
1607
1662
 
1608
1663
  def delete
1609
1664
  @current_buffer.delete
1610
1665
  end
1611
1666
 
1667
+ def delete_and_store_line_to_klipper
1668
+ removed_text = @current_buffer.deleteLine
1669
+ if removed_text
1670
+ if @last_commands[ -1 ] =~ /^delete_and_store_line_to_klipper/
1671
+ clip_filename = write_to_clip_file( removed_text << "\n" )
1672
+ `clipping="$(dcop klipper klipper getClipboardContents)\n$(cat #{clip_filename};printf "_")"; dcop klipper klipper setClipboardContents "${clipping%_}"`
1673
+ else
1674
+ send_to_klipper [ removed_text, "" ]
1675
+ end
1676
+ end
1677
+ end
1678
+
1612
1679
  def deleteAndStoreLine
1680
+ removed_text = @current_buffer.deleteLine
1681
+ if removed_text
1682
+ clip = [ removed_text, "" ]
1683
+ if @last_commands[ -1 ] =~ /^deleteAndStoreLine/
1684
+ @clipboard.appendToClip clip
1685
+ else
1686
+ @clipboard.addClip clip
1687
+ end
1688
+ end
1689
+ end
1690
+
1691
+ def delete_line_to_klipper
1613
1692
  removed_text = @current_buffer.deleteLine
1614
1693
  if removed_text
1615
- if @last_commands[ -1 ] =~ /^deleteAndStoreLine/
1616
- @clipboard.appendToClip( [ removed_text, "" ] )
1617
- else
1618
- @clipboard.addClip( [ removed_text, "" ] )
1619
- end
1694
+ send_to_klipper [ removed_text, "" ]
1620
1695
  end
1621
1696
  end
1622
-
1697
+
1623
1698
  def deleteLine
1624
1699
  removed_text = @current_buffer.deleteLine
1625
1700
  @clipboard.addClip( [ removed_text, "" ] ) if removed_text
1626
1701
  end
1627
1702
 
1703
+ def delete_to_EOL_to_klipper
1704
+ removed_text = @current_buffer.deleteToEOL
1705
+ if removed_text
1706
+ send_to_klipper removed_text
1707
+ end
1708
+ end
1709
+
1628
1710
  def deleteToEOL
1629
1711
  removed_text = @current_buffer.deleteToEOL
1630
1712
  @clipboard.addClip( removed_text ) if removed_text
@@ -1942,65 +2024,76 @@ class Diakonos
1942
2024
 
1943
2025
  # Returns the buffer of the opened file, or nil.
1944
2026
  def openFile( filename = nil, read_only = false, force_revert = ASK_REVERT )
1945
- do_open = true
1946
- buffer = nil
1947
- if filename != nil
1948
- buffer_key = filename
1949
- if(
1950
- (not force_revert) and
1951
- ( (existing_buffer = @buffers[ filename ]) != nil ) and
1952
- ( filename !~ /\.diakonos/ )
2027
+ do_open = true
2028
+ buffer = nil
2029
+ if filename.nil?
2030
+ buffer_key = @untitled_id
2031
+ @untitled_id += 1
2032
+ else
2033
+ if filename =~ /^(.+):(\d+)$/
2034
+ filename, line_number = $1, ( $2.to_i - 1 )
2035
+ end
2036
+ buffer_key = filename
2037
+ if(
2038
+ (not force_revert) and
2039
+ ( (existing_buffer = @buffers[ filename ]) != nil ) and
2040
+ ( filename !~ /\.diakonos/ )
2041
+ )
2042
+ switchTo( existing_buffer )
2043
+ choice = getChoice(
2044
+ "Revert to on-disk version of #{existing_buffer.nice_name}?",
2045
+ [ CHOICE_YES, CHOICE_NO ]
2046
+ )
2047
+ case choice
2048
+ when CHOICE_NO
2049
+ do_open = false
2050
+ end
2051
+ end
2052
+
2053
+ if FileTest.exist?( filename )
2054
+ # Don't try to open non-files (i.e. directories, pipes, sockets, etc.)
2055
+ do_open &&= FileTest.file?( filename )
2056
+ end
2057
+ end
2058
+
2059
+ if do_open
2060
+ # Is file readable?
2061
+
2062
+ # Does the "file" utility exist?
2063
+ if(
2064
+ filename and
2065
+ @settings[ 'use_magic_file' ] and
2066
+ FileTest.exist?( "/usr/bin/file" ) and
2067
+ FileTest.exist?( filename ) and
2068
+ /\blisting\.txt\b/ !~ filename
2069
+ )
2070
+ file_type = `/usr/bin/file -L #{filename}`
2071
+ if file_type !~ /text/ and file_type !~ /empty$/
2072
+ choice = getChoice(
2073
+ "#{filename} does not appear to be readable. Try to open it anyway?",
2074
+ [ CHOICE_YES, CHOICE_NO ],
2075
+ CHOICE_NO
1953
2076
  )
1954
- switchTo( existing_buffer )
1955
- choice = getChoice(
1956
- "Revert to on-disk version of #{existing_buffer.nice_name}?",
1957
- [ CHOICE_YES, CHOICE_NO ]
1958
- )
1959
- case choice
1960
- when CHOICE_NO
1961
- do_open = false
1962
- end
2077
+ case choice
2078
+ when CHOICE_NO
2079
+ do_open = false
1963
2080
  end
1964
2081
 
1965
- if FileTest.exist?( filename )
1966
- # Don't try to open non-files (i.e. directories, pipes, sockets, etc.)
1967
- do_open &&= FileTest.file?( filename )
1968
- end
1969
- else
1970
- buffer_key = @untitled_id
1971
- @untitled_id += 1
2082
+ end
1972
2083
  end
1973
2084
 
1974
2085
  if do_open
1975
- # Is file readable?
1976
-
1977
- # Does the "file" utility exist?
1978
- if @settings[ 'use_magic_file' ] and FileTest.exist?( "/usr/bin/file" ) and filename != nil and FileTest.exist?( filename ) and /\blisting\.txt\b/ !~ filename
1979
- file_type = `/usr/bin/file -L #{filename}`
1980
- if file_type !~ /text/ and file_type !~ /empty$/
1981
- choice = getChoice(
1982
- "#{filename} does not appear to be readable. Try to open it anyway?",
1983
- [ CHOICE_YES, CHOICE_NO ],
1984
- CHOICE_NO
1985
- )
1986
- case choice
1987
- when CHOICE_NO
1988
- do_open = false
1989
- end
1990
-
1991
- end
1992
- end
1993
-
1994
- if do_open
1995
- buffer = Buffer.new( self, filename, read_only )
1996
- @buffers[ buffer_key ] = buffer
1997
- switchTo( buffer )
1998
- end
2086
+ buffer = Buffer.new( self, filename, buffer_key, read_only )
2087
+ @buffers[ buffer_key ] = buffer
2088
+ if switchTo( buffer ) and line_number
2089
+ @current_buffer.goToLine( line_number, 0 )
2090
+ end
1999
2091
  end
2000
-
2001
- return buffer
2092
+ end
2093
+
2094
+ buffer
2002
2095
  end
2003
-
2096
+
2004
2097
  def openFileAsk
2005
2098
  if @current_buffer != nil and @current_buffer.name != nil
2006
2099
  path = File.expand_path( File.dirname( @current_buffer.name ) ) + "/"
@@ -2099,6 +2192,12 @@ class Diakonos
2099
2192
  def paste
2100
2193
  @current_buffer.paste @clipboard.clip
2101
2194
  end
2195
+
2196
+ def paste_from_klipper
2197
+ text = `dcop klipper klipper getClipboardContents`.split( "\n", -1 )
2198
+ text.pop # getClipboardContents puts an extra newline on end
2199
+ @current_buffer.paste text
2200
+ end
2102
2201
 
2103
2202
  def playMacro( name = nil )
2104
2203
  macro, input_history = @macros[ name ]
@@ -2396,7 +2495,7 @@ class Diakonos
2396
2495
  buffer_number = buffer_number_.to_i
2397
2496
  return if buffer_number < 1
2398
2497
  buffer_name = bufferNumberToName( buffer_number )
2399
- if buffer_name != nil
2498
+ if buffer_name
2400
2499
  switchTo( @buffers[ buffer_name ] )
2401
2500
  end
2402
2501
  end