Tiny patch to get SDL paint.slate working for me

Tony Garnock-Jones tonyg at lshift.net
Fri Apr 1 08:18:00 PST 2005


I am on debian testing. For me, ConsoleOutput doesn't exist, and 
filledPie* functions from SDL_gfx are spelled with a lowercase p, 
filledpie*.

Attached is a unified diff.

Tony

-------------- next part --------------
diff -rN -u old-slate/src/plugins/smart-console/.nfs001677be00015c20 new-slate/src/plugins/smart-console/.nfs001677be00015c20
--- old-slate/src/plugins/smart-console/.nfs001677be00015c20	2005-03-29 17:01:42.000000000 +0100
+++ new-slate/src/plugins/smart-console/.nfs001677be00015c20	1970-01-01 01:00:00.000000000 +0100
@@ -1,631 +0,0 @@
-"Smart console that uses a plugin to read/write in a structured way to the console.
-Keeps a buffer of the data on screen so that it's possible to switch between consoles
-when needed. On some platforms the plugin may open new terminal windows, whereas on
-other platforms it may use a shared console window.
-
-Possible improvements:
- - keep a buffer of data written to terminals and support switching between multiple instances
- - primitive stuff should be factored into ExternalLibrary and it should install a method
-   for each primitive and handle image restarts
- - once a parser generator exists it could even parse C code to extract foreign
-   functions and their signatures
-"
-
-prototypes ensureDelegatedNamespace: #terminals.
-
-terminals addPrototype: #SmartConsole derivedFrom: {ExternalResource}.
-SmartConsole traits addPrototype: #Stream derivedFrom: {SmartConsole Stream}.
-
-SmartConsole traits addPrototype: #Event derivedFrom: {Cloneable}.
-SmartConsole traits addPrototype: #ResizeEvent derivedFrom: {SmartConsole Event}.
-
-e@(SmartConsole ResizeEvent traits) new
-[
-  e clone
-].
-
-SmartConsole traits addPrototype: #KeyEvent derivedFrom: {SmartConsole Event}.
-{
-  'leftControl'.
-  'rightControl'.
-  'leftAlt'.
-  'rightAlt'.
-  'shift'.
-} inject: 0 into: [| :index :name |
-  [| :e | e controls at: index]
-    asMethod: ((name ; 'State') as: Symbol)
-    on: {SmartConsole KeyEvent traits}.
-  [| :e :value | e controls at: index put: value]
-    asMethod: ((name ; 'State:') as: Symbol)
-    on: {SmartConsole KeyEvent traits. Boolean traits}.
-  index + 1
-].
-
-SmartConsole KeyEvent `>> [
-  addSlot: #keyCode.  "A raw and potentially platform specific (basically ncurses/windoze) key code"
-  addSlot: #keyName.  "Key name (e.g. LeftArrow) interned as a symbol"
-  addSlot: #char.     "A Character or Nil if special key"
-  addSlot: #controls valued: (BitArray new &capacity: 5). "Internal BitArray of control chars"
-].
-
-SmartConsole traits addPrototype: #KeyDownEvent derivedFrom: {SmartConsole KeyEvent}.
-
-e@(SmartConsole KeyEvent traits) new
-[
-  e clone `>> [| :event | controls: event controls clone. ]
-].
-
-e@(SmartConsole KeyEvent traits) newForKeyCode: code@(Integer traits)
-[
-  e new `>> [keyCode: code. ]
-].
-
-e@(SmartConsole KeyEvent traits) controlState
-[
-  e leftControlState \/ [e rightControlState]
-].
-
-e@(SmartConsole KeyEvent traits) altState
-[
-  e leftAltState \/ [e rightAltState]
-].
-
-"TODO these are basically ncurses specific, move them"
-SmartConsole traits ensureNamespace: #modes.
-SmartConsole modes `>> [
-  addSlot: #Normal      valued: 0.
-  addSlot: #Standout    valued: 1.
-  addSlot: #Underline   valued: 2.
-  addSlot: #Reverse     valued: 3.
-  addSlot: #Blink       valued: 4.
-  addSlot: #Dim         valued: 5.
-  addSlot: #Bold        valued: 6.
-  addSlot: #Invisible   valued: 8.
-].
-
-SmartConsole traits ensureNamespace: #colors.
-SmartConsole colors `>> [
-  addSlot: #Black   valued: 0.
-  addSlot: #Red     valued: 1.
-  addSlot: #Green   valued: 2.
-  addSlot: #Yellow  valued: 3.
-  addSlot: #Blue    valued: 4.
-  addSlot: #Magenta valued: 5.
-  addSlot: #Cyan    valued: 6.
-  addSlot: #White   valued: 7.
-].
-
-SmartConsole `>> [| :c |
-  addLazySlot: #interactor initializer: [| :inst | inst ReadWriteStream newOn: inst].
-  addSlot: #screenData. "TODO update this, or use the ncurses screen dumping feature"
-  addSlot: #defaultForegroundColor valued: c colors White.
-  addSlot: #defaultBackgroundColor valued: c colors Black.
-  addSlot: #cursorRow valued: 0.
-  addSlot: #cursorColumn valued: 0.
-  addSlot: #currentMode valued: 0.
-  "Does the console automatically scroll when a char is put at the bottom-right?"
-  addSlot: #autoScrollsAtBottom valued: True.
-  addSlot: #currentFgColor valued: SmartConsole colors White.
-  addSlot: #currentBgColor valued: SmartConsole colors Black.
-  addSlot: #singleCharBuffer valued: (ByteArray newSize: 1).
-].
-
-c@(SmartConsole traits) new
-[
-  CursesConsole isAvailable ifTrue: [^ CursesConsole clone].
-  [WindowsConsole isAvailable ifTrue: [^ WindowsConsole clone]] breakOn: Error.
-
-  error: 'No SmartConsole plugin was found'.
-].
-
-c@(SmartConsole traits) isAvailable
-[
-  CursesConsole isAvailable \/
-    [[WindowsConsole isAvailable] on: Error do: [| :_ | ^ False]]
-].
-
-c@(SmartConsole traits) enable
-[
-].
-
-c@(SmartConsole traits) open
-[
-  resend.
-  c handle: 'foo'. "Something else then Nil for now"
-].
-
-c@(SmartConsole traits) resized
-[
-].
-
-c@(SmartConsole traits) close
-[
-  resend.
-  c handle: Nil.
-].
-
-c@(SmartConsole traits) width
-[c columns].
-
-c@(SmartConsole traits) columnLast
-[c columns - 1].
-
-_@(SmartConsole traits) columns
-[overrideThis].
-
-c@(SmartConsole traits) height
-[c rows].
-
-c@(SmartConsole traits) rowLast
-[c rows - 1].
-
-_@(SmartConsole traits) rows
-[overrideThis].
-
-_@(SmartConsole traits) clear
-[overrideThis].
-
-_@(SmartConsole traits) clearToEOS
-[overrideThis].
-
-_@(SmartConsole traits) clearToEOL
-[overrideThis].
-
-_@(SmartConsole traits) nextEvent
-[overrideThis].
-
-c@(SmartConsole traits) nextKeyEvent
-[| event |
-  [event: c nextEvent.
-   event is: c KeyEvent] whileFalse.
-  event
-].
-
-_@(SmartConsole traits) elementType
-[overrideThis].
-
-_@(SmartConsole traits) collectionType
-[overrideThis].
-
-c@(SmartConsole traits) cursorPosition
-[
-  {c cursorColumn. c cursorRow}
-].
-
-c@(SmartConsole traits) isCursorAtLastRow
-[
-  c cursorRow = c rowLast
-].
-
-c@(SmartConsole traits) isCursorAtLastColumn
-[
-  c cursorColumn = c columnLast
-].
-
-c@(SmartConsole traits) moveCursorTo: pos
-[| oldpos |
-  oldpos: c cursorPosition.
-  c cursorColumn: pos first.
-  c cursorRow: pos second.
-  oldpos
-].
-
-c@(SmartConsole traits) moveCursorWithOffset: offset
-[| oldpos newpos newcol newrow |
-  oldpos: c cursorPosition.
-  newcol: (c cursorColumn + offset first min: c columnLast max: 0).
-  newrow: (c cursorRow + offset second min: c rowLast max: 0).
-  newpos: {newcol. newrow}.
-  oldpos = newpos ifFalse: [c moveCursorTo: newpos].
-  newpos
-].
-
-c@(SmartConsole traits) writePosition: data
-[
-  c writePosition: data at: c cursorPosition
-].
-
-c@(SmartConsole traits) writePosition: data at: pos
-[| oldpos |
-  oldpos: (c moveCursorTo: pos).
-  c ; '(' ; (data first as: String) ; ',' ; (data second as: String) ; ')'.
-  c moveCursorTo: oldpos.
-].
-
-c@(SmartConsole traits) writeCursorPositionAt: pos
-[
-  c writePosition: c cursorPosition at: pos
-].
-
-c@(SmartConsole traits) moveCursorToEOL
-[
-  c moveCursorTo: {c columnLast. c cursorRow}
-].
-
-c@(SmartConsole traits) moveCursorToBOL
-[
-  c moveCursorTo: {0. c cursorRow}
-].
-
-c@(SmartConsole traits) moveCursorToBONL
-[
-  c moveCursorTo: {0. (c cursorRow + 1 min: c rowLast)}
-].
-
-c@(SmartConsole traits) moveCursorLeft
-[
-  c moveCursorWithOffset: {-1. 0}
-].
-
-c@(SmartConsole traits) moveCursorRight
-[
-  c moveCursorWithOffset: {1. 0}
-].
-
-c@(SmartConsole traits) moveCursorUp
-[
-  c moveCursorWithOffset: {0. -1}
-].
-
-c@(SmartConsole traits) moveCursorDown
-[
-  c moveCursorWithOffset: {0. 1}
-].
-
-c@(SmartConsole traits) scroll &lines: lines
-[overrideThis].
-
-c@(SmartConsole traits) updateCursorPositionFrom: col@(Collection traits)
-[
-  col do: [| :char | c updateCursorPositionFrom: char].
-].
-
-c@(SmartConsole traits) updateCursorPositionFrom: char
-[
-  char caseOf: {
-    $\n -> [c cursorRow < c rowLast ifTrue: [
-              c cursorRow: c cursorRow + 1].
-            c cursorColumn: 0].
-    $\b -> [c cursorColumn > 0 ifTrue: [c cursorColumn: c cursorColumn - 1]].
-    $\t -> [c cursorColumn: ((c cursorColumn + 8) min: c columnLast)].
-  } otherwise: [
-    c cursorColumn < c columnLast
-      ifTrue: [c cursorColumn: c cursorColumn + 1]
-      ifFalse: [c cursorColumn: 0. c cursorRow: (c cursorRow + 1 min: c rowLast)]].
-].
-
-c@(SmartConsole traits) read: n from: handle into: array@(ByteArray traits) startingAt: start
-[| index |
-  index: 0.
-  [index < n]
-    whileTrue:
-      [| event |
-        event: c nextKeyEvent.
-        event char
-          ifNotNil: [
-            array at: start + index put: (event char as: Integer).
-            index: index + 1].
-      ].
-  n
-].
-
-_@(SmartConsole traits) flush
-[overrideThis].
-
-_@(SmartConsole traits) deleteChar
-[overrideThis].
-
-c@(SmartConsole traits) deleteLine
-[c deleteLines: 1].
-
-_@(SmartConsole traits) deleteLines: n
-[overrideThis].
-
-c@(SmartConsole traits) insertLine
-[c insertLines: 1].
-
-_@(SmartConsole traits) insertLines: n
-[overrideThis].
-
-_@(SmartConsole traits) hideCursor
-[overrideThis].
-
-_@(SmartConsole traits) showCursor
-[overrideThis].
-
-c@(SmartConsole traits) attributeMode: mode
-[| old |
-  old: c currentMode.
-  c currentMode: mode.
-  old
-].
-
-c@(SmartConsole traits) foregroundColor: color
-[| old |
-  old: c currentFgColor.
-  c currentFgColor: color.
-  old
-].
-
-c@(SmartConsole traits) backgroundColor: color
-[| old |
-  old: c currentBgColor.
-  c currentBgColor: color.
-  old
-].
-
-c@(SmartConsole traits) withAttributesDo: block &mode: mode &foreground: fg &background: bg
-[| oldmode oldfg oldbg |
-  mode       ifNotNil: [oldmode: (c attributeMode: mode)].
-  foregound  ifNotNil: [oldfg: (c foregroundColor: fg)].
-  background ifNotNil: [oldbg: (c backgroundColor: bg)].
-
-  [block do]
-    ensure: [
-      oldmode ifNotNil: [c attributeMode: oldmode].
-      oldfg   ifNotNil: [c foregroundColor: oldfg].
-      oldbg   ifNotNil: [c backgroundColor: oldbg].
-    ]
-].
-
-"SmartConsole Streaming"
-
-SmartConsole traits addPrototype: #ReadStream derivedFrom: {ExternalResource ReadStream. SmartConsole Stream}.
-SmartConsole traits addPrototype: #WriteStream derivedFrom:
-  {PrettyPrinterMixin. ExternalResource WriteStream. SmartConsole Stream}.
-
-SmartConsole ReadStream `>> [
-  isBinary: False.
-].
-
-SmartConsole WriteStream `>> [
-  isBinary: False.
-].
-
-c@(SmartConsole traits) ; seq
-"A convenience method for the Console as a Stream resource; do NOT repeat this
-pattern without determining that ; can have no other meaning for the resource."
-[c writer ; seq].
-
-"TODO support encoding"
-s@(SmartConsole Stream traits) elementType
-[s resource elementType].
-
-s@(SmartConsole Stream traits) collectionType
-[s resource collectionType].
-
-_@(SmartConsole Stream traits) isAtEnd
-[False].
-
-s@(SmartConsole Stream traits) flush
-[s resource flush].
-
-w@(SmartConsole WriteStream traits) next: n putAll: seq startingAt: start
-[
-  w resource updateCursorPositionFrom: (seq sliceFrom: start below: start + n).
-  resend
-].
-
-SmartConsole traits addPrototype: #ReadWriteStream derivedFrom: {SmartConsole ReadStream. SmartConsole WriteStream}.
-
-s@(SmartConsole ReadWriteStream traits) upTo: char
-"Specialize upTo: so that when reading upTo a newline then
-start up a line editor. It has a nice effect on code that is
-unaware of SmartTerminal features."
-[
-  char = $\n
-    ifTrue: [| terminal |
-      terminal: (Terminal newBasedOn: s resource).
-      terminal commandEditor readCommand &echoNewLine: True]
-    ifFalse: [resend]
-].
-
-
-terminals addPrototype: #StructuredConsole derivedFrom: {SmartConsole}.
-
-StructuredConsole traits `>> [
-" The code assumes that all derived prototypes have these slots at their traits object
-  addSlot: #instances valued: ExtensibleArray new.
-  addSlot: #sequenceToKeyName valued: Dictionary new.
-  addSlot: #keyCodeToKeyName valued: Dictionary new.
-  addSlot: #columns.
-  addSlot: #rows.
-"
-  addSlot: #originalConsole. "TODO this is a hack"
-].
-
-c@(StructuredConsole traits) isAvailable
-[overrideThis].
-
-c@(StructuredConsole traits) isInStructuredMode
-[
-  c instances size > 0
-].
-
-c@(StructuredConsole traits) assumeStructuredMode
-[
-  c isInStructuredMode ifFalse:
-    [error: 'This call requires the console to be in structured mode'].
-].
-
-c@(StructuredConsole traits) enterStructuredMode
-[overrideThis].
-
-c@(StructuredConsole traits) enteredStructuredMode
-"This method is called after entering structured mode. At the time it is called
-it's safe to call other methods that require the console to be in structured mode."
-[
-  c initKeyMappings.
-  c attributeMode: c modes Normal.
-  c foregroundColor: c defaultForegroundColor.
-  c backgroundColor: c defaultBackgroundColor.
-].
-
-c@(StructuredConsole traits) leaveStructuredMode
-[overrideThis].
-
-c@(StructuredConsole traits) leftStructuredMode
-"This method is called after structured mode is left and console mode is
-restored to its original state."
-[].
-
-c@(StructuredConsole traits) open
-[| result |
-  result: resend.
-  c isInStructuredMode
-    ifTrue: [c instances add: c]
-    ifFalse: [
-      c enterStructuredMode ifFalse: [^ Nil].
-      c instances add: c.
-      c enteredStructuredMode.
-      "TODO this is a hack"
-      conditions DebugConsole: c.
-      c originalConsole: lobby Console.
-      lobby addSlot: #Console valued: c].
-  c resized.
-  result
-].
-
-c@(StructuredConsole traits) close
-[
-  c instances remove: c ifAbsent:
-    [error: 'Tried to close a console that is not open'. ^ Nil].
-
-  c isInStructuredMode ifFalse: [
-    c leaveStructuredMode.
-    "TODO this is a hack"
-    lobby addSlot: #Console valued: c originalConsole.
-    conditions DebugConsole: c originalConsole.
-    c leftStructuredMode].
-  resend
-].
-
-_@(StructuredConsole traits) actualColumns
-[overrideThis].
-
-_@(StructuredConsole traits) actualRows
-[overrideThis].
-
-c@(StructuredConsole traits) resized
-[
-  "Actualize width/height slots and resend"
-  c columns: c actualColumns.
-  c rows: c actualRows.
-  resend
-].
-
-c@(StructuredConsole traits) initKeyMappings
-"Add some defaults if they are not already defined"
-[
-  {
-    {10.     {#Enter. $\n}}.
-    {27.     #Escape}.
-    {9.      {#Tab. $\t}}.
-    {8.      #Backspace}.
-    {127.    #C-Backspace}.
-
-    {'[1~'.  #Home}.
-    {'[2~'.  #Insert}.
-    {'[3~'.  #Delete}.
-    {'[4~'.  #End}.
-    {'[5~'.  #PageUp}.
-    {'[6~'.  #PageDown}.
-    {'[A'.   #UpArrow}.
-    {'[B'.   #DownArrow}.
-    {'[C'.   #RightArrow}.
-    {'[D'.   #LeftArrow}.
-
-    {'[[A'.  #Function1}.
-    {'[[B'.  #Function2}.
-    {'[[C'.  #Function3}.
-    {'[[D'.  #Function4}.
-    {'[[E'.  #Function5}.
-    {'[17~'. #Function6}.
-    {'[18~'. #Function7}.
-    {'[19~'. #Function8}.
-    {'[20~'. #Function9}.
-    {'[21~'. #Function10}.
-    {'[23~'. #Function11}.
-    {'[24~'. #Function12}.
-    {'[25~'. #Function13}.
-    {'[26~'. #Function14}.
-    {'[28~'. #Function15}.
-    {'[29~'. #Function16}.
-    {'[31~'. #Function17}.
-    {'[32~'. #Function18}.
-    {'[33~'. #Function19}.
-    {'[34~'. #Function20}.
-  } do: [| :entry value |
-    value: entry second.
-    (entry first is: String)
-      ifTrue: [| sequence |
-        sequence: entry first.
-        (c sequenceToKeyName includesKey: sequence)
-          ifFalse: [c sequenceToKeyName at: sequence put: value]]
-      ifFalse: [| keyCode keyName |
-        keyCode: entry first.
-        (value is: Array)
-          ifTrue: [keyName: value first]
-          ifFalse: [keyName: value. value: {keyName. Nil}].
-
-        (c keyCodeToKeyName includesKey: keyCode) not
-          /\ (c keyCodeToKeyName detect: [| :each | each first = keyName]) isNil
-            ifTrue: [c keyCodeToKeyName at: keyCode put: value]].
-  ].
-].
-
-c@(StructuredConsole traits) printKeyMappings
-"This method prints the key mappings to the console for debug purposes"
-[
-  c sequenceToKeyName keysAndValuesDo: [| :key :value|
-    c ; ((key as: String) ; '->' ; (value as: String)) ; '\n'].
-
-  c keyCodeToKeyName keysAndValuesDo: [| :key :value msg |
-    c ; ((key as: String) ; '->' ; (value first as: String)) ; '\n'].
-].
-
-c@(StructuredConsole traits) resolveEvent: e
-[| nameFromTable |
-  "TODO handle encoding"
-  c keyCodeToKeyName at: e keyCode
-    ifPresent: [| :value |
-      e keyName: value first.
-      value second ifNotNil: [e char: value second]]
-    ifAbsent: [
-      e keyCode < 32
-        ifTrue: [
-          e leftControlState: True.
-          e char: ((e keyCode bitOr: 2r01100000) as: ASCIICharacter)]
-        ifFalse: [
-          e keyCode <= 255
-            ifTrue: [e char: (e keyCode as: Character)]]].
-  e
-].
-
-c@(StructuredConsole traits) translateEscapedSequence: seq into: event
-[| seq |
-  seq size = 1 /\ [seq first ~= $[ ]
-    ifTrue: [| escapedName |
-      c keyCodeToKeyName at: (seq first as: Integer)
-        ifPresent: [| :value |
-          event keyName: value first.
-          ^ True]
-        ifAbsent: [| name |
-          event leftAltState: True.
-          event char: (seq first as: ASCIICharacter).
-          ^ True]]
-    ifFalse: [
-      event keyName: (c sequenceToKeyName at: seq
-        ifAbsent: [^ False])]
-].
-
-c@(StructuredConsole traits) encode: n into: bytes@(ByteArray traits) from: seq &startingAt: start
-"Filter out control chars except \n and \t and put ^ instead of them."
-[
-  0 below: resend do: [| :index byte |
-    byte: (bytes at: index).
-    byte < 32 /\ [byte ~= 10] /\ [byte ~= 9]
-      ifTrue: [bytes at: index put: #[$^ as: Integer]]].
-  n
-].
-
diff -rN -u old-slate/src/ui/SDL/gfxlib/SDLgfxLib.slate new-slate/src/ui/SDL/gfxlib/SDLgfxLib.slate
--- old-slate/src/ui/SDL/gfxlib/SDLgfxLib.slate	2005-03-29 17:01:47.000000000 +0100
+++ new-slate/src/ui/SDL/gfxlib/SDLgfxLib.slate	2005-04-01 17:03:08.000000000 +0100
@@ -41,8 +41,8 @@
       {#Int. 'aaellipseRGBA'. {#PSurf. #Int. #Int. #Int. #Int. #Int. #Int. #Int. #Int}}.
       {#Int. 'filledEllipseColor'. {#PSurf. #Int. #Int. #Int. #Int. #Int}}.
       {#Int. 'filledEllipseRGBA'. {#PSurf. #Int. #Int. #Int. #Int. #Int. #Int. #Int. #Int}}.
-      {#Int. 'filledPieColor'. {#PSurf. #Int. #Int. #Int. #Int. #Int. #Int}}.
-      {#Int. 'filledPieRGBA'. {#PSurf. #Int. #Int. #Int. #Int. #Int. #Int. #Int. #Int. #Int}}.
+      {#Int. 'filledpieColor'. {#PSurf. #Int. #Int. #Int. #Int. #Int. #Int}}.
+      {#Int. 'filledpieRGBA'. {#PSurf. #Int. #Int. #Int. #Int. #Int. #Int. #Int. #Int. #Int}}.
       {#Int. 'trigonColor'. {#PSurf. #Int. #Int. #Int. #Int. #Int. #Int. #Int}}.
       {#Int. 'trigonRGBA'. {#PSurf. #Int. #Int. #Int. #Int. #Int. #Int. #Int. #Int. #Int. #Int}}.
       {#Int. 'aatrigonColor'. {#PSurf. #Int. #Int. #Int. #Int. #Int. #Int. #Int}}.
diff -rN -u old-slate/src/ui/SDL/tests/paint.slate new-slate/src/ui/SDL/tests/paint.slate
--- old-slate/src/ui/SDL/tests/paint.slate	2005-04-01 16:56:20.000000000 +0100
+++ new-slate/src/ui/SDL/tests/paint.slate	2005-04-01 17:08:27.000000000 +0100
@@ -38,6 +38,6 @@
   SDL updateFullSurface: SDL screen.
 ].
 
-ConsoleOutput ; 'Press Esc in the drawing window (be sure it is active) to stop'.
+"ConsoleOutput ; 'Press Esc in the drawing window (be sure it is active) to stop'."
 
-Painter start.
\ No newline at end of file
+Painter start.



More information about the Slate mailing list