I wrote:
  The new ".session" format is incompatible with the old ".ses" files
and there is no upgrade utility.

It is quite trivial to write a script to convert them.
Perhaps a little Lua script inside SciTE would be the most universal?
I can try if the format shown on the tracker won't change. If somebody else try also, he has a good chance of succeeding before I begin... :-)

Well, perhaps not...

-- Convert .ses file loaded in current buffer
-- to a .session file in .properties format
function ConvertSesFile()
  local session, bufferNb = '', 1
  for line in AllLines() do
    local pos, path, bCurrent = 0, '', false
    _, _, pos, path = string.find(line, "<pos=(-?%d+)> (.*)")
    pos = tonumber(pos)
    if pos < 0 then
      pos = -pos
      bCurrent = true
    end
    session = session .. 'buffer.' .. bufferNb .. '.path=' .. path ..
        'buffer.' .. bufferNb .. '.position=' .. pos .. '\n'
    if bCurrent then
      session = session .. 'buffer.' .. bufferNb .. '.current=1\n\n'
    else
      session = session .. '\n'
    end
    bufferNb = bufferNb + 1
  end
  -- Replace whole text with result
  editor:BeginUndoAction()
  -- Overwrite buffer content with converted lines
  editor:SetText(session)
  -- Operation can be cancelled with a single Undo
  editor:EndUndoAction()
end
--[[
buffer.1.path=c:\SciTE\src-session\scite\src\SciTEBuffers.cxx
buffer.1.position=395
buffer.1.current=1
]]

-- Utilities functions:

-- Iterator
function AllLines()
  local currentLineNb = -1
  local totalLineNb = editor.LineCount
  return function ()
    currentLineNb = currentLineNb + 1
    if currentLineNb < totalLineNb then
      return editor:GetLine(currentLineNb)
    end
  end
end

One has to do a Save As command after the conversion, to add sion to the extension... Unless it can be done in Lua too.

--
Philippe Lhoste
--  (near) Paris -- France
--  http://Phi.Lho.free.fr
--  --  --  --  --  --  --  --  --  --  --  --  --  --

_______________________________________________
Scite-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scite-interest

Reply via email to