Skip to content

Commit

Permalink
新差价
Browse files Browse the repository at this point in the history
  • Loading branch information
cissusnar committed Jul 10, 2016
1 parent 2397c4a commit 386e56b
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
*.cpk
*~
6 changes: 6 additions & 0 deletions objc_auto_new.cplugin/info.lua
@@ -0,0 +1,6 @@
plugin_name = "objc自动new"
plugin_bundle_id = "com.clipber.08EABDF2"
plugin_desc = "自动生成new语法"
plugin_version = "1.0"
plugin_author = "http://clipber.com"
cpkgen_version = "1.0"
38 changes: 38 additions & 0 deletions objc_auto_new.cplugin/main.lua
@@ -0,0 +1,38 @@
function magiclines(s)
if s:sub(-1)~="\n" then s=s.."\n" end
return s:gmatch("(.-)\n")
end

function main(text)
-- edit here
r = ""
for line in magiclines(text) do
pt = string.gsub(line,"%s+", "")
if string.find(pt, "^label") then
r = r .. "\nUILabel * " .. pt .. " = [UILabel new];"
end
if string.find(pt, "^_label") then
r = r .. "\n" .. pt .. " = [UILabel new];"
end
if string.find(pt, "^button") then
r = r .. "\nUIButton * " .. pt .. " = [UIButton new];"
end
if string.find(pt, "^_button") then
r = r .. "\n" .. pt .. " = [UIButton new];"
end
if string.find(pt, "^tableView") then
r = r .. "\nUITableView * " .. pt .. " = [UITableView new];"
end
if string.find(pt, "^_tableView") then
r = r .. "\n" .. pt .. " = [UITableView new];"
end
if string.find(pt, "^imageView") then
r = r .. "\nUIImageView * " .. pt .. " = [UIImageView new];"
end
if string.find(pt, "^_imageView") then
r = r .. "\n" .. pt .. " = [UIImageView new];"
end
end
return r
end

6 changes: 6 additions & 0 deletions objc_gen_property.cplugin/info.lua
@@ -0,0 +1,6 @@
plugin_name = "objc生成属性"
plugin_bundle_id = "com.clipber.F1BC52DA"
plugin_desc = "根据变量前缀生成objc属性"
plugin_version = "1.0"
plugin_author = "http://clipber.com"
cpkgen_version = "1.0"
26 changes: 26 additions & 0 deletions objc_gen_property.cplugin/main.lua
@@ -0,0 +1,26 @@
function magiclines(s)
if s:sub(-1)~="\n" then s=s.."\n" end
return s:gmatch("(.-)\n")
end

function main(text)
-- edit here
r = ""
for line in magiclines(text) do
pt = string.gsub(line,"%s+", "")
if string.find(pt, "^label") then
r = r .. "\n@property (nonatomic, strong) UILabel * " .. pt .. ";"
end
if string.find(pt, "^button") then
r = r .. "\n@property (nonatomic, strong) UIButton * " .. pt .. ";"
end
if string.find(pt, "^tableView") then
r = r .. "\n@property (nonatomic, strong) UITableView * " .. pt .. ";"
end
if string.find(pt, "^imageView") then
r = r .. "\n@property (nonatomic, strong) UIImageView * " .. pt .. ";"
end
end
return r
end

0 comments on commit 386e56b

Please sign in to comment.