[Done] Damaged IDE dialog

Post bugs related to the IDE here
Little John
Addict
Addict
Posts: 4773
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

[Done] Damaged IDE dialog

Post by Little John »

Encountered on Windows (e.g. with PB 5.22 LTS and PB 5.30) with display setting 120 DPI:

Image

There is some text missing at the end of the second line, and obviously the fourth line is not readable.

Formerly, when using the standard setting of 96 DPI, I never encountered this issue.
So I think the problem is, that the dialog is not DPI aware.
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Damaged IDE dialog

Post by Fred »

Already fixed in current release.
Little John
Addict
Addict
Posts: 4773
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: [Done] Damaged IDE dialog

Post by Little John »

Sorry, the problem still exists if the path is long. It looks here e.g. like this on Windows 11 with display setting 125 DPI:
 
Image
User avatar
kenmo
Addict
Addict
Posts: 2032
Joined: Tue Dec 23, 2003 3:54 am

Re: Damaged IDE dialog

Post by kenmo »

This problem annoyed me before too.

In my own mod of the IDE, I only show the file name part, instead of the full path. In 99.999% of cases, this is enough info! :D

If that's an acceptable compromise I'll submit it on GitHub.
Little John
Addict
Addict
Posts: 4773
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Damaged IDE dialog

Post by Little John »

On Windows, another solution would be using PathCompactPath_().

Demo code:

Code: Select all

EnableExplicit


