Spaceing in TMemo not matching text file [closed] - delphi

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I have a text file with this:
_____ _ ___ _ _
|_ _| |_ ___ / __|_ _(_)__| |
| | | ' \/ -_) | (_ | '_| / _` |
|_| |_||_\___| \___|_| |_\__,_|
When I load the file into a TMemo, it looks like this:
How can I fix this? Why is it doing this?
I'm using Delphi 10.2.
procedure TFrmMain.FormCreate(Sender: TObject);
begin
Memo2.Lines.LoadFromFile('C:\Users\user1\Desktop\demo\thegrid.txt');
end;

You're using a variable-width font to display it, and ASCII art like that only looks right when it's displayed with a fixed-width font.

Related

Delphi memo why cursor going to the Left always [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
In my VCL project, I have a TMemo with the following text (| is the caret):
| |
|Hello world | |
| |
|test |
| |
| |
When I press the Down button, the caret moves here:
| |
|Hello world |
|| |
|test |
| |
| |
What I need is for it to move here instead:
| |
|Hello world |
| | |
|test |
| |
| |
I think you would find it instructive to devise your own solution for this. The default behaviour for a TMemo responding to the Down key depends on how many characters there are on the next line. If there are at least as many on the next line as there are on the current line, the caret will stay in the same column number.
So a simple solution might be
When you detect an OnKeyDown event caused by the Down key, check the number of characters in the next line, and if it is fewer than the number of characters in the current line to the left of the caret, right-pad the line below with spaces until the numbers of characters are equal. The on-screen appearance will only exactly maintain the column position if the memo uses a fixed-point font; with a proportional font, the cursor will still "wiggle" a bit left and right because spaces are narrower than most other characters.
Of course, you would need to do this for the Up key too, and it's up to you whether you do similar for mouse clicks.
With a bit of googling you can easily find Delphi code to detect the current line and column number of the caret in a TMemo.
The TMemo in Delphi merely wraps the internal control within Windows itself - which does not natively support such functionality that you desire. It may be possible to modify it to behave in such manner, but easier to use something which is already designed for this. One largely popular control which can do this is the SynEdit which is geared towards code editors and syntax highlighting. It might do much more than you need, but it solves what you're looking for.

Programming with Erlang [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm learning Erlang and I'm trying to understand this code that was used as an example.
-module(tutorial5).
-export([format_temps/1]).
format_temps(List_of_cities) ->
convert_list_to_c(List_of_cities).
convert_list_to_c([{Name, {f, F}} | Rest]) ->
Converted_City = {Name, {c, (F -32)* 5 / 9}},
[Converted_City | convert_list_to_c(Rest)];
convert_list_to_c([City | Rest]) ->
[City | convert_list_to_c(Rest)];
convert_list_to_c([]) ->
[].
I am unsure of how to use these methods to get what I need. The most I know about this is that I'm supposed to be able to form a list of cities and their temperatures, and then be able to convert their temperatures from farenheit to celsius and vice versa. Any HELP would be appreciated.
The only callable function in the module tutorial5 is format_temps/1 (it takes one argument). It takes a list of city/temp where each city/temp is a tuple of the form {City,{f,Fahrenheit}} for example {berlin,{f,60}}. The function return a list of city/temp where the temp part is now {c,Celsius}. An example call from the shell with its return would be:
> tutorial5:format_temps([{berlin,{f,59}},{london,{f,50}},{stockholm,{f,50}}]).
[{berlin,{c,15.0}},{london,{c,10.0}},{stockholm,{c,10.0}}]
Some points to note are:
When calling a function in another module you MUST always include the module name
The words starting with lower case letters are atoms, literal constants with a name, while those starting with upper case letters (from my text) are variables. The look alike but are very different.

How to Turn off ARC for a framework if files of that framework are not seen under compile sources? [duplicate]

This question already has answers here:
Disable Automatic Reference Counting for Some Files
(4 answers)
Closed 9 years ago.
i have compiled Pantomime framework and when i add it to my project it shows the following error:
Pantomime.framework/Versions/A/Headers/CWCacheManager.h:40:13: ARC forbids Objective-C objects in structs or unions
How can i turn off ARC or solve this issue because this file CWCacheManager is not showing in compile sources.
All Suggestions are welcome. Thanx in Advance
This is basic step :
Select Project Form Project Manager
|
|
Targets
|
|
Build Phases
|
|
Compile Sources
|
|
Select File that you Want to crate as ARC. (You can also Select Multiple File name from here)
|
|
Press "ENTER" key
|
|
Popup Box/Window is displayed
|
|
Write here - '-fno-objc-arc'
|
|
And again Press 'ENTER' key.
Your selected file is being ARC OFF.

Specflow scenarion description to long

I used to create scenarios where in scenario name I explain what is scenario.
For example:
Scenario: When during context switch, context doesn't match and list of facts for delete are shown to user, facts should be deleted if user has selected them in the list.
But problem is that scenarios getting more and more complicated and scenario names longer and longer. Should I keep writing long names or do you have some better suggestion?
The scenario outlined in the question sounds highly coupled with the system. What is the behaviour you're specifying?
However, to roll with what you've got, I think this is just a language issue.
I Think personally I would just rename it to something like:
Scenario: Should be able to delete non-matching facts
It's more generic but still tells you what's going on when somebody reads the scenario (given the context of the feature and other associated scenarios).
At the end of the day, the length of the scenario name shouldn't matter - just as long as those involved in the development (think the 3 amigos, developer, tester and business stakeholder); all know what it means. But obviously, the easier it is for somebody else to understand, the better.
Well it sounds like you are repeating yourself.
The test below probably doesn't match up to what you mean. But pretend it does.
If your scenario looks like this:
Given the current context is Green
And the following list of facts for delete are selected
| Fact | Checkboxstate |
| A | checked |
| B | |
| C | checked |
| D | |
When I perform a context switch to Orange
Then the following facts should be deleted
| Fact |
| A |
| C |
And the following facts should not be deleted
| Fact |
| B |
| D |
Then the test is barely more complicated than the scenario title you suggested.
(if the test is much more complex than this, then that might be another problem)
Instead try and keep the feature and scenario titles brief and meaningful: e.g.
Feature: Context Switching
Scenario: New Context should be enabled
Scenario: Selected facts should be deleted
etc.

Creating Rowtests with SpecFlow

I am trying to create row tests using SpecFlow and the Microsoft built-in Test Framework, something along these lines:
Scenario Outline: Test Calculator
Given I have entered <x> into the calculator
And I have entered <y> into the calculator
When I press add
Then the result should be <result> on the screen
Examples:
| x | y | result|
| 1 | 2 | 3|
| 2 | 2 | 4|
The problem I am facing is that given any step in the Scenario Outline a separate step method is auto-generated for each value from the Examples table. I would like to be able to implement for each step a generic method receiving input values as parameters but it just does not seem to work.
In the end it looks like it works as expected, what I was missing were quotes around input parameters placeholders:
Scenario Outline: Test Calculator
Given I have entered "<x>" into the calculator
And I have entered "<y>" into the calculator
When I press add
Then the result should be "<result>" on the screen
Examples:
| x | y | result|
| 1 | 2 | 3|
| 2 | 2 | 4|
I had this same problem in VS 2012. I think it may be a bug with SpecFlow, because when I change the Scenario Outline to only be a Scenario, it generates everything correctly. All the documentation says you should not have to surround the placeholders in quotes.
In short, my solution is to change it to a Scenario to generate the steps. But don't forget, you have to change it back to a Scenario Outline to compile. This is what is working for me.

Resources