Español : visionengine es la libreria que hice para la lectura de codebar para implementar en cualquier proyecto HMG Harbour
Español : visionengine es la libreria que hice para la lectura de codebar para implementar en cualquier proyecto HMG Harbour
Code: Select all
cBTW := 'BE12121212121'
cUrl := "https://controleerbtwnummer.eu/api/validate/" + cBTW + ".json"
Code: Select all
cBTW := 'BE12121212121'
cUrl := "https://controleerbtwnummer.eu/api/validate/" + cBTW + ".json"
Code: Select all
@ 15,180 HPDFPRINT IMAGE cImage WIDTH 72 HEIGHT 430 TYPE PNG
Code: Select all
@ 15,180 HPDFPRINT IMAGE cImage WIDTH 72 HEIGHT 430 TYPE PNG
Code: Select all
#xcommand @ <nRow> , <nCol> HPDFPRINT IMAGE <cImage> ;
WIDTH <nWidth> ;
HEIGHT <nheight> ;
[ <stretch : STRETCH> ] ;
=> ;
_HMG_HPDF_IMAGE ( <cImage> , <nRow> , <nCol> , <nheight> , <nWidth> , <.stretch.> )
Code: Select all
#xcommand @ <nRow> , <nCol> HPDFPRINT IMAGE <cImage> ;
WIDTH <nWidth> ;
HEIGHT <nheight> ;
[ <stretch : STRETCH> ] ;
=> ;
_HMG_HPDF_IMAGE ( <cImage> , <nRow> , <nCol> , <nheight> , <nWidth> , <.stretch.> )
The GCC developers are proud to announce a new major GCC release, 16.1.
This major release introduces several significant changes, including a shift
in the default C++ standard, the addition of a new language front-end, and
substantial improvements to diagnostic reporting.
The C++ frontend now defaults to the GNU C++20 dialect and the corresponding
parts of the standard library are no longer experimental. Several
C++26 features receive experimental support, including Reflection
(-freflection), Contracts, expansion statements and std::simd.
Support for C23 _BitInt has expanded to more targets, including
RISC-V, ARM, S/390 and LoongArch. The C frontend now supports
counted_by attribution of pointer fields.
The Fortran coarray implementation now supports using shared
memory multithreading on single node machines.
The GNU compiler welcomes support for the Algol68 language with an
experimental compiler frontend, ga68.
GCC diagnostics can now be output in HTML form and the SARIF output
was enhanced with new control flow features. The static analyzer
starts to be usable on small C++ examples.
Link-Time Optimization now supports better handling of toplevel asm
statements with -flto-toplevel-asm-heuristics. Support for
speculative devirtualization has been enhanced to handle general
indirect function calls and more than one speculative target.
Vectorization now supports vectorizing of uncounted loops and has more
robust and efficient handling of early exits and has improved handling
of reductions.
Note:
Some code that compiled successfully with older GCC versions might require
source changes.
The GCC developers are proud to announce a new major GCC release, 16.1.
This major release introduces several significant changes, including a shift
in the default C++ standard, the addition of a new language front-end, and
substantial improvements to diagnostic reporting.
The C++ frontend now defaults to the GNU C++20 dialect and the corresponding
parts of the standard library are no longer experimental. Several
C++26 features receive experimental support, including Reflection
(-freflection), Contracts, expansion statements and std::simd.
Support for C23 _BitInt has expanded to more targets, including
RISC-V, ARM, S/390 and LoongArch. The C frontend now supports
counted_by attribution of pointer fields.
The Fortran coarray implementation now supports using shared
memory multithreading on single node machines.
The GNU compiler welcomes support for the Algol68 language with an
experimental compiler frontend, ga68.
GCC diagnostics can now be output in HTML form and the SARIF output
was enhanced with new control flow features. The static analyzer
starts to be usable on small C++ examples.
Link-Time Optimization now supports better handling of toplevel asm
statements with -flto-toplevel-asm-heuristics. Support for
speculative devirtualization has been enhanced to handle general
indirect function calls and more than one speculative target.
Vectorization now supports vectorizing of uncounted loops and has more
robust and efficient handling of early exits and has improved handling
of reductions.
Note:
Some code that compiled successfully with older GCC versions might require
source changes.
Code: Select all
// Configuración inicial
REQUEST HB_CODEPAGE_ESWIN
REQUEST HB_CODEPAGE_UTF8
hb_cdpSelect( "ESWIN" ) // Primero leemos como español moderno
USE tabla_vieja.dbf SHARED NEW
COPY STRUCTURE TO tabla_nueva.dbf // La nueva estructura
USE tabla_nueva.dbf EXCLUSIVE NEW
SELECT tabla_vieja
DO WHILE !EOF()
SELECT tabla_nueva
APPEND BLANK
// Convertimos campo por campo (ejemplo con un campo 'Nombre')
REPLACE Nombre WITH HB_AnsiToUtf8( tabla_vieja->Nombre )
SELECT tabla_vieja
SKIP
ENDDOCode: Select all
// Configuración inicial
REQUEST HB_CODEPAGE_ESWIN
REQUEST HB_CODEPAGE_UTF8
hb_cdpSelect( "ESWIN" ) // Primero leemos como español moderno
USE tabla_vieja.dbf SHARED NEW
COPY STRUCTURE TO tabla_nueva.dbf // La nueva estructura
USE tabla_nueva.dbf EXCLUSIVE NEW
SELECT tabla_vieja
DO WHILE !EOF()
SELECT tabla_nueva
APPEND BLANK
// Convertimos campo por campo (ejemplo con un campo 'Nombre')
REPLACE Nombre WITH HB_AnsiToUtf8( tabla_vieja->Nombre )
SELECT tabla_vieja
SKIP
ENDDOCode: Select all
#include <hmg.ch>
PROCEDURE MAIN
PRIVATE lIsAdmin := wapi_IsUserAnAdmin()
IF .Not. lIsAdmin .AND. MsgYesNo ( "The application does not run in administrator mode, do you want to run it as an administrator?", "Run As Administrator" )
RunApiAsAdministrator()
RETURN
ENDIF
Msgdebug ( "Does the application run in administrator mode?" , lIsAdmin )
/* rest of prg */
RETURN
Function RunApiAsAdministrator()
ShellExecuteEx( wapi_GetActiveWindow(), 'runas', hb_ProgName(), , , SW_SHOWNORMAL )
Return Nil
#pragma BEGINDUMP
#include "SET_COMPILE_HMG_UNICODE.ch"
#include "HMG_UNICODE.h"
#include <windows.h>
#include <hbapi.h>
#include <shlobj.h>
HB_FUNC( SHELLEXECUTEEX )
{
SHELLEXECUTEINFO SHExecInfo;
ZeroMemory(&SHExecInfo, sizeof(SHExecInfo));
SHExecInfo.cbSize = sizeof(SHExecInfo);
SHExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
SHExecInfo.hwnd = HB_ISNIL( 1 ) ? GetActiveWindow() : (HWND) HMG_parnl( 1 );
SHExecInfo.lpVerb = (LPCSTR) HMG_parc( 2 );
SHExecInfo.lpFile = (LPCSTR) HMG_parc( 3 );
SHExecInfo.lpParameters = (LPCSTR) HMG_parc( 4 );
SHExecInfo.lpDirectory = (LPCSTR) HMG_parc( 5 );
SHExecInfo.nShow = hb_parni( 6 );
if( ShellExecuteEx(&SHExecInfo) )
{
// hb_retnl( (LONG) SHExecInfo.hProcess );
CloseHandle(SHExecInfo.hProcess);
}
}
#pragma ENDDUMP
Code: Select all
#include <hmg.ch>
PROCEDURE MAIN
PRIVATE lIsAdmin := wapi_IsUserAnAdmin()
IF .Not. lIsAdmin .AND. MsgYesNo ( "The application does not run in administrator mode, do you want to run it as an administrator?", "Run As Administrator" )
RunApiAsAdministrator()
RETURN
ENDIF
Msgdebug ( "Does the application run in administrator mode?" , lIsAdmin )
/* rest of prg */
RETURN
Function RunApiAsAdministrator()
ShellExecuteEx( wapi_GetActiveWindow(), 'runas', hb_ProgName(), , , SW_SHOWNORMAL )
Return Nil
#pragma BEGINDUMP
#include "SET_COMPILE_HMG_UNICODE.ch"
#include "HMG_UNICODE.h"
#include <windows.h>
#include <hbapi.h>
#include <shlobj.h>
HB_FUNC( SHELLEXECUTEEX )
{
SHELLEXECUTEINFO SHExecInfo;
ZeroMemory(&SHExecInfo, sizeof(SHExecInfo));
SHExecInfo.cbSize = sizeof(SHExecInfo);
SHExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
SHExecInfo.hwnd = HB_ISNIL( 1 ) ? GetActiveWindow() : (HWND) HMG_parnl( 1 );
SHExecInfo.lpVerb = (LPCSTR) HMG_parc( 2 );
SHExecInfo.lpFile = (LPCSTR) HMG_parc( 3 );
SHExecInfo.lpParameters = (LPCSTR) HMG_parc( 4 );
SHExecInfo.lpDirectory = (LPCSTR) HMG_parc( 5 );
SHExecInfo.nShow = hb_parni( 6 );
if( ShellExecuteEx(&SHExecInfo) )
{
// hb_retnl( (LONG) SHExecInfo.hProcess );
CloseHandle(SHExecInfo.hProcess);
}
}
#pragma ENDDUMP
Attachments
Attachments
Gracias, estoy haciendo la traduccion del ide como estaba en el viejo IDE
Gracias, estoy haciendo la traduccion del ide como estaba en el viejo IDE
Attachments
HMG_IDE_SourceCode.rar (257.54 KiB)Attachments
HMG_IDE_SourceCode.rar (257.54 KiB)Code: Select all
// Dom.prg
#include "hmg.ch"
#include "IDE_Unicode.ch"
// ============================================================================
// IDE UNICODE v0.12
// DOM CORE ENGINE
// ============================================================================
STATIC nDomNextID := 1000
// ============================================================================
// DOM CORE
// ============================================================================
FUNCTION DOM_Init()
PUBLIC hDOM := {=>}
// ----------------------------------------------------------------
// CORE
// ----------------------------------------------------------------
hDOM["_data"] := {=>}
hDOM["_watch"] := {=>}
hDOM["_history"] := {}
// ----------------------------------------------------------------
// PROJECT
// ----------------------------------------------------------------
hDOM["project"] := {=>}
hDOM["project"]["name"] := ""
hDOM["project"]["path"] := ""
hDOM["project"]["status"] := "INIT"
hDOM["project"]["modified"] := .F.
hDOM["project"]["containers"] := {}
hDOM["project"]["files"] := {}
// ----------------------------------------------------------------
// EDITOR
// ----------------------------------------------------------------
hDOM["editor"] := {=>}
hDOM["editor"]["active_file"] := ""
hDOM["editor"]["dirty"] := .F.
hDOM["editor"]["encoding"] := "utf8"
// ----------------------------------------------------------------
// UI
// ----------------------------------------------------------------
hDOM["ui"] := {=>}
hDOM["ui"]["tree_selected"] := 0
// ----------------------------------------------------------------
// LANGUAGE
// ----------------------------------------------------------------
hDOM["language"] := "English"
RETURN NIL
// ============================================================================
// DOM GET / SET
// ============================================================================
FUNCTION DomSet( cKey, uValue )
LOCAL uOld := NIL
IF !HB_HHasKey( hDOM["_data"], cKey )
hDOM["_data"][ cKey ] := NIL
ENDIF
uOld := hDOM["_data"][ cKey ]
IF uOld == uValue
RETURN NIL
ENDIF
hDOM["_data"][ cKey ] := uValue
AAdd( hDOM["_history"], { cKey, uOld, uValue } )
RETURN NIL
FUNCTION DomGet( cKey )
IF HB_HHasKey( hDOM["_data"], cKey )
RETURN hDOM["_data"][ cKey ]
ENDIF
RETURN NIL
// ============================================================================
// DOM CREATE EMPTY
// ============================================================================
PROCEDURE DOM_CreateEmpty()
hDOM["project"]["name"] := ""
hDOM["project"]["path"] := ""
hDOM["project"]["status"] := "INIT"
hDOM["project"]["modified"] := .F.
hDOM["project"]["containers"] := {}
hDOM["project"]["files"] := {}
RETURN
// ============================================================================
// DOM LOAD PROJECT
// ============================================================================
PROCEDURE DOM_LoadProject( cProject )
LOCAL cName
IF Empty( cProject )
RETURN
ENDIF
IF !File( cProject )
RETURN
ENDIF
cName := hb_fNameName( cProject )
hDOM["project"]["name"] := cName
hDOM["project"]["path"] := cProject
hDOM["project"]["status"] := "PROJECT"
hDOM["project"]["modified"] := .F.
hDOM["project"]["containers"]:= {}
hDOM["project"]["files"] := {}
DOM_LoadContainers()
RETURN
// ============================================================================
// LOAD CONTAINERS
// ============================================================================
PROCEDURE DOM_LoadContainers()
LOCAL cHBP
LOCAL cBase
LOCAL cDir
LOCAL cFRM
LOCAL cHBC
LOCAL cRC
cHBP := hDOM["project"]["path"]
cBase := hb_fNameName( cHBP )
cDir := hb_fNameDir( cHBP )
IF Right( cDir, 1 ) != "\"
cDir += "\"
ENDIF
cFRM := cDir + cBase + ".frm"
cHBC := cDir + cBase + ".hbc"
cRC := cDir + cBase + ".rc"
// ----------------------------------------------------------------
// REGISTER CONTAINERS
// ----------------------------------------------------------------
DOM_AddContainer( "hbp", cHBP )
IF File( cFRM )
DOM_AddContainer( "frm", cFRM )
ENDIF
IF File( cHBC )
DOM_AddContainer( "hbc", cHBC )
ENDIF
IF File( cRC )
DOM_AddContainer( "rc", cRC )
ENDIF
// ----------------------------------------------------------------
// PARSE
// ----------------------------------------------------------------
DOM_ParseHBP( cHBP )
IF File( cFRM )
DOM_ParseFRM( cFRM )
ENDIF
RETURN
// ============================================================================
// ADD CONTAINER
// ============================================================================
PROCEDURE DOM_AddContainer( cType, cPath )
LOCAL hContainer := {=>}
nDomNextID++
hContainer["id"] := nDomNextID
hContainer["type"] := Lower( cType )
hContainer["path"] := cPath
hContainer["name"] := hb_fNameNameExt( cPath )
hContainer["icon"] := GetFileIconIndex( cPath )
AAdd( hDOM["project"]["containers"], hContainer )
RETURN
// ============================================================================
// PARSE HBP
// ============================================================================
PROCEDURE DOM_ParseHBP( cHBP )
LOCAL cContent , aLines , cLine , nI
LOCAL cDir , cFull , cExt
LOCAL cName
IF !File( cHBP )
RETURN
ENDIF
cDir := hb_fNameDir( cHBP )
IF Right( cDir, 1 ) != "\"
cDir += "\"
ENDIF
cContent := MemoRead( cHBP )
cContent := StrTran( cContent, Chr(13), "" )
aLines := hb_ATokens( cContent, Chr(10) )
FOR nI := 1 TO Len( aLines )
cLine := AllTrim( aLines[nI] )
IF Empty( cLine )
LOOP
ENDIF
IF Left( cLine, 1 ) == "#"
LOOP
ENDIF
IF Left( cLine, 1 ) == "-"
LOOP
ENDIF
cLine := StrTran( cLine, "/", "\" )
//----------------------------------------------------
// FULL PATH
//----------------------------------------------------
IF ":" $ cLine
cFull := cLine
ELSE
cFull := cDir + cLine
ENDIF
cExt := Lower( hb_fNameExt( cFull ) )
cName := hb_fNameNameExt( cFull )
//----------------------------------------------------
// REGISTER FILE
//----------------------------------------------------
IF cExt == ".prg" .OR. ;
cExt == ".c" .OR. ;
cExt == ".cpp"
DOM_AddFile( cFull , "hbp" )
ENDIF
NEXT
RETURN
// ============================================================================
// PARSE FRM
// ============================================================================
PROCEDURE DOM_ParseFRM( cFRM )
LOCAL cContent , aLines , cLine , nI , cDir , cFull , cExt
IF !File( cFRM )
RETURN
ENDIF
cDir := hb_fNameDir( cFRM )
IF Right( cDir, 1 ) != "\"
cDir += "\"
ENDIF
cContent := MemoRead( cFRM )
cContent := StrTran( cContent, Chr(13), "" )
aLines := hb_ATokens( cContent, Chr(10) )
FOR nI := 1 TO Len( aLines )
cLine := AllTrim( aLines[nI ] )
IF Empty( cLine )
LOOP
ENDIF
IF Left( cLine, 1 ) == "#"
LOOP
ENDIF
IF Left( cLine, 1 ) == "-"
LOOP
ENDIF
cLine := StrTran( cLine, "/", "\" )
IF ":" $ cLine
cFull := cLine
ELSE
cFull := cDir + cLine
ENDIF
cExt := Lower( hb_fNameExt( cFull ) )
IF cExt == ".fmg"
DOM_AddFile( cFull, "frm" )
ENDIF
NEXT
RETURN
// ============================================================================
// ADD FILE
// ============================================================================
PROCEDURE DOM_AddFile( cFull, cGroup )
LOCAL hFile := {=>}
LOCAL cName , cExt
IF Empty( cFull )
RETURN
ENDIF
IF DOM_FindFileByPath( cFull ) != NIL
RETURN
ENDIF
cName := hb_fNameNameExt( cFull )
cExt := Lower( hb_fNameExt( cFull ) )
nDomNextID++
hFile["id"] := nDomNextID
hFile["name"] := cName
hFile["path"] := cFull
hFile["ext"] := cExt
hFile["group"] := cGroup
hFile["opened"] := .F.
hFile["dirty"] := .F.
hFile["encoding"]:= "utf8"
hFile["icon"] := GetFileIconIndex( cFull )
DO CASE
CASE cExt == ".prg"
hFile["type"] := "source"
CASE cExt == ".c"
hFile["type"] := "c"
CASE cExt == ".cpp"
hFile["type"] := "cpp"
CASE cExt == ".fmg"
hFile["type"] := "form"
OTHERWISE
hFile["type"] := "unknown"
ENDCASE
AAdd( hDOM["project"]["files"], hFile )
hDOM["project"]["modified"] := .T.
RETURN
// ============================================================================
// FIND FILE
// ============================================================================
FUNCTION DOM_FindFileByPath( cPath )
LOCAL aFiles := hDOM["project"]["files"]
LOCAL nI
FOR nI := 1 TO Len( aFiles )
IF Upper( aFiles[nI]["path"] ) == Upper( cPath )
RETURN aFiles[nI]
ENDIF
NEXT
RETURN NIL
FUNCTION DOM_GetPath( nIndex )
LOCAL aFiles , hFile , nI
IF Empty( nIndex )
RETURN ""
ENDIF
IF !HB_HHasKey( hDOM, "project" )
RETURN ""
ENDIF
IF !HB_HHasKey( hDOM["project"], "files" )
RETURN ""
ENDIF
aFiles := hDOM["project"]["files"]
FOR nI := 1 TO Len( aFiles )
hFile := aFiles[nI]
IF ValType( hFile ) == "H"
IF hb_HGetDef( hFile, "treeid", 0 ) == nIndex
RETURN hb_HGetDef( hFile, "path", "" )
ENDIF
ENDIF
NEXT
RETURN ""
PROCEDURE InitProjectStructure()
hDOM["project_name"] := "Untitled"
hDOM["status"] := "EMPTY"
RETURN
// ============================================================================
// BUILD TREE
// ============================================================================
FUNCTION BuildTreeFromDOM()
LOCAL aContainers := hDOM["project"]["containers"]
LOCAL aFiles := hDOM["project"]["files"]
LOCAL nI , nJ
LOCAL hContainer , hFile
LOCAL nRoot
LOCAL nProject
LOCAL nHBP := 0
LOCAL nFRM := 0
LOCAL nHBC := 0
LOCAL nRC := 0
LOCAL nTreeID
IF .NOT. IsWindowDefined( "Inspector" )
RETURN NIL
ENDIF
DoMethod( "Inspector", "Tree_Project", "DisableUpdate" )
DoMethod( "Inspector", "Tree_Project", "DeleteAllItems" )
// ----------------------------------------------------------------
// INIT
// ----------------------------------------------------------------
IF hDOM["project"]["status"] == "INIT"
DoMethod( ;
"Inspector", ;
"Tree_Project", ;
"AddItem", ;
"IDE Unicode v0.12", ;
0, ;
5 )
DoMethod( ;
"Inspector", ;
"Tree_Project", ;
"AddItem", ;
"No open project", ;
1, ;
6 )
DoMethod( "Inspector", "Tree_Project", "EnableUpdate" )
DoMethod( "Inspector", "Tree_Project", "Refresh" )
RETURN NIL
ENDIF
// ----------------------------------------------------------------
// ROOT
// ----------------------------------------------------------------
DoMethod( ;
"Inspector", ;
"Tree_Project", ;
"AddItem", ;
"IDE Unicode v0.12", ;
0, ;
1 )
nRoot := GetProperty( ;
"Inspector", ;
"Tree_Project", ;
"ItemCount" )
// ----------------------------------------------------------------
// PROJECT
// ----------------------------------------------------------------
DoMethod( ;
"Inspector", ;
"Tree_Project", ;
"AddItem", ;
hDOM["project"]["name"], ;
nRoot, ;
6 )
nProject := GetProperty( ;
"Inspector", ;
"Tree_Project", ;
"ItemCount" )
// ----------------------------------------------------------------
// CONTAINERS
// ----------------------------------------------------------------
FOR nI := 1 TO Len( aContainers )
hContainer := aContainers[nI]
DoMethod( ;
"Inspector", ;
"Tree_Project", ;
"AddItem", ;
hContainer["name"], ;
nProject, ;
hContainer["icon"] )
nTreeID := GetProperty( ;
"Inspector", ;
"Tree_Project", ;
"ItemCount" )
hContainer["treeid"] := nTreeID
DO CASE
CASE hContainer["type"] == "hbp"
nHBP := nTreeID
CASE hContainer["type"] == "frm"
nFRM := nTreeID
CASE hContainer["type"] == "hbc"
nHBC := nTreeID
CASE hContainer["type"] == "rc"
nRC := nTreeID
ENDCASE
NEXT
// ----------------------------------------------------------------
// FILES
// ----------------------------------------------------------------
FOR nJ := 1 TO Len( aFiles )
hFile := aFiles[nJ]
DO CASE
CASE hFile["group"] == "hbp"
IF nHBP > 0
DoMethod( ;
"Inspector", ;
"Tree_Project", ;
"AddItem", ;
hFile["name"], ;
nHBP, ;
hFile["icon"] )
ENDIF
CASE hFile["group"] == "frm"
IF nFRM > 0
DoMethod( ;
"Inspector", ;
"Tree_Project", ;
"AddItem", ;
hFile["name"], ;
nFRM, ;
hFile["icon"] )
ENDIF
CASE hFile["group"] == "hbc"
IF nHBC > 0
DoMethod( ;
"Inspector", ;
"Tree_Project", ;
"AddItem", ;
hFile["name"], ;
nHBC, ;
hFile["icon"] )
ENDIF
CASE hFile["group"] == "rc"
IF nRC > 0
DoMethod( ;
"Inspector", ;
"Tree_Project", ;
"AddItem", ;
hFile["name"], ;
nRC, ;
hFile["icon"] )
ENDIF
ENDCASE
//-------------------------------------------------------------
// CAPTURE REAL TREE ID
//-------------------------------------------------------------
nTreeID := GetProperty( ;
"Inspector", ;
"Tree_Project", ;
"ItemCount" )
hFile["treeid"] := nTreeID
NEXT
// ----------------------------------------------------------------
// EXPAND
// ----------------------------------------------------------------
IF nRoot > 0
DoMethod( "Inspector", "Tree_Project", "Expand", nRoot )
ENDIF
IF nProject > 0
DoMethod( "Inspector", "Tree_Project", "Expand", nProject )
ENDIF
IF nHBP > 0
DoMethod( "Inspector", "Tree_Project", "Expand", nHBP )
ENDIF
IF nFRM > 0
DoMethod( "Inspector", "Tree_Project", "Expand", nFRM )
ENDIF
IF nHBC > 0
DoMethod( "Inspector", "Tree_Project", "Expand", nHBC )
ENDIF
IF nRC > 0
DoMethod( "Inspector", "Tree_Project", "Expand", nRC )
ENDIF
// ----------------------------------------------------------------
// DEFAULT SELECT
// ----------------------------------------------------------------
SetProperty( "Inspector", "Tree_Project", "Value", 1 )
DoMethod( "Inspector", "Tree_Project", "EnableUpdate" )
DoMethod( "Inspector", "Tree_Project", "Refresh" )
ConsoleLog( ;
"UI: Tree rebuilt -> " + ;
hb_ntos( Len( aFiles ) ) + ;
" files", ;
"SUCCESS" )
RETURN NIL
// ============================================================================
// SAVE PROJECT
// ============================================================================
PROCEDURE DOM_SaveProject()
LOCAL cProject := DomGet( "project_path" )
IF Empty( cProject )
RETURN
ENDIF
Project_SyncHBP()
ConsoleLog( "DOM: project saved", "SUCCESS" )
RETURN
PROCEDURE Project_SyncHBP()
LOCAL cProject := DomGet( "project_path" )
LOCAL aModules
LOCAL i
LOCAL cContent := ""
IF Empty( cProject )
RETURN
ENDIF
IF !HB_HHasKey( hDOM, "modules" )
RETURN
ENDIF
aModules := hDOM["modules"]
FOR i := 1 TO Len( aModules )
cContent += aModules[i] + hb_eol()
NEXT
MemoWrit( cProject, cContent )
ConsoleLog( "PROJECT: .hbp synced", "SUCCESS" )
RETURN
// ============================================================================
// ICONS
// ============================================================================
FUNCTION GetFileIconIndex( cFile )
LOCAL cExt := Lower( hb_fNameExt( cFile ) )
LOCAL nIcono := 6
DO CASE
CASE cExt == ".hbp"
nIcono := 1
CASE cExt == ".prg" .OR. cExt == ".c" .OR. cExt == ".cpp"
nIcono := 2
CASE cExt == ".rc"
nIcono := 3
CASE cExt == ".ch" .OR. cExt == ".h"
nIcono := 4
CASE cExt == ".frm"
nIcono := 7
CASE cExt == ".fmg"
nIcono := 8
CASE cExt == ".hbc"
nIcono := 9
CASE Empty( cExt )
nIcono := 5
ENDCASE
RETURN nIconoCode: Select all
// Dom.prg
#include "hmg.ch"
#include "IDE_Unicode.ch"
// ============================================================================
// IDE UNICODE v0.12
// DOM CORE ENGINE
// ============================================================================
STATIC nDomNextID := 1000
// ============================================================================
// DOM CORE
// ============================================================================
FUNCTION DOM_Init()
PUBLIC hDOM := {=>}
// ----------------------------------------------------------------
// CORE
// ----------------------------------------------------------------
hDOM["_data"] := {=>}
hDOM["_watch"] := {=>}
hDOM["_history"] := {}
// ----------------------------------------------------------------
// PROJECT
// ----------------------------------------------------------------
hDOM["project"] := {=>}
hDOM["project"]["name"] := ""
hDOM["project"]["path"] := ""
hDOM["project"]["status"] := "INIT"
hDOM["project"]["modified"] := .F.
hDOM["project"]["containers"] := {}
hDOM["project"]["files"] := {}
// ----------------------------------------------------------------
// EDITOR
// ----------------------------------------------------------------
hDOM["editor"] := {=>}
hDOM["editor"]["active_file"] := ""
hDOM["editor"]["dirty"] := .F.
hDOM["editor"]["encoding"] := "utf8"
// ----------------------------------------------------------------
// UI
// ----------------------------------------------------------------
hDOM["ui"] := {=>}
hDOM["ui"]["tree_selected"] := 0
// ----------------------------------------------------------------
// LANGUAGE
// ----------------------------------------------------------------
hDOM["language"] := "English"
RETURN NIL
// ============================================================================
// DOM GET / SET
// ============================================================================
FUNCTION DomSet( cKey, uValue )
LOCAL uOld := NIL
IF !HB_HHasKey( hDOM["_data"], cKey )
hDOM["_data"][ cKey ] := NIL
ENDIF
uOld := hDOM["_data"][ cKey ]
IF uOld == uValue
RETURN NIL
ENDIF
hDOM["_data"][ cKey ] := uValue
AAdd( hDOM["_history"], { cKey, uOld, uValue } )
RETURN NIL
FUNCTION DomGet( cKey )
IF HB_HHasKey( hDOM["_data"], cKey )
RETURN hDOM["_data"][ cKey ]
ENDIF
RETURN NIL
// ============================================================================
// DOM CREATE EMPTY
// ============================================================================
PROCEDURE DOM_CreateEmpty()
hDOM["project"]["name"] := ""
hDOM["project"]["path"] := ""
hDOM["project"]["status"] := "INIT"
hDOM["project"]["modified"] := .F.
hDOM["project"]["containers"] := {}
hDOM["project"]["files"] := {}
RETURN
// ============================================================================
// DOM LOAD PROJECT
// ============================================================================
PROCEDURE DOM_LoadProject( cProject )
LOCAL cName
IF Empty( cProject )
RETURN
ENDIF
IF !File( cProject )
RETURN
ENDIF
cName := hb_fNameName( cProject )
hDOM["project"]["name"] := cName
hDOM["project"]["path"] := cProject
hDOM["project"]["status"] := "PROJECT"
hDOM["project"]["modified"] := .F.
hDOM["project"]["containers"]:= {}
hDOM["project"]["files"] := {}
DOM_LoadContainers()
RETURN
// ============================================================================
// LOAD CONTAINERS
// ============================================================================
PROCEDURE DOM_LoadContainers()
LOCAL cHBP
LOCAL cBase
LOCAL cDir
LOCAL cFRM
LOCAL cHBC
LOCAL cRC
cHBP := hDOM["project"]["path"]
cBase := hb_fNameName( cHBP )
cDir := hb_fNameDir( cHBP )
IF Right( cDir, 1 ) != "\"
cDir += "\"
ENDIF
cFRM := cDir + cBase + ".frm"
cHBC := cDir + cBase + ".hbc"
cRC := cDir + cBase + ".rc"
// ----------------------------------------------------------------
// REGISTER CONTAINERS
// ----------------------------------------------------------------
DOM_AddContainer( "hbp", cHBP )
IF File( cFRM )
DOM_AddContainer( "frm", cFRM )
ENDIF
IF File( cHBC )
DOM_AddContainer( "hbc", cHBC )
ENDIF
IF File( cRC )
DOM_AddContainer( "rc", cRC )
ENDIF
// ----------------------------------------------------------------
// PARSE
// ----------------------------------------------------------------
DOM_ParseHBP( cHBP )
IF File( cFRM )
DOM_ParseFRM( cFRM )
ENDIF
RETURN
// ============================================================================
// ADD CONTAINER
// ============================================================================
PROCEDURE DOM_AddContainer( cType, cPath )
LOCAL hContainer := {=>}
nDomNextID++
hContainer["id"] := nDomNextID
hContainer["type"] := Lower( cType )
hContainer["path"] := cPath
hContainer["name"] := hb_fNameNameExt( cPath )
hContainer["icon"] := GetFileIconIndex( cPath )
AAdd( hDOM["project"]["containers"], hContainer )
RETURN
// ============================================================================
// PARSE HBP
// ============================================================================
PROCEDURE DOM_ParseHBP( cHBP )
LOCAL cContent , aLines , cLine , nI
LOCAL cDir , cFull , cExt
LOCAL cName
IF !File( cHBP )
RETURN
ENDIF
cDir := hb_fNameDir( cHBP )
IF Right( cDir, 1 ) != "\"
cDir += "\"
ENDIF
cContent := MemoRead( cHBP )
cContent := StrTran( cContent, Chr(13), "" )
aLines := hb_ATokens( cContent, Chr(10) )
FOR nI := 1 TO Len( aLines )
cLine := AllTrim( aLines[nI] )
IF Empty( cLine )
LOOP
ENDIF
IF Left( cLine, 1 ) == "#"
LOOP
ENDIF
IF Left( cLine, 1 ) == "-"
LOOP
ENDIF
cLine := StrTran( cLine, "/", "\" )
//----------------------------------------------------
// FULL PATH
//----------------------------------------------------
IF ":" $ cLine
cFull := cLine
ELSE
cFull := cDir + cLine
ENDIF
cExt := Lower( hb_fNameExt( cFull ) )
cName := hb_fNameNameExt( cFull )
//----------------------------------------------------
// REGISTER FILE
//----------------------------------------------------
IF cExt == ".prg" .OR. ;
cExt == ".c" .OR. ;
cExt == ".cpp"
DOM_AddFile( cFull , "hbp" )
ENDIF
NEXT
RETURN
// ============================================================================
// PARSE FRM
// ============================================================================
PROCEDURE DOM_ParseFRM( cFRM )
LOCAL cContent , aLines , cLine , nI , cDir , cFull , cExt
IF !File( cFRM )
RETURN
ENDIF
cDir := hb_fNameDir( cFRM )
IF Right( cDir, 1 ) != "\"
cDir += "\"
ENDIF
cContent := MemoRead( cFRM )
cContent := StrTran( cContent, Chr(13), "" )
aLines := hb_ATokens( cContent, Chr(10) )
FOR nI := 1 TO Len( aLines )
cLine := AllTrim( aLines[nI ] )
IF Empty( cLine )
LOOP
ENDIF
IF Left( cLine, 1 ) == "#"
LOOP
ENDIF
IF Left( cLine, 1 ) == "-"
LOOP
ENDIF
cLine := StrTran( cLine, "/", "\" )
IF ":" $ cLine
cFull := cLine
ELSE
cFull := cDir + cLine
ENDIF
cExt := Lower( hb_fNameExt( cFull ) )
IF cExt == ".fmg"
DOM_AddFile( cFull, "frm" )
ENDIF
NEXT
RETURN
// ============================================================================
// ADD FILE
// ============================================================================
PROCEDURE DOM_AddFile( cFull, cGroup )
LOCAL hFile := {=>}
LOCAL cName , cExt
IF Empty( cFull )
RETURN
ENDIF
IF DOM_FindFileByPath( cFull ) != NIL
RETURN
ENDIF
cName := hb_fNameNameExt( cFull )
cExt := Lower( hb_fNameExt( cFull ) )
nDomNextID++
hFile["id"] := nDomNextID
hFile["name"] := cName
hFile["path"] := cFull
hFile["ext"] := cExt
hFile["group"] := cGroup
hFile["opened"] := .F.
hFile["dirty"] := .F.
hFile["encoding"]:= "utf8"
hFile["icon"] := GetFileIconIndex( cFull )
DO CASE
CASE cExt == ".prg"
hFile["type"] := "source"
CASE cExt == ".c"
hFile["type"] := "c"
CASE cExt == ".cpp"
hFile["type"] := "cpp"
CASE cExt == ".fmg"
hFile["type"] := "form"
OTHERWISE
hFile["type"] := "unknown"
ENDCASE
AAdd( hDOM["project"]["files"], hFile )
hDOM["project"]["modified"] := .T.
RETURN
// ============================================================================
// FIND FILE
// ============================================================================
FUNCTION DOM_FindFileByPath( cPath )
LOCAL aFiles := hDOM["project"]["files"]
LOCAL nI
FOR nI := 1 TO Len( aFiles )
IF Upper( aFiles[nI]["path"] ) == Upper( cPath )
RETURN aFiles[nI]
ENDIF
NEXT
RETURN NIL
FUNCTION DOM_GetPath( nIndex )
LOCAL aFiles , hFile , nI
IF Empty( nIndex )
RETURN ""
ENDIF
IF !HB_HHasKey( hDOM, "project" )
RETURN ""
ENDIF
IF !HB_HHasKey( hDOM["project"], "files" )
RETURN ""
ENDIF
aFiles := hDOM["project"]["files"]
FOR nI := 1 TO Len( aFiles )
hFile := aFiles[nI]
IF ValType( hFile ) == "H"
IF hb_HGetDef( hFile, "treeid", 0 ) == nIndex
RETURN hb_HGetDef( hFile, "path", "" )
ENDIF
ENDIF
NEXT
RETURN ""
PROCEDURE InitProjectStructure()
hDOM["project_name"] := "Untitled"
hDOM["status"] := "EMPTY"
RETURN
// ============================================================================
// BUILD TREE
// ============================================================================
FUNCTION BuildTreeFromDOM()
LOCAL aContainers := hDOM["project"]["containers"]
LOCAL aFiles := hDOM["project"]["files"]
LOCAL nI , nJ
LOCAL hContainer , hFile
LOCAL nRoot
LOCAL nProject
LOCAL nHBP := 0
LOCAL nFRM := 0
LOCAL nHBC := 0
LOCAL nRC := 0
LOCAL nTreeID
IF .NOT. IsWindowDefined( "Inspector" )
RETURN NIL
ENDIF
DoMethod( "Inspector", "Tree_Project", "DisableUpdate" )
DoMethod( "Inspector", "Tree_Project", "DeleteAllItems" )
// ----------------------------------------------------------------
// INIT
// ----------------------------------------------------------------
IF hDOM["project"]["status"] == "INIT"
DoMethod( ;
"Inspector", ;
"Tree_Project", ;
"AddItem", ;
"IDE Unicode v0.12", ;
0, ;
5 )
DoMethod( ;
"Inspector", ;
"Tree_Project", ;
"AddItem", ;
"No open project", ;
1, ;
6 )
DoMethod( "Inspector", "Tree_Project", "EnableUpdate" )
DoMethod( "Inspector", "Tree_Project", "Refresh" )
RETURN NIL
ENDIF
// ----------------------------------------------------------------
// ROOT
// ----------------------------------------------------------------
DoMethod( ;
"Inspector", ;
"Tree_Project", ;
"AddItem", ;
"IDE Unicode v0.12", ;
0, ;
1 )
nRoot := GetProperty( ;
"Inspector", ;
"Tree_Project", ;
"ItemCount" )
// ----------------------------------------------------------------
// PROJECT
// ----------------------------------------------------------------
DoMethod( ;
"Inspector", ;
"Tree_Project", ;
"AddItem", ;
hDOM["project"]["name"], ;
nRoot, ;
6 )
nProject := GetProperty( ;
"Inspector", ;
"Tree_Project", ;
"ItemCount" )
// ----------------------------------------------------------------
// CONTAINERS
// ----------------------------------------------------------------
FOR nI := 1 TO Len( aContainers )
hContainer := aContainers[nI]
DoMethod( ;
"Inspector", ;
"Tree_Project", ;
"AddItem", ;
hContainer["name"], ;
nProject, ;
hContainer["icon"] )
nTreeID := GetProperty( ;
"Inspector", ;
"Tree_Project", ;
"ItemCount" )
hContainer["treeid"] := nTreeID
DO CASE
CASE hContainer["type"] == "hbp"
nHBP := nTreeID
CASE hContainer["type"] == "frm"
nFRM := nTreeID
CASE hContainer["type"] == "hbc"
nHBC := nTreeID
CASE hContainer["type"] == "rc"
nRC := nTreeID
ENDCASE
NEXT
// ----------------------------------------------------------------
// FILES
// ----------------------------------------------------------------
FOR nJ := 1 TO Len( aFiles )
hFile := aFiles[nJ]
DO CASE
CASE hFile["group"] == "hbp"
IF nHBP > 0
DoMethod( ;
"Inspector", ;
"Tree_Project", ;
"AddItem", ;
hFile["name"], ;
nHBP, ;
hFile["icon"] )
ENDIF
CASE hFile["group"] == "frm"
IF nFRM > 0
DoMethod( ;
"Inspector", ;
"Tree_Project", ;
"AddItem", ;
hFile["name"], ;
nFRM, ;
hFile["icon"] )
ENDIF
CASE hFile["group"] == "hbc"
IF nHBC > 0
DoMethod( ;
"Inspector", ;
"Tree_Project", ;
"AddItem", ;
hFile["name"], ;
nHBC, ;
hFile["icon"] )
ENDIF
CASE hFile["group"] == "rc"
IF nRC > 0
DoMethod( ;
"Inspector", ;
"Tree_Project", ;
"AddItem", ;
hFile["name"], ;
nRC, ;
hFile["icon"] )
ENDIF
ENDCASE
//-------------------------------------------------------------
// CAPTURE REAL TREE ID
//-------------------------------------------------------------
nTreeID := GetProperty( ;
"Inspector", ;
"Tree_Project", ;
"ItemCount" )
hFile["treeid"] := nTreeID
NEXT
// ----------------------------------------------------------------
// EXPAND
// ----------------------------------------------------------------
IF nRoot > 0
DoMethod( "Inspector", "Tree_Project", "Expand", nRoot )
ENDIF
IF nProject > 0
DoMethod( "Inspector", "Tree_Project", "Expand", nProject )
ENDIF
IF nHBP > 0
DoMethod( "Inspector", "Tree_Project", "Expand", nHBP )
ENDIF
IF nFRM > 0
DoMethod( "Inspector", "Tree_Project", "Expand", nFRM )
ENDIF
IF nHBC > 0
DoMethod( "Inspector", "Tree_Project", "Expand", nHBC )
ENDIF
IF nRC > 0
DoMethod( "Inspector", "Tree_Project", "Expand", nRC )
ENDIF
// ----------------------------------------------------------------
// DEFAULT SELECT
// ----------------------------------------------------------------
SetProperty( "Inspector", "Tree_Project", "Value", 1 )
DoMethod( "Inspector", "Tree_Project", "EnableUpdate" )
DoMethod( "Inspector", "Tree_Project", "Refresh" )
ConsoleLog( ;
"UI: Tree rebuilt -> " + ;
hb_ntos( Len( aFiles ) ) + ;
" files", ;
"SUCCESS" )
RETURN NIL
// ============================================================================
// SAVE PROJECT
// ============================================================================
PROCEDURE DOM_SaveProject()
LOCAL cProject := DomGet( "project_path" )
IF Empty( cProject )
RETURN
ENDIF
Project_SyncHBP()
ConsoleLog( "DOM: project saved", "SUCCESS" )
RETURN
PROCEDURE Project_SyncHBP()
LOCAL cProject := DomGet( "project_path" )
LOCAL aModules
LOCAL i
LOCAL cContent := ""
IF Empty( cProject )
RETURN
ENDIF
IF !HB_HHasKey( hDOM, "modules" )
RETURN
ENDIF
aModules := hDOM["modules"]
FOR i := 1 TO Len( aModules )
cContent += aModules[i] + hb_eol()
NEXT
MemoWrit( cProject, cContent )
ConsoleLog( "PROJECT: .hbp synced", "SUCCESS" )
RETURN
// ============================================================================
// ICONS
// ============================================================================
FUNCTION GetFileIconIndex( cFile )
LOCAL cExt := Lower( hb_fNameExt( cFile ) )
LOCAL nIcono := 6
DO CASE
CASE cExt == ".hbp"
nIcono := 1
CASE cExt == ".prg" .OR. cExt == ".c" .OR. cExt == ".cpp"
nIcono := 2
CASE cExt == ".rc"
nIcono := 3
CASE cExt == ".ch" .OR. cExt == ".h"
nIcono := 4
CASE cExt == ".frm"
nIcono := 7
CASE cExt == ".fmg"
nIcono := 8
CASE cExt == ".hbc"
nIcono := 9
CASE Empty( cExt )
nIcono := 5
ENDCASE
RETURN nIconoAttachments
Attachments
Attachments
Attachments