Procedure StatusbarCompactPath (statusBar.i, field.i, hDC.i, path$)
   ; in: statusBar: number to identify the status bar
   ;     field    : index of the status bar field where to display the path
   ;     hDC      : handle to regarding device context
   ;     path$    : path to display in the field
   ;
   ; (getestet mit PB 5.73 LTS unter Windows 10 -- mit und ohne DPI-Kompatibilität)
   ; https://docs.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-pathcompactpatha
   Protected rect.RECT, textWidth.i
   
   ; verfügbare Pixelbreite in Statusbar feststellen
   SendMessage_(StatusBarID(statusBar), #SB_GETRECT, field, @rect)
   textWidth = rect\right - rect\left
   
   ; angepassten Pfad in der Statusbar anzeigen
   PathCompactPath_(hDC, @path$, textWidth-5)
   StatusBarText(statusBar, field, path$)
EndProcedure


#StatBar = 0

Define hStatusbar, hDC, event, path$

OpenWindow(0, #PB_Ignore, #PB_Ignore, 300, 200, "Test", #PB_Window_SizeGadget | #PB_Window_SystemMenu)

; StatusBar und Device Context erzeugen
hStatusbar = CreateStatusBar(#StatBar, WindowID(0))
hDC = CreateCompatibleDC_(#Null)
SelectObject_(hDC, SendMessage_(hStatusBar, #WM_GETFONT, 0, 0))

AddStatusBarField(100)
AddStatusBarField(#PB_Ignore)

path$ = "C:\\test\test\test\test\test\test\test\test\test\test\test\test\test\test\test\test\test\test\test\test\test\test\test.txt"

StatusbarCompactPath(#StatBar, 1, hDC, path$)
Repeat
   event = WaitWindowEvent()
   
   ; Wenn die Fenstergröße geändert wird ...
   If event = #PB_Event_SizeWindow
      StatusbarCompactPath(#StatBar, 1, hDC, path$)
   EndIf   
Until event = #PB_Event_CloseWindow

DeleteDC_(hDC)
AZJIO
Addict
Addict
Posts: 2141
Joined: Sun May 14, 2017 1:48 am

Re: Damaged IDE dialog

Post by AZJIO »

Linux (Windows, Mac)

Code: Select all

EnableExplicit

Structure ReplaceGr
	pos.i
	ngr.i
	group.s
EndStructure

Procedure RegexReplace2(RgEx, *Result.string, Replace0$, Escaped = 0)
	Protected i, CountGr, Pos, Offset = 1
	Protected Replace$
	Protected NewList item.s()
	Protected LenT, *Point
	Protected RE2
	Protected NewList ReplaceGr.ReplaceGr()

	CountGr = CountRegularExpressionGroups(RgEx)
	If CountGr > 9
		CountGr = 9
	EndIf

	If ExamineRegularExpression(RgEx, *Result\s)

		If Escaped
			Replace0$ = ReplaceString(Replace0$, "\r", #CR$)
			Replace0$ = ReplaceString(Replace0$, "\n", #LF$)
			Replace0$ = ReplaceString(Replace0$, "\t", #TAB$)
			Replace0$ = ReplaceString(Replace0$, "\f", #FF$)
		EndIf

		RE2 = CreateRegularExpression(#PB_Any, "\\\d")
		If RE2
			If ExamineRegularExpression(RE2, Replace0$)
				While NextRegularExpressionMatch(RE2)
					If AddElement(ReplaceGr())
						ReplaceGr()\pos = RegularExpressionMatchPosition(RE2)
						ReplaceGr()\ngr = ValD(Right(RegularExpressionMatchString(RE2), 1))
						ReplaceGr()\group = RegularExpressionMatchString(RE2)
					EndIf
				Wend
			EndIf
			FreeRegularExpression(RE2)
		EndIf
		If Not ListSize(ReplaceGr())
			*Result\s = ReplaceRegularExpression(RgEx, *Result\s, Replace0$)
			ProcedureReturn
		EndIf
		SortStructuredList(ReplaceGr(), #PB_Sort_Descending, OffsetOf(ReplaceGr\pos), TypeOf(ReplaceGr\pos))

		While NextRegularExpressionMatch(RgEx)
			Pos = RegularExpressionMatchPosition(RgEx)
			Replace$ = Replace0$

			ForEach ReplaceGr()
				If ReplaceGr()\ngr
					Replace$ = ReplaceString(Replace$, ReplaceGr()\group, RegularExpressionGroup(RgEx, ReplaceGr()\ngr), #PB_String_CaseSensitive, ReplaceGr()\pos, 1)
				Else
					Replace$ = ReplaceString(Replace$, ReplaceGr()\group, RegularExpressionMatchString(RgEx), #PB_String_CaseSensitive, ReplaceGr()\pos, 1)
				EndIf
			Next

			If AddElement(item())
				item() = Mid(*Result\s, Offset, Pos - Offset) + Replace$
			EndIf
			Offset = Pos + RegularExpressionMatchLength(RgEx)
		Wend
		If AddElement(item())
			item() = Mid(*Result\s, Offset)
		EndIf

		LenT = 0
		ForEach item()
			LenT + Len(item())
		Next

		*Result\s = Space(LenT)
		*Point = @*Result\s
		ForEach item()
			CopyMemoryString(item(), @*Point)
		Next

		FreeList(item())
	EndIf
EndProcedure


Procedure.s CompactPath(path$)
	Protected idRE, Text.string
	Text\s = path$
	CompilerSelect #PB_Compiler_OS
		CompilerCase #PB_OS_Windows
			idRE = CreateRegularExpression(#PB_Any, "^(.{3,11}\\|.{11})(.*)(\\.{6,27}|.{27})$" )
		CompilerCase #PB_OS_Linux, #PB_OS_MacOS
			idRE = CreateRegularExpression(#PB_Any, "^(.{3,11}/|.{11})(.*)(/.{6,27}|.{27})$" )
	CompilerEndSelect
	If idRE
		RegexReplace2(idRE, @Text, "\1...\3" )
		FreeRegularExpression(idRE)
	EndIf
	ProcedureReturn Text\s
EndProcedure

#StatBar = 0

Define path$

OpenWindow(0, #PB_Ignore, #PB_Ignore, 300, 200, "Test", #PB_Window_SizeGadget | #PB_Window_SystemMenu)

CreateStatusBar(#StatBar, WindowID(0))

AddStatusBarField(100)
AddStatusBarField(#PB_Ignore)

CompilerSelect #PB_Compiler_OS
	CompilerCase #PB_OS_Windows
		path$ = CompactPath("C:\test\test\test\test\test\test\test\test\test\test\test\test\test\test\test\test\test\test\test\test\test\test\test.txt")
		StatusBarText(#StatBar, 1, path$)
		MessageRequester("", CompactPath("C:\Users\user\AppData\Roaming\PureBasic\PureBasic.prefs"))
	CompilerCase #PB_OS_Linux, #PB_OS_MacOS
		MessageRequester("Linux", CompactPath("/home/user/Apps/purebasic/compilers/pbcompilerc"))
CompilerEndSelect
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Last edited by AZJIO on Wed Mar 05, 2025 2:48 am, edited 2 times in total.
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Damaged IDE dialog

Post by ChrisR »

The file name part suits me fine.
Or, as a simple solution, this could be enough

Code: Select all

If GadgetHeight(#GADGET_FileMonitor_Text, #PB_Gadget_RequiredSize) > GadgetHeight(#GADGET_FileMonitor_Text)
  ResizeWindow(#WINDOW_FileMonitor, #PB_Ignore, #PB_Ignore, #PB_Ignore, WindowHeight(#WINDOW_FileMonitor) + GadgetHeight(#GADGET_FileMonitor_Text, #PB_Gadget_RequiredSize) - GadgetHeight(#GADGET_FileMonitor_Text))
EndIf
Edit: But it's probably not enough, a long path will be truncated horizontally in the TextGadget. This should also be added too

Code: Select all

If GadgetWidth(#GADGET_FileMonitor_Text, #PB_Gadget_RequiredSize) > GadgetWidth(#GADGET_FileMonitor_Text)
  ResizeWindow(#WINDOW_FileMonitor, #PB_Ignore, #PB_Ignore, WindowWidth(#WINDOW_FileMonitor) + GadgetWidth(#GADGET_FileMonitor_Text, #PB_Gadget_RequiredSize) - GadgetWidth(#GADGET_FileMonitor_Text), #PB_Ignore)
EndIf
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Damaged IDE dialog

Post by Fred »

kenmo wrote: Tue Mar 04, 2025 11:56 pm This problem annoyed me before too.

In my own mod of the IDE, I only show the file name part, instead of the full path. In 99.999% of cases, this is enough info! :D

If that's an acceptable compromise I'll submit it on GitHub.
Yes, looks good to me
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [Done] Damaged IDE dialog

Post by Fred »

Post Reply