Aegisub/aegisub/automation/tests/basic-tests.lua
Amar Takhar a067bd560d SVN Transition Step 3/7
1. cd aegisub/
  2. svn mv *cpp *h src/
  3. svn mv Makefile.am MatroskaParser.c auto4_perldata.inc bitmaps boost \
     changelog.txt config gl include libosxutil libresrc md5.c msvc mythes.cxx \
     mythes.hxx res.rc src/
  4. cd ..
  5. svn mv FFmpegSource2/ INSTALL Makefile.am README  acinclude.m4 \
     autogen.sh automation/ bin build configure.in desktop dummy.txt lib \
     libass/ m4macros/ packages/ po/ scripts/ universalchardet/ aegisub/
  6. mkdir -p docs/wiki_convert
  7. svn add docs/wiki_convert
  8. cd docs
  9. svn mv aegisub_convert_docs.pl convert.bat output wiki_convert/

* See r2749 for full description.

Originally committed to SVN as r2752.
2009-03-08 08:30:39 +00:00

51 lines
1.7 KiB
Lua

-- Automation 4 test file
-- Create a Macro feature, that displays some text
script_name = "Automation 4 test 2"
script_description = "Some additional non-hello-world tests"
script_author = "Niels Martin Hansen"
script_version = "2"
function macro_test2(subtitles, selected_lines, active_line)
aegisub.debug.out(subtitles.n .. " and " .. #subtitles .. " should be the same value")
aegisub.debug.out(subtitles[selected_lines[1]].raw)
end
function dumper(subtitles, selected_lines, active_line)
for i = 1, #subtitles do
local l = subtitles[i]
local s = l.raw .. "\n"
s = s .. l.class .. "\n"
if l.class == "comment" then
s = s .. "text: " .. l.text .. "\n"
elseif l.class == "info" then
s = s .. string.format("key: %s\nvalue:%s\n", l.key, l.value)
elseif l.class == "format" then
-- skip
elseif l.class == "style" then
s = s .. string.format("name: %s\nfont: %s %d\ncolors: %s %s %s %s\n", l.name, l.fontname, l.fontsize, l.color1, l.color2, l.color3, l.color4)
elseif l.class == "dialogue" then
s = s .. string.format("layer: %d\nstyle: %s\ntext: %s\n", l.layer, l.style, l.text)
end
aegisub.debug.out(s)
end
end
function inserttest(subtitles, selected_lines, active_line)
local lid = selected_lines[1]
subtitles[-lid] = subtitles[lid]
subtitles[0] = subtitles[lid]
local l = subtitles[lid]
l.text = "A4 was here!"
subtitles[lid] = l
aegisub.set_undo_point("Insert Stuff")
end
aegisub.register_macro("File line count", "Count the number of lines in the ASS file", macro_test2, nil)
aegisub.register_macro("Dump", "Dumps info on every line in the file", dumper, nil)
aegisub.register_macro("Insert stuff", "Inserts some lines near the active line", inserttest, nil)