Pierre Surply avatar Pierre Surply committed 18a84ab

Improved ls and prompt

Comments (0)

Files changed (4)

src/robot/robotsos.py

 ##    along with BASIC-RoBots.  If not, see <http://www.gnu.org/licenses/>.
 ##  
 ## Started on  Wed May  9 22:56:00 2012 Pierre Surply
-## Last update Sat Aug 11 20:51:33 2012 Pierre Surply
+## Last update Sun Aug 12 10:14:56 2012 Pierre Surply
 ##
 
 import os
     def get_path(self, path):
         return self.path + path
 
+    def get_short_path(self):
+        return self.current_dir.split("/")[-2]
+
     def set_cmds(self, cmds):
         self.cmds = []
         for i in cmds:
                         if i != "":
                             self.command(i)
                     if self.task == 0 and self.robot.energy > 0:
-                        self.terminal.start_prompt(">")
+                        self.terminal.start_prompt(self.get_short_path() + ">")
                 info = (self.mem, 10)
             elif self.task == 1:
                 if not self.basic.eval_line() or \
                              events.get_key_once(K_c)):
                     self.task = 0
                     if self.robot.energy > 0:
-                        self.terminal.start_prompt(">")
+                        self.terminal.start_prompt(self.get_short_path() + ">")
                 info = (self.mem, 10)
             elif self.task == 2 and selected:
                 if not self.terminal.edit(self, h):
                     self.task = 0
-                    self.terminal.start_prompt(">")
+                    self.terminal.start_prompt(self.get_short_path() + ">")
                 info = ({"CTRL+S" : "Save", \
                              "CTRL+C" : "Close"}, 15)
         else:
         self.terminal.write("Or", 1)
         self.terminal.write_line(": " + ["North", "East", "South", "West"][self.robot.orient])
         self.terminal.write("Shield", 1)
-        self.terminal.write_line(": " + str(self.robot.shield) + "%")
+        self.terminal.write_line(": " + hex(self.robot.shield) + "/0xff ("+\
+                                     str((self.robot.shield * 100) / 0xFF)+"%)")
         self.terminal.write("Energy", 1)
-        self.terminal.write_line(": " + str(self.robot.energy) + "%")
+        self.terminal.write_line(": " + hex(self.robot.energy) + "/0xff ("+\
+                                     str((self.robot.energy * 100) / 0xFF)+"%)")
+        self.terminal.write_line("Registers", 1)
+        for i in sorted(self.robot.mem.keys()):
+            self.terminal.write("  ")
+            self.terminal.write(i, 1)
+            self.terminal.write(": " + hex(self.robot.mem[i]))
+        self.terminal.write_line("")
+        
 
     def help(self, arg):
         if len(arg) > 0:
             self.terminal.write(": " + self.ext_cmd[i][1] + "\n")
                 
     def welcome(self, arg):
-        self.terminal.write_line("*** " + self.name +  " ***\nType 'help' for more information")
+        self.terminal.write_line("\x04\x04\x04 " + self.name +  " \x04\x04\x04\nType 'help' for more information")
 
     def pwd(self, arg):
         self.terminal.write_line(self.current_dir)
 
     def ls(self, arg):
-        s = ""
         for i in os.listdir(self.get_path(self.current_dir)):
-            s += i + " "
-        self.terminal.write_line(s)
+            if os.path.isdir(self.get_path(self.current_dir + i)):
+                self.terminal.write(i, 4)
+            else:
+                self.terminal.write(i)
+            self.terminal.write(" ")
+        self.terminal.write_line("")
 
     def mkdir(self, arg):
         if len(arg) > 0:

src/robot/thermalpowerstation.py

 ##    along with BASIC-RoBots.  If not, see <http://www.gnu.org/licenses/>.
 ## 
 ## Started on  Mon Jul 23 11:55:10 2012 Pierre Surply
-## Last update Sat Aug 11 16:18:08 2012 Pierre Surply
+## Last update Sat Aug 11 22:09:28 2012 Pierre Surply
 ##
 
 import robot
     list_comb = [(0, 50)]
     def __init__(self, new, world, name, env, (x, y), events):
         robot.Robot.__init__(self, new, world, name, env, (x, y), events)
-        self.inv.capacity = 8000000
+        self.inv.capacity = 500000
         self.id_sprite = 3
         self.ext_cmd["burn"] = (self.burn,\
                                     "Burn fuel to produce energy",\

src/robot/woodcutter.py

 ##    along with BASIC-RoBots.  If not, see <http://www.gnu.org/licenses/>.
 ## 
 ## Started on  Tue Jul  3 14:38:15 2012 Pierre Surply
-## Last update Wed Aug  1 18:02:05 2012 Pierre Surply
+## Last update Sun Aug 12 11:56:44 2012 Pierre Surply
 ##
 
 import robot
 ##    along with BASIC-RoBots.  If not, see <http://www.gnu.org/licenses/>.
 ## 
 ## Started on  Wed May  9 18:57:29 2012 Pierre Surply
-## Last update Sat Aug 11 20:40:09 2012 Pierre Surply
+## Last update Sun Aug 12 10:27:12 2012 Pierre Surply
 ##
 
 import time
         self.lines[-1] = self.str2charlist(self.char + " " + self.buf)
         if len(self.buf) < self.pos_curseur:
             self.pos_curseur = len(self.buf)
-        if len(self.lines[-1]) < 3 + self.pos_curseur:
+        if len(self.lines[-1]) < len(self.char) + 2 + self.pos_curseur:
             self.lines[-1].append(ord(" "))
-        self.lines[-1][2 + self.pos_curseur] |= (1 << 8)
+        self.lines[-1][len(self.char) + 1 + self.pos_curseur] |= (1 << 8)
+        for i in range(len(self.char) - 1):
+            self.lines[-1][i] |= (4 << 8)
 
     def start_edit(self, path, f):
         self.clear()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.