simped 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/README.md +15 -0
- data/lib/simped.rb +150 -0
- metadata +50 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
M2ZmYzA4MTgwN2VhZWRlMzM5NTA1YjI4MDE1MWZkN2ZlYjkxNTA3YQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NzY0MTkxMzgzZTNhOTcyNzUxMGU2MTVlNjM3NTcxYTI1ZDg1ODg0OQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZDM5NTE0YzlhOTVkMDM1NDNkN2FmNTc1YWMzYzdhMWM3NTZhZWE0ZWZlODA1
|
10
|
+
NGQ2NTFmMzBhOGFmYzg5Zjg1ZmE0MDJkZGJlYjBiMDUxYWZmNjVjODc3Nzdi
|
11
|
+
MDk4YjA3ZTQxOWZmNTg1Zjc0NTY2YTJmNTJkNWZlMGU3ZjBmODE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZTI0YTMzYjcwYjVhYjExZjY4YzA5NTE2ZjliMWYwOTU1MDg5NmU2NzQ3MjIw
|
14
|
+
ZmMxNTE5YTAzMDgwZGFhMDg5MThmYWFmYmY2MzNiYzZmY2UwYjE1MzBlZmQ2
|
15
|
+
YzU3YjU5ZmFjZWNkZjJmZDhjNGYzMzAwMGY1YTMwYmMxYzM5Mjc=
|
data/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Simped is simplified text editor with black background and white text, using Tcl/Tk graphical user interface to open a new file, open an existing file, save the edited file under the same name or under a different name, close the file or exit the app.
|
2
|
+
|
3
|
+
USAGE:
|
4
|
+
======
|
5
|
+
Create a text file containing:
|
6
|
+
|
7
|
+
```
|
8
|
+
require 'simped'
|
9
|
+
Editor.run
|
10
|
+
```
|
11
|
+
|
12
|
+
save the text file as "simped.rbw" or "simped.rb" on your desktop if you are using Microsoft Windows as an Operating System.
|
13
|
+
|
14
|
+
if Ruby is in your PATH, clicking on this Ruby file will start the Widget.
|
15
|
+
|
data/lib/simped.rb
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
require 'tk'
|
2
|
+
|
3
|
+
class Editor
|
4
|
+
|
5
|
+
def self.run
|
6
|
+
puts `simped.rb`
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
10
|
+
#_________________________________ Main Window ______________________________
|
11
|
+
root = TkRoot.new{title "File Viewer"}
|
12
|
+
root['geometry'] = '1540x700+1+1'
|
13
|
+
#root['resizable'] = false, false
|
14
|
+
#____________________ BUTTONS _____________________________________________
|
15
|
+
button = TkButton.new(root){
|
16
|
+
text "OK"
|
17
|
+
#command(Proc{myproc})
|
18
|
+
}
|
19
|
+
|
20
|
+
button_click = Proc.new{system 'notepad'}
|
21
|
+
button.command = button_click
|
22
|
+
|
23
|
+
#___________________ MENU________________________________________________
|
24
|
+
############# Methods & VARIABLES ###################
|
25
|
+
TkOption.add '*tearOff', 0
|
26
|
+
$filename =TkVariable.new
|
27
|
+
$newfilename =TkVariable.new
|
28
|
+
#___________________________________
|
29
|
+
newfile = Proc.new{$text.delete(1.0, 'end')}
|
30
|
+
#________________________
|
31
|
+
openfile = Proc.new{
|
32
|
+
$filename = Tk::getOpenFile()
|
33
|
+
$content = File.read($filename)
|
34
|
+
$text.delete(1.0, 'end')
|
35
|
+
$text.insert('end', $content)
|
36
|
+
}
|
37
|
+
#___________________________________
|
38
|
+
closefile = Proc.new{$text.delete(1.0, 'end')}
|
39
|
+
#____________________________________
|
40
|
+
savefile = Proc.new{
|
41
|
+
thetext = $text.get("1.0", 'end')
|
42
|
+
File.write($filename, thetext)
|
43
|
+
}
|
44
|
+
#____________________________________
|
45
|
+
savefileas = Proc.new{
|
46
|
+
thetext = $text.get("1.0", 'end')
|
47
|
+
$newfilename = Tk::getSaveFile('filetypes' => [["All Files", "."], ["Text Files", ".txt"]])
|
48
|
+
File.write($newfilename, thetext)
|
49
|
+
}
|
50
|
+
#____________________________________
|
51
|
+
exitapp = Proc.new{exit}
|
52
|
+
help = Proc.new{help_win}
|
53
|
+
#_______ HELP MENU _____________________
|
54
|
+
def help_win
|
55
|
+
begin
|
56
|
+
$win.destroy
|
57
|
+
rescue
|
58
|
+
end
|
59
|
+
$win = TkToplevel.new{title "Help Window"}
|
60
|
+
TkLabel.new($win){
|
61
|
+
text " This is a simple text editor using Tcl/Tk widgets.
|
62
|
+
The menu allows opening an existing file on system.
|
63
|
+
It also allows creating a new file and saving it.
|
64
|
+
An opened file can be saved under the same name
|
65
|
+
or under a new different name"
|
66
|
+
borderwidth 5
|
67
|
+
font TkFont.new('times 16 bold')
|
68
|
+
background "yellow"
|
69
|
+
relief "groove"
|
70
|
+
justify "left"
|
71
|
+
}.grid('row' => 0, 'column' => 0)
|
72
|
+
TkButton.new($win) {
|
73
|
+
text "OK"
|
74
|
+
command "$win.destroy"
|
75
|
+
}.grid('row' => 1, 'column' => 0)
|
76
|
+
end
|
77
|
+
###################### Menu ###################
|
78
|
+
file_menu = TkMenu.new(root)
|
79
|
+
helpMenu = TkMenu.new(root)
|
80
|
+
#______________________________
|
81
|
+
file_menu.add('command',
|
82
|
+
'label' => "New...",
|
83
|
+
'command' => newfile,
|
84
|
+
'underline' => 0)
|
85
|
+
file_menu.add('command',
|
86
|
+
'label' => "Open...",
|
87
|
+
'command' => openfile,
|
88
|
+
'underline' => 0)
|
89
|
+
file_menu.add('command',
|
90
|
+
'label' => 'Close',
|
91
|
+
'command' => closefile,
|
92
|
+
'underline' => 0)
|
93
|
+
file_menu.add('separator')
|
94
|
+
file_menu.add('command',
|
95
|
+
'label' => "Save",
|
96
|
+
'command' => savefile,
|
97
|
+
'underline' => 0)
|
98
|
+
file_menu.add('command',
|
99
|
+
'label' => "Save As...",
|
100
|
+
'command' => savefileas,
|
101
|
+
'underline' => 5)
|
102
|
+
file_menu.add('separator')
|
103
|
+
file_menu.add('command',
|
104
|
+
'label' => "Exit",
|
105
|
+
'command' => exitapp,
|
106
|
+
'underline' => 3)
|
107
|
+
helpMenu.add('command',
|
108
|
+
'label' => "Help",
|
109
|
+
'command' => help,
|
110
|
+
'underline' => 3)
|
111
|
+
#_________________________________________
|
112
|
+
menu_bar = TkMenu.new
|
113
|
+
menu_bar.add('cascade',
|
114
|
+
'menu' => file_menu,
|
115
|
+
'label' => "File")
|
116
|
+
menu_bar.add('cascade',
|
117
|
+
'menu' => helpMenu,
|
118
|
+
'label' => "Help")
|
119
|
+
|
120
|
+
root.menu(menu_bar)
|
121
|
+
#____________________________ TEXT ______________________________________
|
122
|
+
$text = TkText.new(root) do
|
123
|
+
width 100
|
124
|
+
height 24
|
125
|
+
background "black"
|
126
|
+
foreground "white"
|
127
|
+
font TkFont.new('tahoma 16 normal')
|
128
|
+
wrap 'word'
|
129
|
+
insertbackground "yellow"
|
130
|
+
insertwidth 30
|
131
|
+
cursor "hand2"
|
132
|
+
end
|
133
|
+
|
134
|
+
$text.focus
|
135
|
+
#________________ SCROLLBAR ____________________________________________
|
136
|
+
scrollbar = TkScrollbar.new(root){command proc{|*args| $text.yview(*args)}
|
137
|
+
}
|
138
|
+
$text.yscrollcommand(proc{|first, last| scrollbar.set(first, last)})
|
139
|
+
#________________ GEOMETRY _____________________________________________
|
140
|
+
$text.grid('row' => 0, 'column' => 0)
|
141
|
+
button.grid('row' =>0, 'column' => 0)
|
142
|
+
scrollbar.grid('row' => 0, 'column' => 1, 'sticky' => 'NS')
|
143
|
+
TkGrid.columnconfigure( root, 0, :weight => 1 )
|
144
|
+
TkGrid.rowconfigure( root, 0, :weight => 1 )
|
145
|
+
TkGrid.columnconfigure( $text, 0, :weight => 0 )
|
146
|
+
TkGrid.rowconfigure( $text, 0, :weight => 0)
|
147
|
+
|
148
|
+
###################### Show ####################################
|
149
|
+
Tk.mainloop
|
150
|
+
##########################################################
|
metadata
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: simped
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sabry Fattah
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-14 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A simple text editor with white text on black background
|
14
|
+
email: sabryabdelfattah@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files:
|
18
|
+
- README.md
|
19
|
+
files:
|
20
|
+
- README.md
|
21
|
+
- lib/simped.rb
|
22
|
+
homepage: http://sabryfattah.com
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options:
|
28
|
+
- --main
|
29
|
+
- README.md
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ! '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ! '>'
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 2.4.5
|
45
|
+
signing_key:
|
46
|
+
specification_version: 3
|
47
|
+
summary: Simped is a simple GUI text editor with black background and white text.
|
48
|
+
The menu includes just open, cloaem save, save as and exit commands. The help menu
|
49
|
+
explain use of the editor. The GUI is based on Tc/Tk commands
|
50
|
+
test_files: []
|