naksh 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +1 -0
- data/COPYING +674 -0
- data/COPYING-DOCS +15 -0
- data/README.md +45 -0
- data/Rakefile +129 -0
- data/TODO +19 -0
- data/bin/naksh +2 -0
- data/data/default.mo +0 -0
- data/data/default.po +16 -0
- data/data/default2.mo +0 -0
- data/data/default2.po +27 -0
- data/data/starter.pot +29 -0
- data/docs/bash_flow.dia +0 -0
- data/docs/gtk_manual.txt +13 -0
- data/docs/master_plan.dia +0 -0
- data/docs/master_plan.png +0 -0
- data/docs/master_plan.svg +74 -0
- data/docs/master_plan.svgz +0 -0
- data/docs/userguide/en/about.xml +42 -0
- data/docs/userguide/en/gnu-fdl-1.2.xml +543 -0
- data/docs/userguide/en/naksh.xml +881 -0
- data/docs/userguide/en/naksh_start_window.png +0 -0
- data/docs/userguide/en/old_naksh.xml +180 -0
- data/docs/userguide/en/userguide-en.omf +37 -0
- data/lib/naksh.rb +165 -0
- data/lib/naksh/buffer.rb +153 -0
- data/lib/naksh/command_handling.rb +117 -0
- data/lib/naksh/commands/bash/README +2 -0
- data/lib/naksh/commands/bash/echo.nkc.rb +50 -0
- data/lib/naksh/commands/bsd.rb +25 -0
- data/lib/naksh/commands/dos.rb +25 -0
- data/lib/naksh/commands/fuse.rb +25 -0
- data/lib/naksh/commands/gnu.rb +30 -0
- data/lib/naksh/commands/gnu/README +2 -0
- data/lib/naksh/commands/gnu/cat.nkc.rb +50 -0
- data/lib/naksh/commands/gnu/cd.nkc.rb +11 -0
- data/lib/naksh/commands/gnu/echo.documentation.json +57 -0
- data/lib/naksh/commands/gnu/echo.documentation.rb +60 -0
- data/lib/naksh/commands/gnu/echo.nkc.rb +52 -0
- data/lib/naksh/commands/gnu/ls.nkc.rb +11 -0
- data/lib/naksh/commands/gnu/mv.nkc.rb +15 -0
- data/lib/naksh/commands/gnu/pwd.nkc.rb +11 -0
- data/lib/naksh/commands/naksh/addpath.nkc.rb +15 -0
- data/lib/naksh/commands/naksh/broken.nkc.rb +10 -0
- data/lib/naksh/commands/naksh/empty.nkc.rb +4 -0
- data/lib/naksh/commands/naksh/exit.nkc.rb +10 -0
- data/lib/naksh/commands/naksh/help.nkc.rb +21 -0
- data/lib/naksh/commands/naksh/man.nkc.rb +8 -0
- data/lib/naksh/commands/ruby.rb +31 -0
- data/lib/naksh/commands/unix.rb +131 -0
- data/lib/naksh/configuration/gconf.rb +51 -0
- data/lib/naksh/configuration/hash.rb +38 -0
- data/lib/naksh/defaults.rb +40 -0
- data/lib/naksh/history.rb +85 -0
- data/lib/naksh/interfaces.rb +59 -0
- data/lib/naksh/interfaces/fox.rb +49 -0
- data/lib/naksh/interfaces/gtk.rb +103 -0
- data/lib/naksh/interfaces/gtk/abtwin.rb +53 -0
- data/lib/naksh/interfaces/gtk/gnomeapp.rb +31 -0
- data/lib/naksh/interfaces/gtk/helpwin.rb +70 -0
- data/lib/naksh/interfaces/gtk/io.rb +94 -0
- data/lib/naksh/interfaces/gtk/mainwin.rb +56 -0
- data/lib/naksh/interfaces/gtk/mainwin/console.rb +121 -0
- data/lib/naksh/interfaces/gtk/mainwin/main_menu.rb +143 -0
- data/lib/naksh/interfaces/gtk/optwin.rb +78 -0
- data/lib/naksh/interfaces/tab.rb +58 -0
- data/lib/naksh/interfaces/wxw.rb +75 -0
- data/lib/naksh/interfaces/wxw/abtwin.rb +38 -0
- data/lib/naksh/interfaces/wxw/helpwin.rb +40 -0
- data/lib/naksh/interfaces/wxw/io.rb +61 -0
- data/lib/naksh/interfaces/wxw/mainwin.rb +42 -0
- data/lib/naksh/interfaces/wxw/mainwin/main_menu.rb +126 -0
- data/lib/naksh/interfaces/wxw/mainwin/sessions.rb +49 -0
- data/lib/naksh/interfaces/wxw/optwin.rb +37 -0
- data/lib/naksh/path_entry.rb +101 -0
- data/lib/naksh/regexp.rb +31 -0
- data/lib/naksh/session.rb +72 -0
- data/lib/naksh/stdlibext.rb +48 -0
- data/lib/naksh/syntax.rb +57 -0
- data/lib/naksh/syntax/bash.rb +219 -0
- data/lib/naksh/syntax/bash/antlr/bottomup.g +24 -0
- data/lib/naksh/syntax/bash/antlr/topdown.g +52 -0
- data/lib/naksh/syntax/bash/dhaka/evaluator.rb +353 -0
- data/lib/naksh/syntax/bash/dhaka/grammar.rb +71 -0
- data/lib/naksh/syntax/bash/dhaka/lexer.rb +52 -0
- data/lib/naksh/syntax/bash/treetop/bash.treetop +17 -0
- data/lib/old/abbr_call.rb +39 -0
- data/lib/old/autocomplete.rb +29 -0
- data/lib/old/command.rb +106 -0
- data/lib/old/command_holder.rb +75 -0
- data/lib/old/commands.rb +24 -0
- data/lib/old/old_executor.rb +95 -0
- data/lib/old/options.rb +31 -0
- data/lib/old/rush.rb +113 -0
- data/lib/old/sortissimo.rb +205 -0
- data/lib/old/systems.rb +25 -0
- data/lib/old/systems/ruby.rb +26 -0
- data/lib/old/un.rb +240 -0
- data/lib/rust/Rakefile +6 -0
- data/lib/rust/commands/builtins.rb +46 -0
- data/lib/rust/commands/builtins/cd.rb +17 -0
- data/lib/rust/commands/builtins/exit.rb +13 -0
- data/lib/rust/commands/builtins/help.rb +14 -0
- data/lib/rust/commands/builtins/parser.rb +13 -0
- data/lib/rust/commands/builtins/pwd.rb +13 -0
- data/lib/rust/commands/builtins/type.rb +13 -0
- data/lib/rust/commands/commands/ls.rb +13 -0
- data/lib/rust/commands/commands/read.rb +13 -0
- data/lib/rust/commands/commands/rm.rb +14 -0
- data/lib/rust/commands/commands/test.rb +20 -0
- data/lib/rust/helpers/array.rb +10 -0
- data/lib/rust/helpers/command_center.rb +78 -0
- data/lib/rust/helpers/constants.rb +58 -0
- data/lib/rust/helpers/io.rb +132 -0
- data/lib/rust/helpers/parser.rb +45 -0
- data/lib/rust/helpers/rush_control.rb +40 -0
- data/lib/rust/helpers/string.rb +50 -0
- data/lib/rust/helpers/trollop.rb +475 -0
- data/lib/rust/parsers/bash.rb +220 -0
- data/lib/rust/parsers/bash/stdlibext.rb +32 -0
- data/lib/rust/parsers/ren.rb +57 -0
- data/lib/rust/rust.rb +75 -0
- data/lib/rust/syntax/command.rb +23 -0
- data/lib/rust/syntax/paths.rb +31 -0
- data/lib/rust/syntax/pipes.rb +148 -0
- data/naksh.gemspec +55 -0
- data/test/naksh/arg_parser.rspec.rb +27 -0
- data/test/naksh/commands/bash/echo.rspec.rb +32 -0
- data/test/naksh/commands/sortlist +127 -0
- data/test/naksh/external_command.rspec.rb +46 -0
- data/test/naksh/send_error.rspec.rb +60 -0
- data/test/naksh/suggest.rspec.rb +38 -0
- data/test/naksh/syntax/bash.rspec.rb +69 -0
- data/test/naksh/syntax/bash/execute.rspec.rb +51 -0
- data/test/naksh/syntax/rspec.rb +63 -0
- data/test/run_rspecs.rb +20 -0
- metadata +217 -0
|
Binary file
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
2
|
+
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
|
|
3
|
+
|
|
4
|
+
<!-- SYMBOLIC ENTITIES -->
|
|
5
|
+
<!ENTITY appversion "0.2.0"> <!-- the version of the application -->
|
|
6
|
+
<!ENTITY manrevision "0.0.1"><!-- the revision number of this manual -->
|
|
7
|
+
<!ENTITY date "January 2008"><!-- the release date of this manual -->
|
|
8
|
+
<!ENTITY app "<application>Naksh</application>">
|
|
9
|
+
<!-- the name of the application -->
|
|
10
|
+
<!-- INCLUDED FILES -->
|
|
11
|
+
<!ENTITY introduction SYSTEM "introduction.xml">
|
|
12
|
+
<!ENTITY gettingstarted SYSTEM "getting-started.xml">
|
|
13
|
+
<!ENTITY settings SYSTEM "settings.xml">
|
|
14
|
+
<!ENTITY bugs SYSTEM "bugs.xml">
|
|
15
|
+
<!ENTITY about SYSTEM "about.xml">
|
|
16
|
+
<!ENTITY gnufdl SYSTEM "gnu-fdl-1.2.xml">
|
|
17
|
+
|
|
18
|
+
<!-- CHARACTER MNEMONICS -->
|
|
19
|
+
<!ENTITY copy "©"> <!-- copyright sign -->
|
|
20
|
+
]>
|
|
21
|
+
<!--
|
|
22
|
+
This is part of the Naksh Manual.
|
|
23
|
+
Copyright (C) 2011-2008 Mahmut Bulut
|
|
24
|
+
See the file alexandria.xml for copying conditions.
|
|
25
|
+
-->
|
|
26
|
+
<!--
|
|
27
|
+
Permission is granted to copy, distribute and/or modify this document
|
|
28
|
+
under the terms of the GNU Free Documentation License, Version 1.2
|
|
29
|
+
or any later version published by the Free Software Foundation;
|
|
30
|
+
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
|
31
|
+
A copy of the license is included in the section entitled "GNU
|
|
32
|
+
Free Documentation License" (see the file gnu-fdl-1.2.xml).
|
|
33
|
+
-->
|
|
34
|
+
|
|
35
|
+
<!--
|
|
36
|
+
This document is based upon a GNOME documentation template, designed
|
|
37
|
+
by the GNOME Documentation Project Team.
|
|
38
|
+
-->
|
|
39
|
+
|
|
40
|
+
<!--
|
|
41
|
+
(Do not remove this comment block.)
|
|
42
|
+
Maintained by the GNOME Documentation Project
|
|
43
|
+
http://developer.gnome.org/projects/gdp
|
|
44
|
+
Template version: 2.0 beta
|
|
45
|
+
Template last modified Apr 11, 2002
|
|
46
|
+
-->
|
|
47
|
+
|
|
48
|
+
<!-- =============Document Header ============================= -->
|
|
49
|
+
<article id="index" lang="en">
|
|
50
|
+
|
|
51
|
+
<!-- please do not change the id; for translations, change lang to -->
|
|
52
|
+
<!-- appropriate code -->
|
|
53
|
+
|
|
54
|
+
<articleinfo>
|
|
55
|
+
<title>&app; Manual</title>
|
|
56
|
+
|
|
57
|
+
<copyright>
|
|
58
|
+
<year>2011</year>
|
|
59
|
+
<holder>Cathal Mc Ginley</holder>
|
|
60
|
+
</copyright>
|
|
61
|
+
<copyright>
|
|
62
|
+
<year>2005</year>
|
|
63
|
+
<holder>Liam Davison</holder>
|
|
64
|
+
</copyright>
|
|
65
|
+
<!-- translators: uncomment this:
|
|
66
|
+
<copyright>
|
|
67
|
+
<year>2011</year>
|
|
68
|
+
<holder>TRANSLATOR_NAME (LANGUAGE translation)</holder>
|
|
69
|
+
</copyright>
|
|
70
|
+
-->
|
|
71
|
+
|
|
72
|
+
<legalnotice id="legalnotice">
|
|
73
|
+
<para>
|
|
74
|
+
Permission is granted to copy, distribute and/or modify this
|
|
75
|
+
document under the terms of the GNU Free Documentation License,
|
|
76
|
+
Version 1.2 or any later version published by the Free Software
|
|
77
|
+
Foundation; with no Invariant Sections, no Front-Cover Texts,
|
|
78
|
+
and no Back-Cover Texts. A copy of the license is included in
|
|
79
|
+
the section entitled <xref linkend="gfdl"/>.
|
|
80
|
+
</para>
|
|
81
|
+
</legalnotice>
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
<authorgroup>
|
|
85
|
+
<author>
|
|
86
|
+
<firstname>Liam</firstname>
|
|
87
|
+
<surname>Davison</surname>
|
|
88
|
+
<affiliation>
|
|
89
|
+
<orgname>&app; documentation writing</orgname>
|
|
90
|
+
<address> carnegie@liamjdavison.info<email>carnegie@liamjdavison.info</email> </address>
|
|
91
|
+
</affiliation>
|
|
92
|
+
</author>
|
|
93
|
+
<othercredit role="maintainer">
|
|
94
|
+
<firstname>Cathal</firstname>
|
|
95
|
+
<surname>Mc Ginley</surname>
|
|
96
|
+
<affiliation>
|
|
97
|
+
<orgname>&app; developers</orgname>
|
|
98
|
+
<address> <email>cathal.alexandria@gnostai.org</email> </address>
|
|
99
|
+
</affiliation>
|
|
100
|
+
<contrib>Maintenance</contrib>
|
|
101
|
+
</othercredit>
|
|
102
|
+
<!-- This is appropriate place for other contributors: translators,
|
|
103
|
+
maintainers, etc. Commented out by default.
|
|
104
|
+
|
|
105
|
+
<othercredit role="translator">
|
|
106
|
+
<firstname>Latin</firstname>
|
|
107
|
+
<surname>Translator 1</surname>
|
|
108
|
+
<affiliation>
|
|
109
|
+
<orgname>Latin Translation Team</orgname>
|
|
110
|
+
<address> <email>translator@gnome.org</email> </address>
|
|
111
|
+
</affiliation>
|
|
112
|
+
<contrib>Latin translation</contrib>
|
|
113
|
+
</othercredit>
|
|
114
|
+
-->
|
|
115
|
+
</authorgroup>
|
|
116
|
+
|
|
117
|
+
<!-- According to GNU FDL, revision history is mandatory if you are -->
|
|
118
|
+
<!-- modifying/reusing someone else's document. If not, you can omit it. -->
|
|
119
|
+
<!-- Remember to remove the &manrevision; entity from the revision entries -->
|
|
120
|
+
<!-- other than the current revision. -->
|
|
121
|
+
|
|
122
|
+
<revhistory>
|
|
123
|
+
<revision>
|
|
124
|
+
<revnumber>Alexandria Manual V&manrevision;</revnumber>
|
|
125
|
+
<date>&date;</date>
|
|
126
|
+
<revdescription>
|
|
127
|
+
<para role="author">Cathal Mc Ginley
|
|
128
|
+
<email>cathal.alexandria@gnostai.org</email></para>
|
|
129
|
+
<para role="publisher">Alexandria Documentation</para>
|
|
130
|
+
</revdescription>
|
|
131
|
+
</revision>
|
|
132
|
+
<revision>
|
|
133
|
+
<revnumber>Alexandria Manual V0.0.8</revnumber>
|
|
134
|
+
<date>November 2005</date>
|
|
135
|
+
<revdescription>
|
|
136
|
+
<para role="author">Liam Davison
|
|
137
|
+
<email>carnegie@liamjdavison.info</email></para>
|
|
138
|
+
<para role="publisher">Alexandria Documentation</para>
|
|
139
|
+
</revdescription>
|
|
140
|
+
</revision>
|
|
141
|
+
</revhistory>
|
|
142
|
+
|
|
143
|
+
<releaseinfo>This manual describes version &appversion; of &app;</releaseinfo>
|
|
144
|
+
|
|
145
|
+
<legalnotice id="feedback">
|
|
146
|
+
<title>Feedback</title>
|
|
147
|
+
|
|
148
|
+
<para>Alexandria is not an official part of GNOME. To report a bug
|
|
149
|
+
or make a suggestion regarding the &app; application or this
|
|
150
|
+
manual, follow the directions on the <ulink
|
|
151
|
+
url="http://alexandria.rubyforge.org/feedback.html"
|
|
152
|
+
type="http">&app; Feedback web page</ulink>.
|
|
153
|
+
</para>
|
|
154
|
+
|
|
155
|
+
</legalnotice>
|
|
156
|
+
<!-- Translators may also add here feedback address for translations -->
|
|
157
|
+
|
|
158
|
+
</articleinfo>
|
|
159
|
+
|
|
160
|
+
<indexterm zone="index">
|
|
161
|
+
<primary>Alexandria</primary>
|
|
162
|
+
</indexterm>
|
|
163
|
+
|
|
164
|
+
<!-- ============= Document Body ============================= -->
|
|
165
|
+
|
|
166
|
+
&introduction;
|
|
167
|
+
&gettingstarted;
|
|
168
|
+
&addingbooks;
|
|
169
|
+
&editingbookproperties;
|
|
170
|
+
&workingwithlibraries;
|
|
171
|
+
&searching;
|
|
172
|
+
&smartlibraries;
|
|
173
|
+
&exporting;
|
|
174
|
+
&settings;
|
|
175
|
+
&bugs;
|
|
176
|
+
&about;
|
|
177
|
+
|
|
178
|
+
&gnufdl;
|
|
179
|
+
|
|
180
|
+
</article>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE omf PUBLIC "-//OMF//DTD Scrollkeeper OMF Variant V1.0//EN" "http://scrollkeeper.sourceforge.net/dtds/scrollkeeper-omf-1.0/scrollkeeper-omf.dtd">
|
|
3
|
+
<omf><!-- why not use xml:lang? -->
|
|
4
|
+
<resource>
|
|
5
|
+
<creator>
|
|
6
|
+
scienceblock@gmail.com (Mahmut Bulut)
|
|
7
|
+
</creator>
|
|
8
|
+
<maintainer>
|
|
9
|
+
scienceblock@gmail.com (Mahmut Bulut)
|
|
10
|
+
</maintainer>
|
|
11
|
+
<contributor>
|
|
12
|
+
fedzor
|
|
13
|
+
</contributor>
|
|
14
|
+
<contributor>
|
|
15
|
+
Antonio Salazar
|
|
16
|
+
</contributor>
|
|
17
|
+
<title>
|
|
18
|
+
Naksh Manual
|
|
19
|
+
</title>
|
|
20
|
+
<date>
|
|
21
|
+
2011-21-05
|
|
22
|
+
</date>
|
|
23
|
+
<version identifier="0.2.0" date="2011-21-05" description="Initial Developer Version"/>
|
|
24
|
+
<subject category="Applications|Utilities|Terminals"/>
|
|
25
|
+
<description>
|
|
26
|
+
A general-purpose shell written in Ruby
|
|
27
|
+
</description>
|
|
28
|
+
<type>
|
|
29
|
+
user's guide
|
|
30
|
+
</type>
|
|
31
|
+
<format mime="text/xml" dtd="-//OASIS//DTD DocBook XML V4.1.2//EN"/>
|
|
32
|
+
<identifier url="file://usr/share/doc/naksh/naksh.xml"/><!-- this should be a variable set upon installation -->
|
|
33
|
+
<language code="Ruby"/><!-- maybe the language element should have content, maybe I am misusing the code attribute -->
|
|
34
|
+
<relation seriesid="1d5fa320-bd0b-11dc-946b-ea1420edaf2f"/>
|
|
35
|
+
<rights type="GNU FDL" license.version="1.1" holder="Mahmut Bulut"/>
|
|
36
|
+
</resource>
|
|
37
|
+
</omf>
|
data/lib/naksh.rb
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
#!/usr/local/bin/ruby
|
|
2
|
+
# 2011 Mahmut Bulut
|
|
3
|
+
|
|
4
|
+
# This file is part of Naksh.
|
|
5
|
+
#
|
|
6
|
+
# Naksh is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# Naksh is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with Naksh. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
require 'gettext'
|
|
21
|
+
require 'pathname'
|
|
22
|
+
|
|
23
|
+
dir=Pathname.new(__FILE__).realpath
|
|
24
|
+
Dir.chdir(File.dirname(__FILE__))
|
|
25
|
+
|
|
26
|
+
module Naksh
|
|
27
|
+
|
|
28
|
+
#anything that won't kill naksh should mixin this
|
|
29
|
+
module NonCriticalError
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
require 'naksh/configuration/hash.rb'
|
|
37
|
+
Naksh.config['/env/runmode']= ($0==__FILE__)? 'interactive' : 'lib'
|
|
38
|
+
|
|
39
|
+
if ((Pathname.new(Naksh.config['/dir'])+'lib'+'naksh.rb').to_s !=dir.to_s rescue true)
|
|
40
|
+
$stdout.puts 'Naksh configuration information is inaccurate. Loading defaults...'
|
|
41
|
+
require 'naksh/defaults.rb'
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
Naksh.config['/env/pwd']= Pathname.new((ENV["PWD"] or Dir.pwd)).realpath.to_s
|
|
45
|
+
Naksh.config['/env/user']= ENV['USER'] or ENV['USERNAME'] or ''
|
|
46
|
+
Naksh.config['/env/home']= (ENV['USERPROFILE'] or ENV["HOME"] or '')
|
|
47
|
+
Naksh.config['/env/host']= (ENV['COMPUTERNAME'] or '')
|
|
48
|
+
Naksh.config['/env/pwd']= Naksh.config['/env/home'] if Naksh.config['/env/home']
|
|
49
|
+
Naksh.config['/env/locale']= 'en'
|
|
50
|
+
Naksh.config['/meta/svn/revision']= `svn info`[/Revision: (\d+)/,1].to_i rescue -1
|
|
51
|
+
require 'naksh/buffer.rb'
|
|
52
|
+
require 'naksh/stdlibext.rb'
|
|
53
|
+
require 'naksh/path_entry.rb'
|
|
54
|
+
require 'naksh/command_handling.rb'
|
|
55
|
+
require 'naksh/history.rb'
|
|
56
|
+
require 'naksh/session.rb'
|
|
57
|
+
require 'naksh/interfaces.rb'
|
|
58
|
+
require 'naksh/syntax.rb'
|
|
59
|
+
#hack to make stuff work if you don't use gettext
|
|
60
|
+
def _(str)
|
|
61
|
+
str
|
|
62
|
+
end unless respond_to? :_
|
|
63
|
+
|
|
64
|
+
module Naksh
|
|
65
|
+
module Commands
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def Naksh.attempt_submit config_entry
|
|
70
|
+
case Naksh.config[config_entry]
|
|
71
|
+
when 'submit'
|
|
72
|
+
input=Naksh.interface.in
|
|
73
|
+
Naksh.interface.on_pre_submit
|
|
74
|
+
if Naksh.syntax.complete? input
|
|
75
|
+
begin
|
|
76
|
+
return false unless Naksh.syntax.try_execute(input)
|
|
77
|
+
rescue Naksh::NonCriticalError=>error
|
|
78
|
+
Naksh.buffer.clear
|
|
79
|
+
Naksh.interface.err.print((_('Naksh: %s')%[error.to_s])<<"\n")
|
|
80
|
+
end
|
|
81
|
+
Naksh.current_session.history.position=Naksh.current_session.history.length
|
|
82
|
+
Naksh.current_session.history<<input
|
|
83
|
+
Naksh.interface.new_prompt
|
|
84
|
+
return true
|
|
85
|
+
else
|
|
86
|
+
return false
|
|
87
|
+
end
|
|
88
|
+
when 'char'
|
|
89
|
+
return false
|
|
90
|
+
else
|
|
91
|
+
$stderr.puts _("Naksh.config[%s] has unrecognized value: %s")%[config_entry,Naksh.config[config_entry].inspect]
|
|
92
|
+
return nil
|
|
93
|
+
end
|
|
94
|
+
raise RuntimeError,_('this should never be executed')
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def Naksh.quit
|
|
99
|
+
Naksh.interface.quit
|
|
100
|
+
true
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
#this should be a spell checker
|
|
104
|
+
#Naksh.suggestions('xml-cpy-editor')#=>'xml-copy-editor'
|
|
105
|
+
#autocomplete is the next best thing
|
|
106
|
+
def Naksh.suggestions(com_str)
|
|
107
|
+
Naksh.autocomplete(com_str)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
#replaces %{var} with var.value
|
|
112
|
+
def Naksh.replace_vars(str)
|
|
113
|
+
str=str.gsub('%{pwd}',Naksh.config['/env/pwd'].sub(/\A/+Naksh.config['/env/home'],'~'))
|
|
114
|
+
str.gsub!('%{user}',Naksh.config['/env/user'])
|
|
115
|
+
str.gsub!('%{host}',Naksh.config['/env/host'])
|
|
116
|
+
str
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def Naksh.evaluate_path(str)
|
|
121
|
+
if path.match(/\A\//) and File.exist? path
|
|
122
|
+
return path
|
|
123
|
+
else
|
|
124
|
+
Naksh.interface.err.puts _('addpath: invalid filepath')
|
|
125
|
+
return false
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
require 'naksh/syntax/bash.rb'
|
|
133
|
+
Naksh.syntax=Naksh::Syntax::Bash
|
|
134
|
+
|
|
135
|
+
#the order items are added to the path is the order they will be searched
|
|
136
|
+
Naksh.path<<PathEntry.new('/home/mahmutbulut/Projects/naksh/lib/naksh/commands/naksh',:nkc_dir)
|
|
137
|
+
Naksh.path<<PathEntry.new('/home/mahmutbulut/Projects/naksh/lib/naksh/commands/gnu',:nkc_dir)
|
|
138
|
+
Naksh.path<<PathEntry.new('/home/mahmutbulut/Projects/naksh/lib/naksh/commands/bash',:nkc_dir)
|
|
139
|
+
Naksh.path<<PathEntry.new('/usr/bin',:external_dir)
|
|
140
|
+
|
|
141
|
+
if Naksh.config['/env/runmode']=='interactive'
|
|
142
|
+
|
|
143
|
+
case Naksh.config['/interface/default']
|
|
144
|
+
when 'tty'
|
|
145
|
+
require 'naksh/interfaces/tty.rb'
|
|
146
|
+
Naksh.interface=Naksh::Interfaces::Tty
|
|
147
|
+
when 'gtk'
|
|
148
|
+
require 'naksh/interfaces/gtk.rb'
|
|
149
|
+
Naksh.interface=Naksh::Interfaces::Rbgtk
|
|
150
|
+
when 'wxw'
|
|
151
|
+
require 'naksh/interfaces/wxw.rb'
|
|
152
|
+
Naksh.interface=Naksh::Interfaces::Wxw
|
|
153
|
+
when 'fox'
|
|
154
|
+
require 'naksh/interfaces/fox.rb'
|
|
155
|
+
Naksh.interface=Naksh::Interfaces::Fox
|
|
156
|
+
else
|
|
157
|
+
$stderr.puts "The configuration is requesting an unknown interface `#{Naksh.config['/interface/default']}'"
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
Naksh.buffer.err=Naksh.interface.err
|
|
161
|
+
Naksh.buffer.out=Naksh.interface.out
|
|
162
|
+
|
|
163
|
+
Naksh.interface.run(Naksh::Session.new)
|
|
164
|
+
|
|
165
|
+
end
|
data/lib/naksh/buffer.rb
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#!/usr/local/bin/ruby
|
|
2
|
+
# 2011 Mahmut Bulut
|
|
3
|
+
|
|
4
|
+
# This file is part of Naksh.
|
|
5
|
+
#
|
|
6
|
+
# Naksh is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# Naksh is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with Naksh. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
|
|
19
|
+
require 'stringio'
|
|
20
|
+
|
|
21
|
+
module Naksh
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
#for internal buffers
|
|
25
|
+
#these should be replaced with a file
|
|
26
|
+
#named BufferClass for to prevent typing errors
|
|
27
|
+
class BufferClass
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def initialize(inp=nil,out=nil,err=nil)
|
|
31
|
+
@in =inp
|
|
32
|
+
@out=out
|
|
33
|
+
@err=err
|
|
34
|
+
@new=String.new
|
|
35
|
+
@old=StringIO.new
|
|
36
|
+
@silenced=false
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
attr_accessor :in,:out,:err
|
|
40
|
+
|
|
41
|
+
def pp *a
|
|
42
|
+
a.each do |i|
|
|
43
|
+
@out.pp i.to_s
|
|
44
|
+
end
|
|
45
|
+
nil
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def print *a
|
|
49
|
+
a.each do |i|
|
|
50
|
+
@out.print i.to_s
|
|
51
|
+
end
|
|
52
|
+
nil
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def puts *a
|
|
57
|
+
a.each do |i|
|
|
58
|
+
@out.print i.to_s
|
|
59
|
+
@out.print "\n" unless i[-1]=="\n" or i[-1].chr=="\n"
|
|
60
|
+
end
|
|
61
|
+
nil
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def fake_print *a
|
|
66
|
+
@new<<a.join('')
|
|
67
|
+
nil
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def fake_puts *a
|
|
72
|
+
a.each do |i|
|
|
73
|
+
@new<<i.to_s
|
|
74
|
+
@new<<"\n" unless @new[-1]=="\n" or @new[-1].chr=="\n"
|
|
75
|
+
end
|
|
76
|
+
nil
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
alias_method :fake_pp,:fake_puts
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
alias_method :real_pp, :pp
|
|
83
|
+
alias_method :real_print,:print
|
|
84
|
+
alias_method :real_puts, :puts
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
#see Buffer#silenced?
|
|
88
|
+
def silence
|
|
89
|
+
@silenced=true
|
|
90
|
+
self.class.class_eval('undef_method :print,:puts,:pp')
|
|
91
|
+
self.class.class_eval('alias_method :pp, :fake_pp')
|
|
92
|
+
self.class.class_eval('alias_method :print,:fake_print')
|
|
93
|
+
self.class.class_eval('alias_method :puts, :fake_puts')
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# if silenced? is true, Buffer#puts and Buffer#print
|
|
97
|
+
# are storing data for later use,
|
|
98
|
+
# and not sending it to Buffer#out
|
|
99
|
+
def silenced?
|
|
100
|
+
@silenced
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
#wipe anything stored and call self.speak
|
|
105
|
+
def clear
|
|
106
|
+
@old=StringIO.new
|
|
107
|
+
@new=String.new
|
|
108
|
+
speak
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def speak
|
|
113
|
+
@silenced=false
|
|
114
|
+
self.class.class_eval('undef_method :print,:puts,:pp')
|
|
115
|
+
self.class.class_eval('alias_method :print,:real_print')
|
|
116
|
+
self.class.class_eval('alias_method :pp, :real_pp')
|
|
117
|
+
self.class.class_eval('alias_method :puts, :real_puts')
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
#this is useful if you don't want incremental output, just a single final dump
|
|
122
|
+
def flush
|
|
123
|
+
@out.print @old.read
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def gets
|
|
128
|
+
@old.gets
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
#just like gets, but throws an error at end of file
|
|
132
|
+
def readline
|
|
133
|
+
@old.readline
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# this tells the buffer you're working on a new command,
|
|
137
|
+
# and anything you printed before should be getted now
|
|
138
|
+
def next
|
|
139
|
+
@old=StringIO.new(@new)
|
|
140
|
+
@new=String.new
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
@buffer = BufferClass.new
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def Naksh.buffer
|
|
150
|
+
@buffer
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
end
|