Sahli Editor
+
+
+
diff --git a/textmode.coffee b/textmode.coffee
index 2d62724..e2749f5 100644
--- a/textmode.coffee
+++ b/textmode.coffee
@@ -1663,3 +1663,318 @@ class @ImageTextModeFontAmiga extends @ImageTextModeFont
]
@height = 16
@[k] = v for own k, v of options
+
+Sahli Editor
+============
+
+Editor for Sahli files.
+
+- open existing file
+- create new item
+ * get filename from dir
+ * insert SAUCE data if available
+ * use SAUCE data to find font
+ * allow Amiga choices
+ * colorpicker
+- edit existing item
+- remove item
+- clear whole file
+- copy/clone
+- move items around
+- sort items
+- output to screen (copy into file)
+ * run from node - save filename dialog
+
+***
+It should be noted that this does not do bounds checking, and it would be very
+possible to overflow this by using a debugger and such. As the purpose of this
+is limited, and this should NOT be put on a live website, I feel that is ok for
+now. Perhaps I will fix it after Revision.
+
+***
+
+== Create Initial crappage
+We need to make a screen that has a few things in it for starters
+Title, load existing, and new file options.
+
+Silliness for checking that this works.
+
+ $(-> $("h1").hide().slideDown(500))
+
+Create buttos to choose between the New and Load functionalities
+(As we are not going to ever load a file _and_ do a new file.)
+(If someone wants to do that, they can restart with F5 or something.)
+Also hide the editor until needed, and initialize some elements.
+
+ $(->
+ $("#newsahli")
+ .button { disabled: false}
+ .click -> newsahli()
+ )
+
+ $(->
+ $("#loadsahli")
+ .button { disabled: false}
+ .click -> loadsahli()
+ )
+ $(->
+ $(".hidden").hide()
+ $("#entryamiga").button {icons: {primary:"ui-icon-gear"}}
+ .click ->
+ stuff = $(@).children()
+ if @.value == "1"
+ stuff[1].textContent = 'Ansi'
+ @.value = "0"
+ else
+ stuff[1].textContent = 'Ascii'
+ @.value = "1"
+ $(".45box").css {width:'45%',display:'inline-block'}
+ $(".groupbox p").css {margin:"0 0 .25em 0"}
+ $("#entryfilepick").change ->
+ if @.files[0]? then $("#entryfile").val @.files[0].name
+ $("#entryfile").click ->
+ $("#entryfilepick").click()
+ )
+
+The sahli file definition format is as follows:
+"file" - the actual filename on disk, "name" - the title of the piece,
+the boolean 'amiga' indicates if it is ansi or ascii (True = ascii),
+width is the width (widest point of the file), author the author of the piece,
+the color and bg items define the color for amiga ascii, and the font
+defines the font similarly. For PC ansi, this should be 'ansifont.'
+The three remaining lines are informational and optional.
+
+The slide format is currently unused, but consists of a background picture,
+a html template, and a css file.
+
+ class Sahli
+ constructor: ->
+ @emptyfiledef = {
+ "file": "",
+ "name": "",
+ "amiga": true,
+ "width": "",
+ "author": "",
+ "font": "Propaz",
+ "color": [ 0,0,0,0 ],
+ "bg": [ 0,0,0,0 ],
+ "line1": "",
+ "line2": "",
+ "text": ""
+ }
+ @emptyslidesdef = {
+ "background": "",
+ "template": "",
+ "css": ""
+ }
+ @empty = {
+ "slides": @emptyslidesdef,
+ "filedata": [ ]
+ }
+
+ loader: ->
+ $.ajax {
+ url: '../list.sahli',
+ dataType: "json",
+ success: (result) =>
+ @data = result
+ @.edit()
+ }
+
+Editor functionality:
+Close the new/load buttons - unneeded now.
+list, and allow dragon-droppings for sorting. Doubleclick to edit, or use
+edit button.
+
+ edit: ->
+ $('#buttonbox').hide()
+ $('#listsave').button {icons: {primary:"ui-icon-disk"}}
+ .click =>
+ console.log dumpjson @.data
+
+
+You need to save the order, and extract these in that order; moving around
+does not alter the array. Alternately, _have_ it alter the array.
+
+ @buildlist @data
+
+ buildlist: (data) ->
+ $('#list').show 100
+ x = 0
+ $('#sortlist').append @.additem item,x++ for item in @data.filedata
+ $('#sortlist').sortable
+ start: (event,ui) ->
+ ui.item.data {startpos:ui.item.index()}
+ stop: (event,ui) =>
+ s = ui.item.data().startpos
+ e = ui.item.index()
+ @data.filedata = @.rearrangearray s,e,@data.filedata
+ console.log name.author for name in @data.filedata
+ console.log '---'
+
+Given a start and and end position, pop the array element at start off and
+insert it into the array at end position. A la the draggon-dropping.
+
+ rearrangearray: (startpos,endpos,a) ->
+ moving = a[startpos]
+ alen = a.length
+ tarr = a[0...startpos].concat a[startpos+1..-1]
+ tarr[0...endpos].concat [moving].concat tarr[endpos..-1]
+
+
+ additem: (item,pos) ->
+ entry = @.genentryline item,pos
+ entry.dblclick =>
+ @.editline item,pos
+
+ genentryline: (item,pos) ->
+ arrows = ""
+ amigastatus = ansiorascii booltoint item.amiga
+ delbutton = $("delete")
+ .click ((_this) ->
+ (event) ->
+ pos = @.id.replace "del-",""
+ console.log _this.data.filedata.splice pos,1
+ @.parentNode.remove()
+ )(this)
+ entry = $("