Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Компьютеры » Программы » SciTE - Open Source Text Editor for Windows & Linux

Модерирует : gyra, Maz

Widok (23-11-2010 11:23): Лимит страниц. Продолжаем здесь  Версия для печати • ПодписатьсяДобавить в закладки
На первую страницук этому сообщениюк последнему сообщению

   

mozers



Silver Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору

Код:
function _replace_block( l1, c1, l2, c2, fill, incr, nlen )
 
-- Replace/Insert/Fill in rectangle block
 
local l, line_pos, line_len, start_pos, end_pos, nblanks, blanks, txt, inslen
  if l1>l2 then l2,l1=l1,l2 end
  if
c1>c2 then c2,c1=c1,c2 end
  if
nlen>0 then inslen=nlen else inslen=string.len(fill) end
 
editor:BeginUndoAction()
 
editor:DeleteBack() -- we don't need old text in the selection
 
for l = l1, l2 do
   
line_pos = editor:PositionFromLine(l)
   
line_len = editor.LineEndPosition[l] - line_pos
    if c1 > line_len then
     
nblanks = c1 - line_len
      blanks = string.rep(" ",nblanks)
     
editor:InsertText(line_pos+line_len, blanks)
   
end
   
start_pos = line_pos + c1
    if nlen==0 then
     
editor:InsertText(start_pos, fill)
   
else
     
txt = string.format("%0"..nlen.."d", fill)
     
editor:InsertText(start_pos, txt)
     
fill = fill + incr
    end
  end
 
editor.CurrentPos = editor:PositionFromLine(l1) + c1 + inslen
  editor:EndUndoAction()
end
 
function
fill_rectangle(args)
 
-- fill_rectangle text:$(1) incr:$(2)
  -- with one argument - fill with it
  -- with two arguments (numeric) - fill with sequence
 
if editor.SelectionMode ~= SC_SEL_RECTANGLE then
   
_ALERT("Please provide rectangular selection")
   
return
  end
  local
ARG1 = "text:"
 
local ARG1LEN = string.len( ARG1 )
 
local ARG2 = " incr:"
 
local ARG2LEN = string.len( ARG2 )
 
local fill=''
 
local incr=''
 
local nlen=0
 
local pos = string.find(args,ARG1,1,true)
 
if not pos then
    return
  end
 
args = string.sub(args,pos+ARG1LEN)
 
local pos = string.find(args,ARG2,1,true)
 
if pos then
   
fill = string.sub(args,1,pos-1)
   
incr = string.sub(args,pos+ARG2LEN)
 
else
   
fill = args
    incr = ''
 
end
  if
incr ~= '' then
   
nlen = string.len( fill )
   
fill = tonumber( fill )
   
incr = tonumber( incr )
 
end
  local
p1 = editor.CurrentPos
 
local p2 = editor.Anchor
 
if p1 > p2 then
   
p1, p2 = p2, p1
  end
 
_replace_block( editor:LineFromPosition(p1), editor.Column[p1],
                 
editor:LineFromPosition(p2), editor.Column[p2],
                 
fill, incr, nlen )
end

Всего записей: 2187 | Зарегистр. 03-01-2002 | Отправлено: 11:01 02-04-2008
   

На первую страницук этому сообщениюк последнему сообщению

Компьютерный форум Ru.Board » Компьютеры » Программы » SciTE - Open Source Text Editor for Windows & Linux
Widok (23-11-2010 11:23): Лимит страниц. Продолжаем здесь


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru