开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
3 Star 2 Fork 1

PureBasic/PureBASIC

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
devel
分支 (25)
devel
spiderbasic-3.10
v6.21
v6.20
spiderbasic-3.02
qt
v6.12
spiderbasic-3.01
enablejs-ignore-formatting
master
spiderbasic-3.00
webview-tool
v6.11
v6.10
v6.04
spiderbasic-2.51
v6.03
editor-fix-3
editor-slow-fix2
editor-slow-fix
devel
分支 (25)
devel
spiderbasic-3.10
v6.21
v6.20
spiderbasic-3.02
qt
v6.12
spiderbasic-3.01
enablejs-ignore-formatting
master
spiderbasic-3.00
webview-tool
v6.11
v6.10
v6.04
spiderbasic-2.51
v6.03
editor-fix-3
editor-slow-fix2
editor-slow-fix
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
devel
分支 (25)
devel
spiderbasic-3.10
v6.21
v6.20
spiderbasic-3.02
qt
v6.12
spiderbasic-3.01
enablejs-ignore-formatting
master
spiderbasic-3.00
webview-tool
v6.11
v6.10
v6.04
spiderbasic-2.51
v6.03
editor-fix-3
editor-slow-fix2
editor-slow-fix
purebasic
/
PureBasicDebugger
/
VariableGadget.pb
purebasic
/
PureBasicDebugger
/
VariableGadget.pb
VariableGadget.pb 47.35 KB
一键复制 编辑 原始数据 按行查看 历史
Timo Harter 提交于 2023年04月28日 17:25 +08:00 . Gtk3 support (#182)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341
; --------------------------------------------------------------------------------------------
; Copyright (c) Fantaisie Software. All rights reserved.
; Dual licensed under the GPL and Fantaisie Software licenses.
; See LICENSE and LICENSE-FANTAISIE in the project root for license information.
; --------------------------------------------------------------------------------------------
; describes one entry in the gadget
;
Structure VariableGadget_Entry
Kind.b ; 0=normal, or #TYPE_ARRAY, #TYPE_LINKEDLIST or #TYPE_MAP
Type.b ; type (normal debugger type value)
Node.w ; 0=no node, 1=node (closed), 2=node (open)
Sublevel.w ; structure sublevel
Parent.l ; index of parent item (-1 if none), needed for sorting
Name$ ; variable name (as displayed in the gadget)
Value$ ; variable value (as displayed in the gadget)
Extra$ ; info in the extra column(s)
EndStructure
; Sort order of types in the gadget
; We cannot use the debugger types directly as they have a different numerical order
Enumeration
#SORTTYPE_Unknown
#SORTTYPE_Byte
#SORTTYPE_Ascii
#SORTTYPE_Character
#SORTTYPE_Unicode
#SORTTYPE_Word
#SORTTYPE_Long
#SORTTYPE_Integer
#SORTTYPE_Quad
#SORTTYPE_Pointer
#SORTTYPE_Float
#SORTTYPE_Double
#SORTTYPE_String
#SORTTYPE_FixedString
#SORTTYPE_Structure
EndEnumeration
; a dummy structure with an empty array, to make access
; to the Entry list (which is a memory area) easy.
;
Structure VariableGadget_ItemList
item.VariableGadget_Entry[0]
EndStructure
; SetGadgetData() stores the VariableGadget pointer
; SetGadgetItemData() contains the real index in the Entry array (this never needs to be changed)
; structure representing one gadget
;
Structure VariableGadget
Gadget.i ; purebasic #Gadget (can be #PB_Any)
ExtraColumns.l ; number of extra columns in the gadget
ItemCount.l ; number of items
Items.i ; memory area for the items
CustomData.i ; free to be used by the caller
IsLocked.l ; if locked, no events get processed to not mess things up (FlushEvents() may be called while adding items to the gadget!)
CurrentParent.l; current parent item while adding items
CurrentSublevel.l ; current sublevel while adding
SortColumn.l ; -1 if none
SortDirection.l ; 1 or -1
IndexSort.l ; true if the main level should be sorted by index rather than name
CompilerIf #CompileLinuxGtk
TreeModel.i ; While the gadget is locked, store the model here
CompilerEndIf
EndStructure
Global NewList VariableGadget_List.VariableGadget() ; currently created gadgets
Global Dim VariableGadget_Icons(#TYPE_MAX) ; icons for the variable types
Global VariableGadget_NodeOpen, VariableGadget_NodeClose
; internal function to catch the 12x12 images and put them in the right size
; (ie 16x16 on windows)
;
UsePNGImageDecoder()
Procedure VariableGadget_CatchIcon(*Address)
CompilerIf #CompileMac
; TODO: implement DrawImage() on MacOS
result = CatchImage(#PB_Any, *Address)
CompilerElse
realImage = CatchImage(#PB_Any, *Address)
result = CreateImage(#PB_Any, #DEFAULT_ListIconImageSize, #DEFAULT_ListIconImageSize)
If result And realImage And StartDrawing(ImageOutput(result))
Box(0, 0, #DEFAULT_ListIconImageSize, #DEFAULT_ListIconImageSize, $FFFFFF)
DrawImage(ImageID(realImage), #DEFAULT_ListIconImageOffset, #DEFAULT_ListIconImageOffset)
StopDrawing()
EndIf
CompilerEndIf
ProcedureReturn result
EndProcedure
; Get the #SORTTYPE_xxx value for the given debugger type
; No List/Array types allowed (these are not displayed in the gadget anyway)
;
Procedure VariableGadget_SortType(type)
If IS_POINTER(type)
ProcedureReturn #SORTTYPE_Pointer
Else
Select type & #TYPEMASK
Case #TYPE_BYTE: ProcedureReturn #SORTTYPE_Byte
Case #TYPE_ASCII: ProcedureReturn #SORTTYPE_Ascii
Case #TYPE_CHARACTER: ProcedureReturn #SORTTYPE_Character
Case #TYPE_UNICODE: ProcedureReturn #SORTTYPE_Unicode
Case #TYPE_WORD: ProcedureReturn #SORTTYPE_Word
Case #TYPE_LONG: ProcedureReturn #SORTTYPE_Long
Case #TYPE_INTEGER: ProcedureReturn #SORTTYPE_Integer
Case #TYPE_QUAD: ProcedureReturn #SORTTYPE_Quad
Case #TYPE_FLOAT: ProcedureReturn #SORTTYPE_Float
Case #TYPE_DOUBLE: ProcedureReturn #SORTTYPE_Double
Case #TYPE_STRING: ProcedureReturn #SORTTYPE_String
Case #TYPE_FIXEDSTRING: ProcedureReturn #SORTTYPE_FixedString
Case #TYPE_STRUCTURE: ProcedureReturn #SORTTYPE_Structure
Default: ProcedureReturn #SORTTYPE_Unknown
EndSelect
EndIf
EndProcedure
; Compare two items in the gadget (for sorting, returns >0, 0, <0)
;
; Note:
; Array, List, Map are only possible inside structures (where they always sort by order),
; So we do not have to take care of these in the compare proc
;
Procedure VariableGadget_Compare(*Gadget.VariableGadget, index1, index2)
*items.VariableGadget_ItemList = *Gadget\Items
*entry1.VariableGadget_Entry = @*items\item[index1]
*entry2.VariableGadget_Entry = @*items\item[index2]
If *entry1\Parent = -1 And *entry2\Parent = -1
; both are toplevel items, so compare them
; since we only compare toplevel items, there are no spaces at the names
; Get the result for the name compare always, as it is a fallback below
;
If *Gadget\IndexSort
NameResult = (index1 - index2) * *Gadget\SortDirection ; compare indexes instead of names for the main level
Else
; ignore the * in front of names
*Name1 = @*entry1\Name$
If PeekC(*Name1) = '*'
*Name1 + SizeOf(Character)
EndIf
*Name2 = @*entry2\Name$
If PeekC(*Name2) = '*'
*Name2 + SizeOf(Character)
EndIf
NameResult = CompareMemoryString(*Name1, *Name2, #PB_String_NoCase) * *Gadget\SortDirection ; PB is case insensitive
EndIf
If *Gadget\SortColumn = *Gadget\ExtraColumns ; Name column
ProcedureReturn NameResult
ElseIf *Gadget\SortColumn = *Gadget\ExtraColumns+1 ; value column
; Spechial thing for the Watchlist. List all out of scope values at the end
If *entry1\Value$ = "---"
If *entry2\Value$ <> "---"
ProcedureReturn 1
EndIf
ElseIf *entry2\Value$ = "---"
ProcedureReturn -1
EndIf
; sort first by type, then by value
Type1 = VariableGadget_SortType(*entry1\Type)
Type2 = VariableGadget_SortType(*entry2\Type)
If Type1 <> Type2
ProcedureReturn (Type1 - Type2) * *Gadget\SortDirection
ElseIf Type1 = #SORTTYPE_Structure ; structure. compare structure types
Struct1$ = StringField(*entry1\Name,ドル 2, ".")
Struct2$ = StringField(*entry2\Name,ドル 2, ".")
Result = CompareMemoryString(@Struct1,ドル @Struct2,ドル #PB_String_NoCase) * *Gadget\SortDirection
If Result = 0
ProcedureReturn NameResult
Else
ProcedureReturn Result
EndIf
ElseIf *entry1\Value$ = *entry2\Value$ Or Type1 = #SORTTYPE_Unknown ; equal values, use name then
ProcedureReturn NameResult
ElseIf Type1 <= #SORTTYPE_Pointer ; integer types
If VariableIsHex
Quad1.q = Val("$" + *entry1\Value$)
Quad2.q = Val("$" + *entry2\Value$)
Else
Quad1.q = Val(*entry1\Value$)
Quad2.q = Val(*entry2\Value$)
EndIf
; cannot just do "ProcedureReturn Quad1-Quad2" as that could exceed the returnvalue size on x86
If Quad1 = Quad2
ProcedureReturn 0
ElseIf Quad1 < Quad2
ProcedureReturn (-1) * *Gadget\SortDirection
Else
ProcedureReturn *Gadget\SortDirection
EndIf
ElseIf Type1 <= #SORTTYPE_Double ; float types
Double1.d = ValD(*entry1\Value$)
Double2.d = ValD(*entry2\Value$)
If Double1 = Double2
ProcedureReturn 0
ElseIf Double1 < Double2
ProcedureReturn (-1) * *Gadget\SortDirection
Else
ProcedureReturn *Gadget\SortDirection
EndIf
Else ; string types
ProcedureReturn CompareMemoryString(@*entry1\Value,ドル @*entry2\Value$) * *Gadget\SortDirection ; use case sensitive here
EndIf
Else ; any of the extra columns
Extra1$ = StringField(*entry1\Extra,ドル *Gadget\SortColumn+1, Chr(10))
Extra2$ = StringField(*entry2\Extra,ドル *Gadget\SortColumn+1, Chr(10))
Result = CompareMemoryString(@Extra1,ドル @Extra2,ドル #PB_String_NoCase)
If Result = #PB_String_Equal
ProcedureReturn NameResult
Else
ProcedureReturn Result * *Gadget\SortDirection
EndIf
EndIf
Else
; at least one is not a toplevel one
; find the index of the toplevel item for both items
topindex1 = index1
While *items\item[topindex1]\Parent <> -1
topindex1 = *items\item[topindex1]\Parent
Wend
topindex2 = index2
While *items\item[topindex2]\Parent <> -1
topindex2 = *items\item[topindex2]\Parent
Wend
If topindex1 = topindex2
; both are in the same toplevel node, so just compare by index to keep the
; structures correct (do not apply sort direction)
; this also applies if one entry is the direct parent of the other
ProcedureReturn index1 - index2
Else
; both are in different toplevel nodes. compare these
ProcedureReturn VariableGadget_Compare(*Gadget, topindex1, topindex2)
EndIf
EndIf
ProcedureReturn Result
EndProcedure
; Platform specific sort implementation stuff
;
CompilerIf #CompileWindows
Structure ListIconData ; LPARAM data structure for ListIconGadget
UserData.i
EndStructure
Procedure VariableGadget_SortProc(*data1.ListIconData, *data2.ListIconData, *Gadget.VariableGadget)
If *data1 = 0 Or *data2 = 0
ProcedureReturn 0 ; this may not happen, as we use SetGadgetItemData() to set all index values
Else
ProcedureReturn VariableGadget_Compare(*Gadget, *data1\UserData, *data2\UserData)
EndIf
EndProcedure
Procedure VariableGadget_ParentCallback(Window, Message, wParam, lParam)
Callback = GetProp_(Window, "Variable_Callback")
If Message = #WM_NCDESTROY
; remove our prop, this is the last message, so no problem
RemoveProp_(Window, "Variable_Callback")
ElseIf Message = #WM_NOTIFY
*nmv.NM_LISTVIEW = lParam
If *nmv\hdr\code = #LVN_COLUMNCLICK
; find the right gadget (if it is a variablegadget at all)
ForEach VariableGadget_List()
If *nmv\hdr\hwndFrom = GadgetID(VariableGadget_List()\Gadget)
; set new column/direction
If VariableGadget_List()\SortColumn = *nmv\iSubItem
VariableGadget_List()\SortDirection * -1
Else
VariableGadget_List()\SortColumn = *nmv\iSubItem
VariableGadget_List()\SortDirection = 1
EndIf
; sort
SendMessage_(*nmv\hdr\hwndFrom, #LVM_SORTITEMS, @VariableGadget_List(), @VariableGadget_SortProc())
SetSortArrow(VariableGadget_List()\Gadget, VariableGadget_List()\SortColumn, VariableGadget_List()\SortDirection)
ProcedureReturn 0
EndIf
Next VariableGadget_List()
EndIf
EndIf
If Callback
ProcedureReturn CallWindowProc_(Callback, Window, Message, wParam, lParam)
Else
ProcedureReturn DefWindowProc_(Window, Message, wParam, lParam)
EndIf
EndProcedure
CompilerEndIf
CompilerIf 0;#CompileMac
Global ItemCompareUPP
;
; Problem with this implementation:
; The sorting itself works well here, but structured items do not work, as we cannot ensure that they are always sorted top-down
; as on Windows. The reason is that we have no control over the SortDirection. OSX just asks us to order the items, but the direction
; is handled by the DataBrowser. There is no re-sort when simply reversing items in the list, as OSX caches the sort information.
; Because of this, we cannot swap structure items if the sort order changes to remain top-down. So in the end, when sorting
; bottom-up, structures get reversed in the view.
;
; The only solution to this is to have real containers in the DataBrowser which means customly implement the whole gadget for the IDE. :(
;
#kDataBrowserOrderIncreasing = 1
#kDataBrowserOrderDecreasing = 2
#kDataBrowserListViewSortableColumn = 1 << (16 + 2)
; To get the PB GadgetID from the ControlRef
ImportC ""
PB_Gadget_GetProperty(Gadget, Property)
EndImport
#ID_Property = 'ID'
; Must return true if itemOne < itemTwo, and false if itemOne >= itemTwo
;
ProcedureC VariableGadget_ItemCompareCallback(Gadget, itemOne, itemTwo, sortProperty)
GadgetID = PB_Gadget_GetProperty(Gadget, #ID_Property)
*Gadget.VariableGadget = GetGadgetData(GadgetID)
RealIndex1 = GetGadgetItemData(GadgetID, itemOne-1) ; The itemID values are the index+1 on OSX
RealIndex2 = GetGadgetItemData(GadgetID, itemTwo-1)
; Find out the ColumnIndex which is being sorted
; Note: There is a separate image column, as the VAriableGadget always includes images
SortColumn = -1
For i = 1 To *Gadget\ExtraColumns+2
If GetDataBrowserTableViewColumnProperty_(Gadget, i, @ColumnProperty) = #noErr
If ColumnProperty = sortProperty
SortColumn = i-1
Break
EndIf
EndIf
Next i
; Update the Column+Direction in the structure so the compare function knows them, and a future
; VariableGadget_Sort() uses the correct data
;
SortDirection = #kDataBrowserOrderIncreasing ; fallback
;GetDataBrowserSortOrder_(Gadget, @SortDirection)
*Gadget\SortColumn = SortColumn
If SortDirection = #kDataBrowserOrderIncreasing
*Gadget\SortDirection = 1
Else
*Gadget\SortDirection = -1
EndIf
; Note: The callback always should not take the direction into account (the Gadget does that),
; so in case of decreasing sort, we must reverse the result to get the correct output.
; We cannot just have SortDirection fixed at 1, as structures are treated specially (always by index),
; so they come out wrong if the compare function is not aware of the true direction
;
If SortColumn = -1
ProcedureReturn #False ; return >= (should never happen)
ElseIf (VariableGadget_Compare(*Gadget, RealIndex1, RealIndex2) * *Gadget\SortDirection) < 0
ProcedureReturn #True ; <
Else
ProcedureReturn #False ; >=
EndIf
EndProcedure
CompilerEndIf
; Sort the entire gadget with the given settings
; Does nothing if SortColumn=-1, so this can be called after all changes
;
Procedure VariableGadget_Sort(Gadget)
*Gadget.VariableGadget = GetGadgetData(Gadget)
CompilerIf #CompileWindows
If *Gadget\SortColumn <> -1
SendMessage_(GadgetID(Gadget), #LVM_SORTITEMS, *Gadget, @VariableGadget_SortProc())
EndIf
SetSortArrow(Gadget, *Gadget\SortColumn, *Gadget\SortDirection)
CompilerEndIf
CompilerIf #CompileMac
; Even though OSX takes care of most of the sorting stuff itself (column arrow etc), we still must
; re-initiate a sort after we made changes, because the PB ListIconGadget always adds items at the end
; and only maps the internal linkedlist through the data callback, so a single AddGadgetItem() in the middle
; messes up the cached sort data that OSX seems to be keeping
;
; If *Gadget\SortColumn <> -1
; ; +1, as the VariableGadget always has an image column!
; If GetDataBrowserTableViewColumnProperty_(GadgetID(Gadget), *Gadget\SortColumn+1, @SortColumnID) = #noErr
; SetDataBrowserSortProperty_(GadgetID(Gadget), SortColumnID)
; If *Gadget\SortDirection > 0
; SetDataBrowserSortOrder_(GadgetID(Gadget), #kDataBrowserOrderIncreasing)
; Else
; SetDataBrowserSortOrder_(GadgetID(Gadget), #kDataBrowserOrderDecreasing)
; EndIf
; EndIf
; EndIf
CompilerEndIf
EndProcedure
; creates a new gadget
; returns the result of ListIconGadget()
; so you can use the result with ResizeGadget(), HideGadget(), etc, but also
; with the VariableGadget_...() functions
Procedure VariableGadget_Create(Gadget, x, y, Width, Height, ExtraColumn,ドル DefaultSort, IndexSort)
Static IsInitialized
If IsInitialized = 0
VariableGadget_Icons(#TYPE_BYTE) = VariableGadget_CatchIcon(?VariableGadget_Byte)
VariableGadget_Icons(#TYPE_WORD) = VariableGadget_CatchIcon(?VariableGadget_Word)
VariableGadget_Icons(#TYPE_LONG) = VariableGadget_CatchIcon(?VariableGadget_Long)
VariableGadget_Icons(#TYPE_STRUCTURE) = VariableGadget_CatchIcon(?VariableGadget_Struct)
VariableGadget_Icons(#TYPE_STRING) = VariableGadget_CatchIcon(?VariableGadget_String)
VariableGadget_Icons(#TYPE_FLOAT) = VariableGadget_CatchIcon(?VariableGadget_Float)
VariableGadget_Icons(#TYPE_FIXEDSTRING)= VariableGadget_CatchIcon(?VariableGadget_Fixed)
VariableGadget_Icons(#TYPE_CHARACTER) = VariableGadget_CatchIcon(?VariableGadget_Char)
VariableGadget_Icons(#TYPE_DOUBLE) = VariableGadget_CatchIcon(?VariableGadget_Double)
VariableGadget_Icons(#TYPE_QUAD) = VariableGadget_CatchIcon(?VariableGadget_Quad)
VariableGadget_Icons(#TYPE_INTEGER) = VariableGadget_CatchIcon(?VariableGadget_Integer)
VariableGadget_Icons(#TYPE_ASCII) = VariableGadget_CatchIcon(?VariableGadget_Ascii)
VariableGadget_Icons(#TYPE_UNICODE) = VariableGadget_CatchIcon(?VariableGadget_Unicode)
VariableGadget_NodeOpen = VariableGadget_CatchIcon(?VariableGadget_NodeOpen)
VariableGadget_NodeClose = VariableGadget_CatchIcon(?VariableGadget_NodeClose)
IsInitialized = 1
EndIf
If AddElement(VariableGadget_List())
If ExtraColumn$ <> ""
Result = ListIconGadget(Gadget, x, y, Width, Height, StringField(ExtraColumn,ドル 1, Chr(10)), 100, #PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
If Gadget = #PB_Any
VariableGadget_List()\Gadget = Result
Else
VariableGadget_List()\Gadget = Gadget
EndIf
ExtraColumns = 1
While StringField(ExtraColumn,ドル ExtraColumns+1, Chr(10)) <> ""
AddGadgetColumn(VariableGadget_List()\Gadget, ExtraColumns, StringField(ExtraColumn,ドル ExtraColumns+1, Chr(10)), 100)
ExtraColumns + 1
Wend
AddGadgetColumn(VariableGadget_List()\Gadget, ExtraColumns, Language("Debugger","Name"), 200)
AddGadgetColumn(VariableGadget_List()\Gadget, ExtraColumns+1, Language("Debugger","Value"), 800)
VariableGadget_List()\ExtraColumns = ExtraColumns
Else
Result = ListIconGadget(Gadget, x, y, Width, Height, Language("Debugger","Name"), 200, #PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
If Gadget = #PB_Any
VariableGadget_List()\Gadget = Result
Else
VariableGadget_List()\Gadget = Gadget
EndIf
AddGadgetColumn(VariableGadget_List()\Gadget, 1, Language("Debugger","Value"), 800)
VariableGadget_List()\ExtraColumns = 0
EndIf
VariableGadget_List()\IndexSort = IndexSort
If DefaultSort
VariableGadget_List()\SortColumn = VariableGadget_List()\ExtraColumns
VariableGadget_List()\SortDirection = 1
Else
VariableGadget_List()\SortColumn = -1
EndIf
; Setup Header click monitoring for the sort
;
CompilerIf #CompileWindows
Parent = GetParent_(GadgetID(VariableGadget_List()\Gadget))
If GetProp_(Parent, "Variable_Callback") = 0 ; no monitoring callback yet
SetProp_(Parent, @"Variable_Callback", SetWindowLongPtr_(Parent, #GWL_WNDPROC, @VariableGadget_ParentCallback()))
EndIf
CompilerEndIf
; Setup the sort callback for OSX
;
CompilerIf #CompileMac
; If ItemCompareUPP = 0
; ItemCompareUPP = NewDataBrowserItemCompareUPP_(@VariableGadget_ItemCompareCallback())
; EndIf
;
; If ItemCompareUPP
; ; add our sort callback to the listicon's callbacks
; Callbacks.DataBrowserCallbacks\version = #kDataBrowserLatestCallbacks ; in MacExtensions.pb
;
; If GetDataBrowserCallbacks_(GadgetID(VariableGadget_List()\Gadget), @Callbacks) = #noErr
; Callbacks\itemCompareCallback = ItemCompareUPP
; SetDataBrowserCallbacks_(GadgetID(VariableGadget_List()\Gadget), @Callbacks)
; EndIf
;
; ; set all columns to sortable
; For i = 0 To VariableGadget_List()\ExtraColumns+1 ; the ImageColumn is only present after the first AddGadgetItem
; If GetDataBrowserTableViewColumnProperty_(GadgetID(VariableGadget_List()\Gadget), i, @ColumnProperty) = #noErr
; If GetDataBrowserPropertyFlags_(GadgetID(VariableGadget_List()\Gadget), ColumnProperty, @PropertyFlags) = #noErr
; PropertyFlags | #kDataBrowserListViewSortableColumn
; SetDataBrowserPropertyFlags_(GadgetID(VariableGadget_List()\Gadget), ColumnProperty, PropertyFlags)
; EndIf
; EndIf
; Next i
; EndIf
CompilerEndIf
SetGadgetData(VariableGadget_List()\Gadget, @VariableGadget_List())
ProcedureReturn Result
Else
ProcedureReturn 0
EndIf
EndProcedure
; use this instead of "FreeGadget()" so that the item list is properly freed
;
Procedure VariableGadget_Free(Gadget)
*VariableGadget.VariableGadget = GetGadgetData(Gadget)
ChangeCurrentElement(VariableGadget_List(), *VariableGadget)
If VariableGadget_List()\Items
*items.VariableGadget_ItemList = VariableGadget_List()\Items
For i = 0 To VariableGadget_List()\ItemCount-1
FreePBString(@*items\item[i]\Name$)
FreePBString(@*items\item[i]\Value$)
FreePBString(@*items\item[i]\Extra$)
Next i
FreeMemory(VariableGadget_List()\Items)
EndIf
FreeGadget(Gadget)
DeleteElement(VariableGadget_List())
EndProcedure
; Lock variablegadget display updates (to speed up inserting)
; You MUST NOT call SetGadgetState() on the gadget while it is locked! (Linux thing)
;
; This also locks the processing of VariableGadget_Event(), so there is no accidental
; expand done while not all items are added to the gadget.
;
Procedure VariableGadget_Lock(Gadget)
*VariableGadget.VariableGadget = GetGadgetData(Gadget)
*VariableGadget\IsLocked = #True
CompilerIf #CompileWindows
SendMessage_(GadgetID(Gadget), #WM_SETREDRAW, #False, 0)
CompilerEndIf
CompilerIf #CompileLinuxGtk
*VariableGadget.VariableGadget = GetGadgetData(Gadget)
*VariableGadget\TreeModel = gtk_tree_view_get_model_(GadgetID(Gadget))
g_object_ref_(*VariableGadget\TreeModel) ; must be ref'ed or it is destroyed
gtk_tree_view_set_model_(GadgetID(Gadget), #Null) ; disconnect the model for a faster update
CompilerEndIf
EndProcedure
Procedure VariableGadget_Unlock(Gadget)
*VariableGadget.VariableGadget = GetGadgetData(Gadget)
*VariableGadget\IsLocked = #False
CompilerIf #CompileWindows
SendMessage_(GadgetID(Gadget), #WM_SETREDRAW, #True, 0)
InvalidateRect_(GadgetID(Gadget), #Null, #True);
CompilerEndIf
CompilerIf #CompileLinuxGtk
*VariableGadget.VariableGadget = GetGadgetData(Gadget)
gtk_tree_view_set_model_(GadgetID(Gadget), *VariableGadget\TreeModel) ; reconnect the model
g_object_unref_(*VariableGadget\TreeModel) ; release reference
CompilerEndIf
EndProcedure
; Get the Chr(10) separated text for an item in the VariableGadget
; (handles Array, List, Map stuff)
;
Procedure.s VariableGadget_EntryText(*VariableGadget.VariableGadget, realindex)
*items.VariableGadget_ItemList = *VariableGadget\Items
Text$ = *items\item[realindex]\Extra$ + *items\item[realindex]\Name$
Select *items\item[realindex]\Kind
Case #TYPE_ARRAY
; For Arrays, we include the dimensions (in Value$)
; directly on the name because it just looks better
Text$ + "(" + *items\item[realindex]\Value$ + ")"
Case #TYPE_LINKEDLIST, #TYPE_MAP
; For List, Map we set the info in the Value column, but add the ()
Text$ + "()" + Chr(10) + *items\item[realindex]\Value$
Default
; Normal item
Text$ + Chr(10) + *items\item[realindex]\Value$
EndSelect
ProcedureReturn Text$
EndProcedure
; you MUST call this for every event you receive for the gadget
;
Procedure VariableGadget_Event(Gadget)
DoSort = 0
If EventType() = #PB_EventType_LeftDoubleClick
index = GetGadgetState(Gadget)
If index <> -1
*VariableGadget.VariableGadget = GetGadgetData(Gadget)
ChangeCurrentElement(VariableGadget_List(), *VariableGadget)
If VariableGadget_List()\IsLocked = #False And VariableGadget_List()\Items
*items.VariableGadget_ItemList = VariableGadget_List()\Items
realindex = GetGadgetItemData(Gadget, index)
indexbefore = index
VariableGadget_Lock(Gadget)
If *items\item[realindex]\Node = 1
RemoveGadgetItem(Gadget, index) ; re-add this item to change the image
AddGadgetItem(Gadget, index, VariableGadget_EntryText(*VariableGadget, realindex), ImageID(VariableGadget_NodeClose))
SetGadgetItemData(Gadget, index, realindex)
*items\item[realindex]\Node = 2
sublevel = *items\item[realindex]\Sublevel
index + 1
realindex + 1
While realindex < VariableGadget_List()\ItemCount And *items\item[realindex]\sublevel > sublevel
If *items\item[realindex]\Node = 1
AddGadgetItem(Gadget, index, VariableGadget_EntryText(*VariableGadget, realindex), ImageID(VariableGadget_NodeOpen))
SetGadgetItemData(Gadget, index, realindex)
index + 1
; skip node contents
sublevel2 = *items\item[realindex]\Sublevel
realindex + 1
While realindex < VariableGadget_List()\ItemCount And *items\item[realindex]\sublevel > sublevel2
realindex + 1
Wend
Else
If *items\item[realindex]\Node = 2
Image = VariableGadget_NodeClose
Else
Image = VariableGadget_Icons(*items\item[realindex]\Type & #TYPEMASK)
EndIf
AddGadgetItem(Gadget, index, VariableGadget_EntryText(*VariableGadget, realindex), ImageID(Image))
SetGadgetItemData(Gadget, index, realindex)
index + 1
realindex + 1
EndIf
Wend
DoSort = 1
ElseIf *items\item[realindex]\Node = 2
RemoveGadgetItem(Gadget, index) ; re-add this item to change the image
AddGadgetItem(Gadget, index, VariableGadget_EntryText(*VariableGadget, realindex), ImageID(VariableGadget_NodeOpen))
SetGadgetItemData(Gadget, index, realindex)
*items\item[realindex]\Node = 1
sublevel = *items\item[realindex]\Sublevel
index + 1
realindex + 1
While realindex < VariableGadget_List()\ItemCount And *items\item[realindex]\sublevel > sublevel
If *items\item[realindex]\Node = 1
RemoveGadgetItem(Gadget, index)
; skip node contents (because they are not visible in the gadget)
sublevel2 = *items\item[realindex]\Sublevel
realindex + 1
While realindex < VariableGadget_List()\ItemCount And *items\item[realindex]\sublevel > sublevel2
realindex + 1
Wend
Else
RemoveGadgetItem(Gadget, index)
realindex + 1
EndIf
Wend
EndIf
VariableGadget_Unlock(Gadget)
SetGadgetState(Gadget, indexbefore)
If DoSort
; must be after the SetGadgetState, as the index is wrong else!
VariableGadget_Sort(Gadget)
EndIf
EndIf
EndIf
EndIf
EndProcedure
; this must be called before adding any items to the gadget
; to allocate the space for them
; (it also clears the old gadget item list)
; VariableGadget_Allocate(Gadget, 0) will just clear the gadget
;
Procedure VariableGadget_Allocate(Gadget, NbItems)
*VariableGadget.VariableGadget = GetGadgetData(Gadget)
ChangeCurrentElement(VariableGadget_List(), *VariableGadget)
; free the old variable list
;
If VariableGadget_List()\Items
*items.VariableGadget_ItemList = VariableGadget_List()\Items
For i = 0 To VariableGadget_List()\ItemCount-1
FreePBString(@*items\item[i]\Name$)
FreePBString(@*items\item[i]\Value$)
FreePBString(@*items\item[i]\Extra$)
Next i
FreeMemory(VariableGadget_List()\Items)
VariableGadget_List()\Items = 0
EndIf
; set the current count to 0, and reset parent index
;
VariableGadget_List()\ItemCount = 0
VariableGadget_List()\CurrentParent = -1
VariableGadget_List()\CurrentSublevel = 0
; allocate new space for the items
;
If NbItems > 0
VariableGadget_List()\Items = AllocateMemory(NbItems * SizeOf(VariableGadget_Entry))
EndIf
ClearGadgetItems(Gadget) ; clear the items in the gadget
EndProcedure
; call this function to expand all primary nodes an collapse all others
; (used for array display for example)
;
Procedure VariableGadget_Expand(Gadget)
*VariableGadget.VariableGadget = GetGadgetData(Gadget)
ChangeCurrentElement(VariableGadget_List(), *VariableGadget)
If VariableGadget_List()\Items
ClearGadgetItems(Gadget)
Index = 0
*items.VariableGadget_ItemList = VariableGadget_List()\Items
For i = 0 To VariableGadget_List()\ItemCount-1
If *items\item[i]\sublevel < 2 ; display all items of sublevel 0 and 1
If *items\item[i]\Node <> 0 And *items\item[i]\sublevel = 0
Image = VariableGadget_NodeClose
*items\item[i]\Node = 2
ElseIf *items\item[i]\Node <> 0
Image = VariableGadget_NodeOpen
*items\item[i]\Node = 1
Else
Image = VariableGadget_Icons(*items\item[i]\Type & #TYPEMASK)
EndIf
AddGadgetItem(Gadget, Index, VariableGadget_EntryText(*VariableGadget, i), ImageID(Image))
SetGadgetItemData(Gadget, Index, i)
Index + 1
Else
If *items\item[i]\Node <> 0 ; a node -> set to collapsed
*items\item[i]\Node = 1
EndIf
EndIf
Next i
EndIf
EndProcedure
; this sets the gadget to be used in the following _Add / _Set calls
; this is to speed up the list modification
;
Procedure VariableGadget_Use(Gadget)
Shared *VariableGadget_Used.VariableGadget
*VariableGadget_Used = GetGadgetData(Gadget)
EndProcedure
; add a variable To the gadget
; if *Value is a 0-pointer, the value field will be left empty
;
Procedure VariableGadget_Add(Type, DynamicType, Sublevel, Extra,ドル Name,ドル ModuleName,ドル *Value, Is64bit)
Shared *VariableGadget_Used.VariableGadget
; prefix the module name
If ModuleName$ <> ""
Name$ = ModuleName$ + "::" + Name$
EndIf
If IS_ARRAY(Type) Or IS_LINKEDLIST(Type) Or IS_MAP(Type)
Kind = Type
Type = DynamicType
Else
Kind = 0
EndIf
Type & #IGNORE_PARAM ; remove the "direct param" flag if it is set
index = *VariableGadget_Used\ItemCount
*items.VariableGadget_ItemList = *VariableGadget_Used\Items
; add the separating chr(10) to the extra text
If *VariableGadget_Used\ExtraColumns > 0
If Extra$ = ""
Extra$ = RSet("", *VariableGadget_Used\ExtraColumns, Chr(10))
Else
Extra$ + Chr(10)
EndIf
EndIf
If *items
; find the current parent, if we ended a previous node
While *VariableGadget_Used\CurrentSublevel > Sublevel And *VariableGadget_Used\CurrentParent <> -1
*VariableGadget_Used\CurrentParent = *items\item[*VariableGadget_Used\CurrentParent]\Parent
*VariableGadget_Used\CurrentSublevel - 1
Wend
*VariableGadget_Used\CurrentSublevel = Sublevel
*items\item[index]\Kind = Kind
*items\item[index]\Type = Type
*items\item[index]\Node = 0
*items\item[index]\SubLevel = SubLevel
*items\item[index]\Parent = *VariableGadget_Used\CurrentParent
*items\item[index]\Name$ = Name$
*items\item[index]\Extra$ = Extra$
*items\item[index]\Value$ = ""
If IS_ARRAY(Kind)
If *Value
*items\item[index]\Value$ = PeekAscii(*Value) ; array dimensions
Else
*items\item[index]\Value$ = ""
EndIf
ElseIf IS_LINKEDLIST(Kind)
If *Value
If Is64bit
If PeekQ(*Value) = -1
Size$ = "-"
Else
Size$ = Str(PeekQ(*Value))
EndIf
If PeekQ(*Value+8) = -1
Current$ = "-"
Else
Current$ = Str(PeekQ(*Value+8))
EndIf
Else
If PeekL(*Value) = -1
Size$ = "-"
Else
Size$ = Str(PeekL(*Value))
EndIf
If PeekL(*Value+4) = -1
Current$ = "-"
Else
Current$ = Str(PeekL(*Value+4))
EndIf
EndIf
*items\item[index]\Value$ = Language("Debugger","Size") + ": " + Size$ + " " + Language("Debugger","Current") + ": " + Current$
Else
*items\item[index]\Value$ = ""
EndIf
ElseIf IS_MAP(Kind)
If *Value
*items\item[index]\Value$ = Language("Debugger", "Size")+": "
If Is64bit
If PeekQ(*Value) = -1
*items\item[index]\Value$ + "-"
Else
*items\item[index]\Value$ + Str(PeekQ(*Value))
EndIf
*Value + 8
Else
If PeekL(*Value) = -1
*items\item[index]\Value$ + "-"
Else
*items\item[index]\Value$ + Str(PeekL(*Value))
EndIf
*Value + 4
EndIf
*items\item[index]\Value$ + " " + Language("Debugger","Current")+": "
If PeekB(*Value) ; IsCurrent
*items\item[index]\Value$ + Chr(34)+PeekS(*Value+1)+Chr(34) ; in external debugger format
Else
*items\item[index]\Value$ + "-"
EndIf
Else
*items\item[index]\Value$ = ""
EndIf
ElseIf IS_POINTER(Type)
*items\item[index]\Name$ = "*" + *items\item[index]\Name$
If *Value
If Is64bit And VariableIsHex
*items\item[index]\Value$ = Hex(PeekQ(*Value), #PB_Quad)
ElseIf Is64bit
*items\item[index]\Value$ = Str(PeekQ(*Value))
ElseIf VariableIsHex
*items\item[index]\Value$ = Hex(PeekL(*Value), #PB_Long)
Else
*items\item[index]\Value$ = Str(PeekL(*Value))
EndIf
EndIf
Else ; not a pointer
If Type = #TYPE_STRUCTURE ; structure, not a pointer
*items\item[index]\Node = 1
*VariableGadget_Used\CurrentParent = index ; this is the new parent
ElseIf *Value
Select Type & #TYPEMASK
Case #TYPE_BYTE
If VariableIsHex
*items\item[index]\Value$ = Hex(PeekB(*Value), #PB_Byte)
Else
*items\item[index]\Value$ = Str(PeekB(*Value))
EndIf
Case #TYPE_ASCII
If VariableIsHex
*items\item[index]\Value$ = Hex(PeekB(*Value) & $FF) ; todo
Else
*items\item[index]\Value$ = Str(PeekB(*Value) & $FF)
EndIf
Case #TYPE_UNICODE
If VariableIsHex
*items\item[index]\Value$ = Hex(PeekW(*Value) & $FFFF) ; todo
Else
*items\item[index]\Value$ = Str(PeekW(*Value) & $FFFF)
EndIf
Case #TYPE_WORD
If VariableIsHex
*items\item[index]\Value$ = Hex(PeekW(*Value), #PB_Word)
Else
*items\item[index]\Value$ = Str(PeekW(*Value))
EndIf
Case #TYPE_LONG, #TYPE_CHARACTER ; chars are passed as longs
If VariableIsHex
*items\item[index]\Value$ = Hex(PeekL(*Value), #PB_Long)
Else
*items\item[index]\Value$ = Str(PeekL(*Value))
EndIf
Case #TYPE_STRING, #TYPE_FIXEDSTRING
*items\item[index]\Value$ = Chr(34) + PeekS(*Value) + Chr(34)
Case #TYPE_FLOAT
*items\item[index]\Value$ = StrF_Debug(PeekF(*Value))
Case #TYPE_DOUBLE
*items\item[index]\Value$ = StrD_Debug(PeekD(*Value))
Case #TYPE_QUAD
If VariableIsHex
*items\item[index]\Value$ = Hex(PeekQ(*Value), #PB_Quad)
Else
*items\item[index]\Value$ = Str(PeekQ(*Value))
EndIf
Case #TYPE_INTEGER
If Is64bit And VariableIsHex
*items\item[index]\Value$ = Hex(PeekQ(*Value), #PB_Quad)
ElseIf Is64bit
*items\item[index]\Value$ = Str(PeekQ(*Value))
ElseIf VariableIsHex
*items\item[index]\Value$ = Hex(PeekL(*Value), #PB_Long)
Else
*items\item[index]\Value$ = Str(PeekL(*Value))
EndIf
EndSelect
EndIf
EndIf
If Sublevel = 0 ; only the main level is visible when adding!
If *items\item[index]\Node = 1
Image = VariableGadget_NodeOpen
Else
Image = VariableGadget_Icons(Type & #TYPEMASK)
EndIf
gadgetindex = CountGadgetItems(*VariableGadget_Used\Gadget)
AddGadgetItem(*VariableGadget_Used\Gadget, gadgetindex, VariableGadget_EntryText(*VariableGadget_Used, index), ImageID(Image))
SetGadgetItemData(*VariableGadget_Used\Gadget, gadgetindex, index)
EndIf
*items\item[index]\Name$ = Space(SubLevel * 3) + *items\item[index]\Name$
*VariableGadget_Used\ItemCount + 1
EndIf
EndProcedure
; After a number of VariableGadget_Set() with AutoSync=#False, call this
; to update the entire gadget content. (Use this when updating the whole list anyway)
;
Procedure VariableGadget_SyncAll()
Shared *VariableGadget_Used.VariableGadget
*items.VariableGadget_ItemList = *VariableGadget_Used\Items
If *items
Gadget = *VariableGadget_Used\Gadget
Last = CountGadgetItems(Gadget) - 1
For i = 0 To Last
index = GetGadgetItemData(Gadget, i)
If *items\item[index]\Kind = #TYPE_ARRAY
; special handling for array type
SetGadgetItemText(Gadget, i, *items\item[index]\Name$ + "(" + *items\item[index]\Value$ + ")", *VariableGadget_Used\ExtraColumns)
Else
SetGadgetItemText(Gadget, i, *items\item[index]\Value,ドル *VariableGadget_Used\ExtraColumns+1)
EndIf
Next i
EndIf
EndProcedure
; Called internally: Sync only a single item to the gadget display
;
; NOTE: This is slow for gadgets with a large number of items, that's why
; only the watchlist actually uses it. (The VariableViewer does SyncAll())
;
Procedure VariableGadget_SyncItem(ListIndex)
Shared *VariableGadget_Used.VariableGadget
*items.VariableGadget_ItemList = *VariableGadget_Used\Items
If *items
Gadget = *VariableGadget_Used\Gadget
Last = CountGadgetItems(Gadget) - 1
For i = 0 To Last
index = GetGadgetItemData(Gadget, i)
If index = ListIndex ; found the item
If *items\item[index]\Kind = #TYPE_ARRAY
; special handling for array type
SetGadgetItemText(Gadget, i, *items\item[index]\Name$ + "(" + *items\item[index]\Value$ + ")", *VariableGadget_Used\ExtraColumns)
Else
SetGadgetItemText(Gadget, i, *items\item[index]\Value,ドル *VariableGadget_Used\ExtraColumns+1)
EndIf
Break
EndIf
Next i
EndIf
EndProcedure
; set the value for the given variable
; (a 0-pointer for *Value empties the field)
;
; AutoSync: If true, directly update the gadget display, if false
; this has to be done manually with SyncAll() or SyncItem()
;
Procedure VariableGadget_Set(index, *Value, Is64bit, AutoSync)
Shared *VariableGadget_Used.VariableGadget
*items.VariableGadget_ItemList = *VariableGadget_Used\Items
If *items And index < *VariableGadget_Used\ItemCount And *Value
Type = *items\item[index]\Type
If IS_ARRAY(*items\item[index]\Kind)
*items\item[index]\Value$ = PeekAscii(*Value) ; dimensions
ElseIf IS_LINKEDLIST(*items\item[index]\Kind)
If Is64bit
If PeekQ(*Value) = -1
Size$ = "-"
Else
Size$ = Str(PeekQ(*Value))
EndIf
If PeekQ(*Value+8) = -1
Current$ = "-"
Else
Current$ = Str(PeekQ(*Value+8))
EndIf
Else
If PeekL(*Value) = -1
Size$ = "-"
Else
Size$ = Str(PeekL(*Value))
EndIf
If PeekL(*Value+4) = -1
Current$ = "-"
Else
Current$ = Str(PeekL(*Value+4))
EndIf
EndIf
*items\item[index]\Value$ = Language("Debugger","Size") + ": " + Size$ + " " + Language("Debugger","Current") + ": " + Current$
ElseIf IS_MAP(*items\item[index]\Kind)
*items\item[index]\Value$ = Language("Debugger", "Size")+": "
If Is64bit
If PeekQ(*Value) = -1
*items\item[index]\Value$ + "-"
Else
*items\item[index]\Value$ + Str(PeekQ(*Value))
EndIf
*Value + 8
Else
If PeekL(*Value) = -1
*items\item[index]\Value$ + "-"
Else
*items\item[index]\Value$ + Str(PeekL(*Value))
EndIf
*Value + 4
EndIf
*items\item[index]\Value$ + " " + Language("Debugger","Current")+": "
If PeekB(*Value) ; IsCurrent
*items\item[index]\Value$ + Chr(34)+PeekS(*Value+1)+Chr(34) ; in external debugger format
Else
*items\item[index]\Value$ + "-"
EndIf
ElseIf IS_POINTER(Type)
If Is64bit And VariableIsHex
*items\item[index]\Value$ = Hex(PeekQ(*Value), #PB_Quad)
ElseIf Is64bit
*items\item[index]\Value$ = Str(PeekQ(*Value))
ElseIf VariableIsHex
*items\item[index]\Value$ = Hex(PeekL(*Value), #PB_Long)
Else
*items\item[index]\Value$ = Str(PeekL(*Value))
EndIf
Else
Select Type & #TYPEMASK
Case #TYPE_BYTE
If VariableIsHex
*items\item[index]\Value$ = Hex(PeekB(*Value), #PB_Byte)
Else
*items\item[index]\Value$ = Str(PeekB(*Value))
EndIf
Case #TYPE_ASCII
If VariableIsHex
*items\item[index]\Value$ = Hex(PeekB(*Value) & $FF)
Else
*items\item[index]\Value$ = Str(PeekB(*Value) & $FF)
EndIf
Case #TYPE_UNICODE
If VariableIsHex
*items\item[index]\Value$ = Hex(PeekW(*Value) & $FFFF)
Else
*items\item[index]\Value$ = Str(PeekW(*Value) & $FFFF)
EndIf
Case #TYPE_WORD
If VariableIsHex
*items\item[index]\Value$ = Hex(PeekW(*Value), #PB_Word)
Else
*items\item[index]\Value$ = Str(PeekW(*Value))
EndIf
Case #TYPE_LONG, #TYPE_CHARACTER ; chars are passed as longs
If VariableIsHex
*items\item[index]\Value$ = Hex(PeekL(*Value), #PB_Long)
Else
*items\item[index]\Value$ = Str(PeekL(*Value))
EndIf
Case #TYPE_STRING, #TYPE_FIXEDSTRING
*items\item[index]\Value$ = Chr(34) + PeekS(*Value) + Chr(34)
Case #TYPE_FLOAT
*items\item[index]\Value$ = StrF_Debug(PeekF(*Value))
Case #TYPE_DOUBLE
*items\item[index]\Value$ = StrD_Debug(PeekD(*Value))
Case #TYPE_QUAD
If VariableIsHex
*items\item[index]\Value$ = Hex(PeekQ(*Value), #PB_Quad)
Else
*items\item[index]\Value$ = Str(PeekQ(*Value))
EndIf
Case #TYPE_INTEGER
If Is64bit And VariableIsHex
*items\item[index]\Value$ = Hex(PeekQ(*Value), #PB_Quad)
ElseIf Is64bit
*items\item[index]\Value$ = Str(PeekQ(*Value))
ElseIf VariableIsHex
*items\item[index]\Value$ = Hex(PeekL(*Value), #PB_Long)
Else
*items\item[index]\Value$ = Str(PeekL(*Value))
EndIf
EndSelect
EndIf
; update the text if the item is visible
;
If AutoSync
VariableGadget_SyncItem(index)
EndIf
EndIf
EndProcedure
; set the "Value" field of the given variable to the given string
; used to not existing variables (ie out of scope for watchlist)
;
; AutoSync: If true, directly update the gadget display, if false
; this has to be done manually with SyncAll() or SyncItem()
;
Procedure VariableGadget_SetString(index, String,ドル AutoSync)
Shared *VariableGadget_Used.VariableGadget
*items.VariableGadget_ItemList = *VariableGadget_Used\Items
If *items And index < *VariableGadget_Used\ItemCount
*items\item[index]\Value$ = String$
If AutoSync
VariableGadget_SyncItem(index)
EndIf
EndIf
EndProcedure
; get the real index in the data list from the gadget index
;
Procedure VariableGadget_GadgetIndexToReal(Gadget, index)
If index = -1
ProcedureReturn -1
Else
ProcedureReturn GetGadgetItemData(Gadget, index)
EndIf
EndProcedure
; returns the index of the current selected item in the full list
;
Procedure VariableGadget_GetState(Gadget)
index = GetGadgetState(Gadget)
If index = -1
ProcedureReturn -1
Else
ProcedureReturn GetGadgetItemData(Gadget, index)
EndIf
EndProcedure
; countgadgetitems on th virtual item list
;
Procedure VariableGadget_GetCount(Gadget)
*VariableGadget.VariableGadget = GetGadgetData(Gadget)
ProcedureReturn *VariableGadget\ItemCount
EndProcedure
DataSection
VariableGadget_Byte: : IncludeBinary #DEFAULT_DebuggerSource + "Data" + #Separator + "byte.png"
VariableGadget_Word: : IncludeBinary #DEFAULT_DebuggerSource + "Data" + #Separator + "word.png"
VariableGadget_Long: : IncludeBinary #DEFAULT_DebuggerSource + "Data" + #Separator + "long.png"
VariableGadget_Struct: : IncludeBinary #DEFAULT_DebuggerSource + "Data" + #Separator + "struct.png"
VariableGadget_String: : IncludeBinary #DEFAULT_DebuggerSource + "Data" + #Separator + "string.png"
VariableGadget_Float: : IncludeBinary #DEFAULT_DebuggerSource + "Data" + #Separator + "float.png"
VariableGadget_NodeOpen: : IncludeBinary #DEFAULT_DebuggerSource + "Data" + #Separator + "struct1.png"
VariableGadget_NodeClose: : IncludeBinary #DEFAULT_DebuggerSource + "Data" + #Separator + "struct2.png"
VariableGadget_Char: : IncludeBinary #DEFAULT_DebuggerSource + "Data" + #Separator + "char.png"
VariableGadget_Fixed: : IncludeBinary #DEFAULT_DebuggerSource + "Data" + #Separator + "fixed.png"
VariableGadget_Double: : IncludeBinary #DEFAULT_DebuggerSource + "Data" + #Separator + "double.png"
VariableGadget_Quad: : IncludeBinary #DEFAULT_DebuggerSource + "Data" + #Separator + "quad.png"
VariableGadget_Integer: : IncludeBinary #DEFAULT_DebuggerSource + "Data" + #Separator + "integer.png"
VariableGadget_Ascii: : IncludeBinary #DEFAULT_DebuggerSource + "Data" + #Separator + "ascii.png"
VariableGadget_Unicode: : IncludeBinary #DEFAULT_DebuggerSource + "Data" + #Separator + "unicode.png"
EndDataSection
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

PureBasic是由Fantaisie Software所开发的商用BASIC程序语言及集成开发环境。特点是语法简单直接,不依赖运行时库,因此能编译出相当小巧的程序,包含命令列或GUI执行档、DLL等。而且不使用各系统的API,所以有高度的跨平台特性,支持Windows 32/64位元、Linux 32/64位元、Mac OS X、Amiga。
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/PureBasic/purebasic.git
git@gitee.com:PureBasic/purebasic.git
PureBasic
purebasic
PureBASIC
devel
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /