diff --git a/package/readme.txt b/package/readme.txt
index 1a5aab8b..cc8f4ba6 100644
--- a/package/readme.txt
+++ b/package/readme.txt
@@ -1,6 +1,6 @@
-------------------------------------------------------------------------------
Kuin Programming Language
-v.2018.6.17
+v.2018.7.17
(C) Kuina-chan
-------------------------------------------------------------------------------
@@ -43,6 +43,17 @@ v.2018.6.17
4. 変更履歴
-------------------------------------------------------------------------------
+v.2018.7.17
+ - よく使うコードを簡単に挿入できる、スニペット機能の追加
+ - 互換性が失われる変更
+ - wnd@WndBase.enableをwnd@WndBase.setEnabledに変更
+ - 細かな機能追加
+ - wnd@WndBase.getEnabled、wnd@WndBase.getVisible、
+ wnd@ListView.clearColumnメソッドの追加
+ - wnd@ListView.onSel、wnd@ListView.onMouseClickイベントの追加
+ - 細かな不具合の修正
+ - math@lcm関数に渡す値が大きいとオーバーフローする不具合の修正
+
v.2018.6.17
- 互換性が失われる変更
- 「+**」構文の廃止と、オーバーライド元メソッドを参照する「super」構文の
diff --git a/package/samples/0000_kuinvaders/res/title.jpg b/package/samples/0000_kuinvaders/res/title.jpg
index a7fd60b8..a5f05050 100644
Binary files a/package/samples/0000_kuinvaders/res/title.jpg and b/package/samples/0000_kuinvaders/res/title.jpg differ
diff --git a/package/sys/dbg/d1003.knd b/package/sys/dbg/d1003.knd
index 2ba40736..11daf079 100644
Binary files a/package/sys/dbg/d1003.knd and b/package/sys/dbg/d1003.knd differ
diff --git a/package/sys/rls/d1003.knd b/package/sys/rls/d1003.knd
index 86e0d77c..f9883f15 100644
Binary files a/package/sys/rls/d1003.knd and b/package/sys/rls/d1003.knd differ
diff --git a/package/sys/snippet.knd b/package/sys/snippet.knd
new file mode 100644
index 00000000..35db43ec
--- /dev/null
+++ b/package/sys/snippet.knd
@@ -0,0 +1,49 @@
+
+
+
+ mainと空のウインドウ
+ var wndMain: wnd@Wnd
+
+func main()
+do @wndMain :: wnd@makeWnd(null, %normal, 800, 450, "Title")
+
+while(wnd@act())
+end while
+end func
+
+
+
+ mainとdrawコントロール
+ var wndMain: wnd@Wnd
+var drawMain: wnd@Draw
+
+func main()
+do @wndMain :: wnd@makeWnd(null, %aspect, 1600, 900, "Title")
+do @drawMain :: wnd@makeDraw(@wndMain, 0, 0, 1600, 900, %scale, %scale, false)
+
+while(wnd@act())
+do draw@render(60)
+end while
+end func
+
+
+
+ listの走査
+ do _0.head()
+while(!_0.term())
+var _1: _2 :: _0.get()
+
+do _0.next()
+end while
+
+
+
+ dictの走査
+ do _0.forEach(_1, null)
+
+func _1(key: _2, value: _3, data: kuin@Class): bool
+ret true
+end func
+
+
+
diff --git a/package/sys/wnd.kn b/package/sys/wnd.kn
index c6c3373c..454599dd 100644
--- a/package/sys/wnd.kn
+++ b/package/sys/wnd.kn
@@ -56,7 +56,10 @@ end enum
+func [d0001.knd, _wndBaseFocused] focused(): bool
end func
- +func [d0001.knd, _wndBaseEnable] enable(isEnabled: bool)
+ +func [d0001.knd, _wndBaseSetEnabled] setEnabled(isEnabled: bool)
+ end func
+
+ +func [d0001.knd, _wndBaseGetEnabled] getEnabled(): bool
end func
+func [d0001.knd, _wndBaseSetPos] setPos(x: int, y: int, width: int, height: int)
@@ -68,6 +71,9 @@ end enum
+func [d0001.knd, _wndBaseSetVisible] setVisible(isVisible: bool)
end func
+ +func [d0001.knd, _wndBaseGetVisible] getVisible(): bool
+ end func
+
+func [d0001.knd, _wndBaseClientToScreen] clientToScreen(screenX: &int, screenY: &int, clientX: int, clientY: int)
end func
@@ -429,6 +435,9 @@ end class
+func [d0001.knd, _listViewLenColumn] lenColumn(): int
end func
+ +func [d0001.knd, _listViewClearColumn] clearColumn()
+ end func
+
+func [d0001.knd, _listViewSetText] setText(idx: int, column: int, text: []char)
end func
@@ -444,7 +453,9 @@ end class
+func [d0001.knd, _listViewGetSel] getSel(): int
end func
+ +var onSel: func<(@WndBase)>
+var onMouseDoubleClick: func<(@WndBase)>
+ +var onMouseClick: func<(@WndBase)>
end class
+class Pager(@WndBase)
diff --git a/package/sys/wndex.kn b/package/sys/wndex.kn
index bc1f95a4..65a92db2 100644
--- a/package/sys/wndex.kn
+++ b/package/sys/wndex.kn
@@ -111,7 +111,7 @@ end func
do result.name :: parseStr(node, "name")
if(!isRoot)
if(!parseBool(node, "enabled"))
- do result.enable(false)
+ do result.setEnabled(false)
end if
if(!parseBool(node, "visible"))
do result.setVisible(false)
diff --git a/src/compiler/main.c b/src/compiler/main.c
index e28f5752..1bbc4339 100644
--- a/src/compiler/main.c
+++ b/src/compiler/main.c
@@ -253,7 +253,7 @@ EXPORT Bool Interpret2(const U8* path, const void*(*func_get_src)(const U8*), co
EXPORT void Version(S64* major, S64* minor, S64* micro)
{
*major = 2018;
- *minor = 6;
+ *minor = 7;
*micro = 17;
}
diff --git a/src/kuin_editor/doc.kn b/src/kuin_editor/doc.kn
index 99c6e8c2..e55d3615 100644
--- a/src/kuin_editor/doc.kn
+++ b/src/kuin_editor/doc.kn
@@ -36,7 +36,13 @@
+func treeItemOnMoveNode()
end func
- +func listInfoOnSel()
+ +func listObjOnSel()
+ end func
+
+ +func listPropOnSel(listView: wnd@ListView)
+ end func
+
+ +func listPropOnMouseClick(listView: wnd@ListView)
end func
+func listPropOnMouseDoubleClick(listView: wnd@ListView)
@@ -105,6 +111,9 @@
+func undoImpl(undo2: @UndoCmd)
end func
+ +func getSelCode(): []char
+ end func
+
+var changed: bool
var undo: undo@Undo
end class
diff --git a/src/kuin_editor/doc_ar.kn b/src/kuin_editor/doc_ar.kn
index 14e5a353..94ba8f3d 100644
--- a/src/kuin_editor/doc_ar.kn
+++ b/src/kuin_editor/doc_ar.kn
@@ -187,11 +187,17 @@
end func
end func
- +*func listInfoOnSel()
- var sel: int :: \form@listInfo.getSel()
+ +*func listObjOnSel()
+ var sel: int :: \form@listObj.getSel()
do me.ctrl :: sel < 0 ?(0, sel)
end func
+ +*func listPropOnSel(listView: wnd@ListView)
+ end func
+
+ +*func listPropOnMouseClick(listView: wnd@ListView)
+ end func
+
+*func listPropOnMouseDoubleClick(listView: wnd@ListView)
if(^me.holds = 0)
ret
@@ -285,7 +291,7 @@
do \form@showMsgRunning()
ret
end if
- var name: []char :: \form@listInfo.getText(me.ctrl)
+ var name: []char :: \form@listObj.getText(me.ctrl)
do me.mode :: %put
do me.holdOffsetX :: x2
do me.holdOffsetY :: y2
diff --git a/src/kuin_editor/doc_src.kn b/src/kuin_editor/doc_src.kn
index 6272d4ae..875b41d6 100644
--- a/src/kuin_editor/doc_src.kn
+++ b/src/kuin_editor/doc_src.kn
@@ -197,7 +197,7 @@ end func
end func
+*func updateList(list_: wnd@List)
- ; TODO:
+ do \snippet@updateList(list_)
end func
+*func treeItemOnSel()
@@ -208,19 +208,37 @@ end func
; TODO:
end func
- +*func listInfoOnSel()
- ; TODO:
- {
- var sel: int :: \form@listInfo.getSel()
- if(sel <> -1 & sel < ^me.listInfoItem)
- do me.listInfoItem.head()
- var item: @ErrListItem :: me.listInfoItem.getOffset(sel)
- if(\src@jumpSrc(item.pos))
- do me.propText :: item.text
- do \form@updateProp()
- end if
+ +*func listObjOnSel()
+ var sel: int :: \form@listObj.getSel()
+ if(sel = -1)
+ ret
+ end if
+ var code: []char :: \snippet@getCode(\form@listObj.getText(sel))
+ if(code =& null)
+ do \form@updateList()
+ ret
+ end if
+ do me.undo.recordBegin()
+ if(me.areaSel())
+ do me.delAreaStr()
+ end if
+ do me.ins(me.cursorX, me.cursorY, code, true)
+ do me.interpret1SetDirty(me.cursorY, true)
+ do me.undo.recordEnd()
+ do me.refreshCursor(false, true)
+ do \form@paintDrawEditor()
+ end func
+
+ +*func listPropOnSel(listView: wnd@ListView)
+ end func
+
+ +*func listPropOnMouseClick(listView: wnd@ListView)
+ var sel: int :: listView.getSel()
+ if(sel <> -1 & sel < ^me.errList)
+ do me.errList.head()
+ var item: @ErrListItem :: me.errList.getOffset(sel)
+ do \src@jumpSrc(item.pos)
end if
- }
end func
+*func mouseDownL(x: int, y: int)
@@ -634,6 +652,31 @@ end func
end if
end func
+ +*func getSelCode(): []char
+ if(!me.areaSel())
+ ret null
+ end if
+ var x1: int :: me.areaX
+ var y1: int :: me.areaY
+ var x2: int :: me.cursorX
+ var y2: int :: me.cursorY
+ if(y1 > y2 | y1 = y2 & x1 > x2)
+ do x1 :$ x2
+ do y1 :$ y2
+ end if
+ var str: []char
+ if(y1 = y2)
+ do str :: me.src.src[y1].sub(x1, x2 - x1).trim()
+ else
+ do str :: me.src.src[y1].sub(x1, -1).trim() ~ "\n"
+ for i(y1 + 1, y2 - 1)
+ do str :~ me.src.src[i].trim() ~ "\n"
+ end for
+ do str :~ me.src.src[y2].sub(0, x2).trim()
+ end if
+ ret str
+ end func
+
func setSrc(src: [][]char)
if(src =& null | ^src = 0)
do me.src.src :: [""]
diff --git a/src/kuin_editor/find.kn b/src/kuin_editor/find.kn
index b7a338ad..51515069 100644
--- a/src/kuin_editor/find.kn
+++ b/src/kuin_editor/find.kn
@@ -87,16 +87,16 @@ end func
do @wndFind.activate()
end if
do @wndFindTabFind.setSel(replace ?(1, 0))
- do @wndFindEditReplace.enable(replace)
- do @wndFindBtnReplace.enable(replace)
- do @wndFindBtnReplaceAll.enable(replace)
+ do @wndFindEditReplace.setEnabled(replace)
+ do @wndFindBtnReplace.setEnabled(replace)
+ do @wndFindBtnReplaceAll.setEnabled(replace)
do wndFindChkRegularExpressionOnPush(null)
do @wndFindEditPattern.focus()
do @wndFindEditPattern.setSel(0, -1)
; TODO:
- do @wndFindRadioAll.enable(false)
- do @wndFindRadioSel.enable(false)
+ do @wndFindRadioAll.setEnabled(false)
+ do @wndFindRadioSel.setEnabled(false)
func wndFindOnClose(wnd: wnd@Wnd): bool
do @tabOrderFind :: null
@@ -137,9 +137,9 @@ end func
ret
end if
var replace: bool :: sel = 1
- do @wndFindEditReplace.enable(replace)
- do @wndFindBtnReplace.enable(replace)
- do @wndFindBtnReplaceAll.enable(replace)
+ do @wndFindEditReplace.setEnabled(replace)
+ do @wndFindBtnReplace.setEnabled(replace)
+ do @wndFindBtnReplaceAll.setEnabled(replace)
end func
func wndFindEditPatternOnChange(wnd: wnd@Edit)
@@ -160,8 +160,8 @@ end func
func wndFindChkRegularExpressionOnPush(wnd: wnd@Chk)
do @wndFindChkRegularExpressionLast :: @wndFindChkRegularExpression.getChk()
- do @wndFindChkDistinguishCase.enable(!@wndFindChkRegularExpressionLast)
- do @wndFindChkOnlyWord.enable(!@wndFindChkRegularExpressionLast)
+ do @wndFindChkDistinguishCase.setEnabled(!@wndFindChkRegularExpressionLast)
+ do @wndFindChkOnlyWord.setEnabled(!@wndFindChkRegularExpressionLast)
end func
func wndFindBtnReplaceOnPush(wnd: wnd@Btn)
diff --git a/src/kuin_editor/form.kn b/src/kuin_editor/form.kn
index d7a62a98..ebe71d1d 100644
--- a/src/kuin_editor/form.kn
+++ b/src/kuin_editor/form.kn
@@ -1,6 +1,6 @@
+var wndMain: wnd@Wnd
+var treeItem: wnd@TreeMulti
-+var listInfo: wnd@List
++var listObj: wnd@List
var editFile: wnd@Edit
+var drawEditor: wnd@Draw
+var scrollXSrc: wnd@ScrollX
@@ -35,13 +35,13 @@ var drag: bool
do @wndMain.onClose :: @wndMainOnClose
do @wndMain.onActivate :: @wndMainOnActivate
do @wndMain.onPushMenu :: @wndMainOnPushMenu
- do @treeItem :: wnd@makeTreeMulti(@wndMain, 12, 12, 244, 466, %fix, %fix)
+ do @treeItem :: wnd@makeTreeMulti(@wndMain, 12, 290, 244, 466, %fix, %scale)
do @treeItem.draggable(true)
do @treeItem.allowDraggingToRoot(false)
do @treeItem.onSel :: @treeItemOnSel
do @treeItem.onMoveNode :: @treeItemOnMoveNode
- do @listInfo :: wnd@makeList(@wndMain, 12, 484, 244, 272, %fix, %scale)
- do @listInfo.onSel :: @listInfoOnSel
+ do @listObj :: wnd@makeList(@wndMain, 12, 12, 244, 272, %fix, %fix)
+ do @listObj.onSel :: @listObjOnSel
do @editFile :: wnd@makeEdit(@wndMain, 262, 12, 759, 15, %scale, %fix)
do @editFile.readonly(true)
do @drawEditor :: wnd@makeDraw(@wndMain, 262, 33, 759, 582, %scale, %scale, true)
@@ -50,9 +50,9 @@ var drag: bool
do @scrollYSrc :: wnd@makeScrollY(@drawEditor, 742, 0, 17, 565, %move, %scale)
do @scrollYSrc.setState(0, 0, 1, 0)
do @listProp :: wnd@makeListView(@wndMain, 262, 621, 391, 135, %scale, %move)
- do @listProp.addColumn(\common@langEn ?("Property", "プロパティ"))
- do @listProp.addColumn(\common@langEn ?("Value", "値"))
+ do @listProp.onSel :: @listPropOnSel
do @listProp.onMouseDoubleClick :: @listPropOnMouseDoubleClick
+ do @listProp.onMouseClick :: @listPropOnMouseClick
do @editLog :: wnd@makeEditMulti(@wndMain, 659, 621, 553, 135, %move, %move)
do @editLog.readonly(true)
do @btnCompile :: wnd@makeBtn(@wndMain, 1027, 12, 185, 23, %move, %fix, \common@langEn ?("Compile && Run", "コンパイル&実行"))
@@ -96,6 +96,8 @@ var drag: bool
do @popupMainEdit.add(0x0037, \common@langEn ?("&Delete\tDel", "削除(&D)\tDel"))
do @popupMainEdit.add(0x0038, \common@langEn ?("Select &All\tCtrl+A", "すべて選択(&A)\tCtrl+A"))
do @popupMainEdit.addLine()
+ do @popupMainEdit.add(0x003D, \common@langEn ?("Add &Selection To Snippet", "選択範囲をスニペットに追加(&S)"))
+ do @popupMainEdit.addLine()
do @popupMainEdit.add(0x0039, \common@langEn ?("&Find\tCtrl+F", "検索(&F)\tCtrl+F"))
do @popupMainEdit.add(0x003A, \common@langEn ?("&Replace\tCtrl+H", "置換(&R)\tCtrl+H"))
do @popupMainEdit.add(0x003B, \common@langEn ?("Find Pre&vious\tShift+F3", "前を検索(&V)\tShift+F3"))
@@ -395,6 +397,9 @@ func wndMainOnPushMenu(wnd: wnd@WndBase, id: int)
do \find@findPrev()
case 0x003C
do \find@findNext()
+ case 0x003D
+ do \snippet@add(\src@curDoc.getSelCode())
+ do @updateList()
end switch
end func
@@ -409,8 +414,8 @@ func treeItemOnMoveNode(wnd: wnd@WndBase)
do \src@curDoc.treeItemOnMoveNode()
end func
-func listInfoOnSel(wnd: wnd@WndBase)
- do \src@curDoc.listInfoOnSel()
+func listObjOnSel(wnd: wnd@WndBase)
+ do \src@curDoc.listObjOnSel()
end func
func drawEditorOnPaint(wnd: wnd@WndBase, width: int, height: int)
@@ -472,6 +477,14 @@ func drawEditorOnSetMouseImg(wnd: wnd@WndBase): wnd@MouseImg
ret \src@curDoc.setMouseImg()
end func
+func listPropOnSel(wnd: wnd@WndBase)
+ do \src@curDoc.listPropOnSel(@listProp)
+end func
+
+func listPropOnMouseClick(wnd: wnd@WndBase)
+ do \src@curDoc.listPropOnMouseClick(@listProp)
+end func
+
func listPropOnMouseDoubleClick(wnd: wnd@WndBase)
do \src@curDoc.listPropOnMouseDoubleClick(@listProp)
end func
@@ -692,6 +705,13 @@ end func
+func updateProp()
do @listProp.setRedraw(false)
do @listProp.clear()
+ do @listProp.clearColumn()
+ if(\src@curDoc =$ \doc_src@DocSrc)
+ do @listProp.addColumn(\common@langEn ?("Error", "エラー"))
+ else
+ do @listProp.addColumn(\common@langEn ?("Property", "プロパティ"))
+ do @listProp.addColumn(\common@langEn ?("Value", "値"))
+ end if
do \src@curDoc.updateProp(@listProp)
do @listProp.adjustWidth()
do @listProp.setRedraw(true)
@@ -708,10 +728,10 @@ end func
end func
+func updateList()
- do @listInfo.setRedraw(false)
- do @listInfo.clear()
- do \src@curDoc.updateList(@listInfo)
- do @listInfo.setRedraw(true)
+ do @listObj.setRedraw(false)
+ do @listObj.clear()
+ do \src@curDoc.updateList(@listObj)
+ do @listObj.setRedraw(true)
end func
+func updateUi()
@@ -723,10 +743,10 @@ end func
func lockEditor(lock: bool)
do @lockingEditor :: lock
- do @btnCompile.enable(!lock)
- do @btnRls.enable(!lock)
- do @editIcon.enable(!lock)
- do @btnIcon.enable(!lock)
+ do @btnCompile.setEnabled(!lock)
+ do @btnRls.setEnabled(!lock)
+ do @editIcon.setEnabled(!lock)
+ do @btnIcon.setEnabled(!lock)
end func
+func setEditIconDirectly(icon: []char)
diff --git a/src/kuin_editor/kuin_editor.kn b/src/kuin_editor/kuin_editor.kn
index b46d181f..9a18b374 100644
--- a/src/kuin_editor/kuin_editor.kn
+++ b/src/kuin_editor/kuin_editor.kn
@@ -7,6 +7,7 @@ func main()
do \dll@initCompiler(\common@langEn ?(1, 0))
do \completion@init()
do \find@init()
+ do \snippet@load()
do \form@makeWnd()
do \doc_src@init()
do \src@init()
diff --git a/src/kuin_editor/snippet.kn b/src/kuin_editor/snippet.kn
new file mode 100644
index 00000000..3aba77ae
--- /dev/null
+++ b/src/kuin_editor/snippet.kn
@@ -0,0 +1,145 @@
+var snippets: list<@Snippet>
+
+class Snippet()
+ +var name: []char
+ +var removable: bool
+ +var code: []char
+end class
+
++func load()
+ do @snippets :: #list<@Snippet>
+ do loadXml(file@exeDir() ~ "sys/snippet.knd", false)
+ do loadXml(file@exeDir() ~ "sys/snippet_user.knd", true)
+
+ func loadXml(path: []char, removable: bool)
+ try
+ var prop: xml@Xml :: xml@makeXml(path)
+ if(prop =& null)
+ ret
+ end if
+ var root: xml@Node :: prop.root()
+ var snippets: xml@Node :: root.findChild("snippets")
+ var node: xml@Node :: snippets.firstChild()
+ while(node <>& null)
+ var item: @Snippet :: #@Snippet
+ do item.name :: node.findChild("name").getValue()
+ if(item.name =& null)
+ do item.name :: ""
+ end if
+ do item.removable :: removable
+ do item.code :: node.findChild("code").getValue()
+ if(item.code =& null)
+ do item.code :: ""
+ end if
+ do @snippets.add(item)
+ do node :: node.next()
+ end while
+ catch
+ end try
+ end func
+end func
+
+func save()
+ do saveXml(file@exeDir() ~ "sys/snippet.knd", false)
+ do saveXml(file@exeDir() ~ "sys/snippet_user.knd", true)
+
+ func saveXml(path: []char, removable: bool)
+ do file@delFile(path)
+ var prop: xml@Xml :: xml@makeXmlEmpty()
+ var root: xml@Node :: prop.root()
+ var snippets: xml@Node :: root.addChild("snippets")
+ do @snippets.head()
+ while(!@snippets.term())
+ var snippet: @Snippet :: @snippets.get()
+ if(snippet.removable = removable)
+ var node: xml@Node :: snippets.addChild("snippet")
+ do node.addChild("name").setValue(snippet.name)
+ do node.addChild("code").setValue(snippet.code)
+ end if
+ do @snippets.next()
+ end while
+ do prop.save(path, false)
+ end func
+end func
+
++func add(code: []char)
+ if(code =& null)
+ ret
+ end if
+
+ var name: []char :: wndex@inputBox(\form@wndMain, \common@langEn ?("Input the snippet name.", "スニペットの名前を入力してください。"), \common@title, null, validate)
+ if(name <>& null)
+ do name :: name.trim()
+ if(name <> "")
+ var snippet: @Snippet :: #@Snippet
+ do snippet.name :: name
+ do snippet.removable :: true
+ do snippet.code :: code
+ do @snippets.add(snippet)
+ do @save()
+ end if
+ end if
+
+ func validate(name: []char): bool
+ do @snippets.head()
+ while(!@snippets.term())
+ if(@snippets.get().name = name)
+ ret false
+ end if
+ do @snippets.next()
+ end while
+ ret true
+ end func
+end func
+
++func updateList(list_: wnd@List)
+ do @snippets.head()
+ while(!@snippets.term())
+ var snippet: @Snippet :: @snippets.get()
+ do list_.add((snippet.removable ?("\\", "")) ~ snippet.name)
+ do @snippets.next()
+ end while
+end func
+
++func getCode(name: []char): []char
+ if(^name >= 1 & name[0] = '\\')
+ do name :: name.sub(1, -1)
+ end if
+ var snippet: @Snippet :: null
+ do @snippets.head()
+ while loop(!@snippets.term())
+ var item: @Snippet :: @snippets.get()
+ if(item.name = name)
+ do snippet :: item
+ break loop
+ end if
+ do @snippets.next()
+ end while
+ if(snippet =& null)
+ ret null
+ end if
+ var result: wnd@MsgBoxResult :: wnd@msgBox(\form@wndMain, (\common@langEn ?("Insert the following code?", "以下のコードを挿入しますか?")) ~ "\n\n" ~ snippet.name ~ "\n\n" ~ snippet.code, \common@title, %question, %yesNoCancel)
+ switch(result)
+ case %yes
+ ret snippet.code
+ case %no
+ if(!snippet.removable)
+ ret null
+ end if
+ do result :: wnd@msgBox(\form@wndMain, (\common@langEn ?("Delete [\{snippet.name}] snippet?", "スニペット[\{snippet.name}]を削除しますか?")), \common@title, %question, %yesNoCancel)
+ if(result = %yes)
+ do @snippets.head()
+ while loop(!@snippets.term())
+ if(@snippets.get().name = name)
+ do @snippets.del()
+ skip loop
+ end if
+ do @snippets.next()
+ end while
+ do @save()
+ end if
+ ret null
+ case %cancel
+ ret null
+ end switch
+end func
diff --git a/src/lib_math/main.c b/src/lib_math/main.c
index a1abe32d..f804c12f 100644
--- a/src/lib_math/main.c
+++ b/src/lib_math/main.c
@@ -101,7 +101,7 @@ EXPORT S64 _lcm(S64 a, S64 b)
a = -a;
if (b < 0)
b = -b;
- return a * b / _gcd(a, b);
+ return a / _gcd(a, b) * b;
}
EXPORT S64 _modPow(S64 value, S64 exponent, S64 modulus)
diff --git a/src/lib_wnd/main.cpp b/src/lib_wnd/main.cpp
index db7ca022..1bbe0ce5 100644
--- a/src/lib_wnd/main.cpp
+++ b/src/lib_wnd/main.cpp
@@ -220,7 +220,9 @@ struct SLabelLink
struct SListView
{
SWndBase WndBase;
+ void* OnSel;
void* OnMouseDoubleClick;
+ void* OnMouseClick;
};
struct SPager
@@ -816,11 +818,16 @@ EXPORT_CPP Bool _wndBaseFocused(SClass* me_)
return GetFocus() == reinterpret_cast(me_)->WndHandle;
}
-EXPORT_CPP void _wndBaseEnable(SClass* me_, Bool is_enabled)
+EXPORT_CPP void _wndBaseSetEnabled(SClass* me_, Bool is_enabled)
{
EnableWindow(reinterpret_cast(me_)->WndHandle, is_enabled ? TRUE : FALSE);
}
+EXPORT_CPP Bool _wndBaseGetEnabled(SClass* me_)
+{
+ return IsWindowEnabled(reinterpret_cast(me_)->WndHandle);
+}
+
EXPORT_CPP void _wndBaseSetPos(SClass* me_, S64 x, S64 y, S64 width, S64 height)
{
SetWindowPos(reinterpret_cast(me_)->WndHandle, NULL, (int)x, (int)y, (int)width, (int)height, SWP_NOZORDER);
@@ -843,6 +850,11 @@ EXPORT_CPP void _wndBaseSetVisible(SClass* me_, Bool is_visible)
ShowWindow(reinterpret_cast(me_)->WndHandle, is_visible ? SW_SHOW : SW_HIDE);
}
+EXPORT_CPP Bool _wndBaseGetVisible(SClass* me_)
+{
+ return IsWindowVisible(reinterpret_cast(me_)->WndHandle);
+}
+
EXPORT_CPP void _wndBaseClientToScreen(SClass* me_, S64* screenX, S64* screenY, S64 clientX, S64 clientY)
{
POINT point;
@@ -1298,7 +1310,9 @@ EXPORT_CPP SClass* _makeListView(SClass* me_, SClass* parent, S64 x, S64 y, S64
DWORD ex = ListView_GetExtendedListViewStyle(wnd);
ListView_SetExtendedListViewStyle(wnd, ex | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
SetWindowLongPtr(ListView_GetHeader(wnd), GWLP_USERDATA, reinterpret_cast(me_));
+ me2->OnSel = NULL;
me2->OnMouseDoubleClick = NULL;
+ me2->OnMouseClick = NULL;
return me_;
}
@@ -1389,6 +1403,13 @@ EXPORT_CPP S64 _listViewLenColumn(SClass* me_)
return static_cast(Header_GetItemCount(ListView_GetHeader(reinterpret_cast(me_)->WndHandle)));
}
+EXPORT_CPP void _listViewClearColumn(SClass* me_)
+{
+ S64 len = _listViewLenColumn(me_);
+ for (S64 i = 0; i < len; i++)
+ _listViewDelColumn(me_, 0);
+}
+
EXPORT_CPP void _listViewSetText(SClass* me_, S64 idx, S64 column, const U8* text)
{
THROWDBG(text == NULL, 0xc0000005);
@@ -2290,6 +2311,26 @@ static void CommandAndNotify(HWND wnd, UINT msg, WPARAM w_param, LPARAM l_param)
}
}
break;
+ case WndKind_ListView:
+ {
+ SListView* list_view = reinterpret_cast(wnd_ctrl2);
+ switch (reinterpret_cast(l_param)->code)
+ {
+ case LVN_ITEMCHANGED:
+ if (list_view->OnSel != NULL)
+ {
+ NMLISTVIEW* param = reinterpret_cast(l_param);
+ if ((param->uOldState & LVIS_SELECTED) != (param->uNewState & LVIS_SELECTED))
+ Call1Asm(IncWndRef(reinterpret_cast(wnd_ctrl2)), list_view->OnSel);
+ }
+ break;
+ case NM_CLICK:
+ if (list_view->OnMouseClick != NULL)
+ Call1Asm(IncWndRef(reinterpret_cast(wnd_ctrl2)), list_view->OnMouseClick);
+ break;
+ }
+ }
+ break;
}
}
}
diff --git a/src/lib_wnd/main.h b/src/lib_wnd/main.h
index e2202c77..bf4fa376 100644
--- a/src/lib_wnd/main.h
+++ b/src/lib_wnd/main.h
@@ -22,10 +22,12 @@ EXPORT_CPP void _wndBaseGetPos(SClass* me_, S64* x, S64* y, S64* width, S64* hei
EXPORT_CPP void _wndBaseGetPosScreen(SClass* me_, S64* x, S64* y, S64* width, S64* height);
EXPORT_CPP void _wndBaseFocus(SClass* me_);
EXPORT_CPP Bool _wndBaseFocused(SClass* me_);
-EXPORT_CPP void _wndBaseEnable(SClass* me_, Bool is_enabled);
+EXPORT_CPP void _wndBaseSetEnabled(SClass* me_, Bool is_enabled);
+EXPORT_CPP Bool _wndBaseGetEnabled(SClass* me_);
EXPORT_CPP void _wndBaseSetPos(SClass* me_, S64 x, S64 y, S64 width, S64 height);
EXPORT_CPP void _wndBaseSetRedraw(SClass* me_, Bool is_enabled);
EXPORT_CPP void _wndBaseSetVisible(SClass* me_, Bool is_visible);
+EXPORT_CPP Bool _wndBaseGetVisible(SClass* me_);
EXPORT_CPP void _wndBaseClientToScreen(SClass* me_, S64* screenX, S64* screenY, S64 clientX, S64 clientY);
EXPORT_CPP void _wndBaseScreenToClient(SClass* me_, S64* clientX, S64* clientY, S64 screenX, S64 screenY);
EXPORT_CPP void _wndMinMax(SClass* me_, S64 minWidth, S64 minHeight, S64 maxWidth, S64 maxHeight);
diff --git a/src/lib_xml/main.cpp b/src/lib_xml/main.cpp
index 668c32be..3ad92879 100644
--- a/src/lib_xml/main.cpp
+++ b/src/lib_xml/main.cpp
@@ -52,7 +52,7 @@ EXPORT_CPP SClass* _makeXml(SClass* me_, const U8* path)
if (file_ptr == NULL)
return NULL;
me2->Tree = static_cast(AllocMem(sizeof(tinyxml2::XMLDocument)));
- new(me2->Tree)tinyxml2::XMLDocument(true, tinyxml2::COLLAPSE_WHITESPACE);
+ new(me2->Tree)tinyxml2::XMLDocument(true, tinyxml2::PRESERVE_WHITESPACE);
tinyxml2::XMLError result = me2->Tree->LoadFile(file_ptr);
fclose(file_ptr);
if (result != tinyxml2::XML_SUCCESS)
@@ -69,7 +69,7 @@ EXPORT_CPP SClass* _makeXmlEmpty(SClass* me_)
{
SXml* me2 = reinterpret_cast(me_);
me2->Tree = static_cast(AllocMem(sizeof(tinyxml2::XMLDocument)));
- new(me2->Tree)tinyxml2::XMLDocument(true, tinyxml2::COLLAPSE_WHITESPACE);
+ new(me2->Tree)tinyxml2::XMLDocument(true, tinyxml2::PRESERVE_WHITESPACE);
me2->Tree->InsertEndChild(me2->Tree->NewDeclaration());
return me_;
}